Commit | Line | Data |
6e32c255 |
1 | #!perl -T |
2 | |
3 | BEGIN { |
6e32c255 |
4 | use Config; |
5 | use Test::More; |
60e845e3 |
6 | plan skip_all => "POSIX is unavailable" |
7 | if $Config{'extensions'} !~ m!\bPOSIX\b!; |
6e32c255 |
8 | } |
6e32c255 |
9 | use strict; |
10 | use POSIX; |
60e845e3 |
11 | BEGIN { |
12 | plan skip_all => "POSIX::Termios not implemented" |
13 | if !eval "POSIX::Termios->new;1" |
14 | and $@=~/not implemented/; |
15 | } |
16 | |
6e32c255 |
17 | |
18 | my @getters = qw(getcflag getiflag getispeed getlflag getoflag getospeed); |
19 | |
20 | plan tests => 3 + 2 * (3 + NCCS() + @getters); |
21 | |
22 | my $r; |
23 | |
24 | # create a new object |
25 | my $termios = eval { POSIX::Termios->new }; |
26 | is( $@, '', "calling POSIX::Termios->new" ); |
27 | ok( defined $termios, "\tchecking if the object is defined" ); |
28 | isa_ok( $termios, "POSIX::Termios", "\tchecking the type of the object" ); |
29 | |
30 | # testing getattr() |
220f811a |
31 | |
32 | SKIP: { |
33 | -t STDIN or skip("STDIN not a tty", 2); |
34 | $r = eval { $termios->getattr(0) }; |
35 | is( $@, '', "calling getattr(0)" ); |
36 | ok( defined $r, "\tchecking if the returned value is defined: $r" ); |
37 | } |
38 | |
39 | SKIP: { |
40 | -t STDOUT or skip("STDOUT not a tty", 2); |
41 | $r = eval { $termios->getattr(1) }; |
42 | is( $@, '', "calling getattr(1)" ); |
43 | ok( defined $r, "\tchecking if the returned value is defined: $r" ); |
44 | } |
45 | |
46 | SKIP: { |
47 | -t STDERR or skip("STDERR not a tty", 2); |
48 | $r = eval { $termios->getattr(2) }; |
49 | is( $@, '', "calling getattr(2)" ); |
6e32c255 |
50 | ok( defined $r, "\tchecking if the returned value is defined: $r" ); |
51 | } |
52 | |
53 | # testing getcc() |
54 | for my $i (0..NCCS()-1) { |
55 | $r = eval { $termios->getcc($i) }; |
56 | is( $@, '', "calling getcc($i)" ); |
57 | ok( defined $r, "\tchecking if the returned value is defined: $r" ); |
58 | } |
59 | |
60 | # testing getcflag() |
61 | for my $method (@getters) { |
62 | $r = eval { $termios->$method() }; |
63 | is( $@, '', "calling $method()" ); |
64 | ok( defined $r, "\tchecking if the returned value is defined: $r" ); |
65 | } |
66 | |