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