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