Test scripts for I18N::Langinfo and POSIX
[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 for my $i (0..2) {
31     $r = eval { $termios->getattr($i) };
32     is( $@, '', "calling getattr($i)" );
33     ok( defined $r, "\tchecking if the returned value is defined: $r" );
34 }
35
36 # testing getcc()
37 for my $i (0..NCCS()-1) {
38     $r = eval { $termios->getcc($i) };
39     is( $@, '', "calling getcc($i)" );
40     ok( defined $r, "\tchecking if the returned value is defined: $r" );
41 }
42
43 # testing getcflag()
44 for my $method (@getters) {
45     $r = eval { $termios->$method() };
46     is( $@, '', "calling $method()" );
47     ok( defined $r, "\tchecking if the returned value is defined: $r" );
48 }
49