Attempt to fix core-specific logic in IPC::Open2 tests
[p5sagit/p5-mst-13.2.git] / ext / POSIX / t / termios.t
CommitLineData
6e32c255 1#!perl -T
2
3BEGIN {
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 9use strict;
10use POSIX;
60e845e3 11BEGIN {
12 plan skip_all => "POSIX::Termios not implemented"
13 if !eval "POSIX::Termios->new;1"
14 and $@=~/not implemented/;
15}
16
6e32c255 17
18my @getters = qw(getcflag getiflag getispeed getlflag getoflag getospeed);
19
20plan tests => 3 + 2 * (3 + NCCS() + @getters);
21
22my $r;
23
24# create a new object
25my $termios = eval { POSIX::Termios->new };
26is( $@, '', "calling POSIX::Termios->new" );
27ok( defined $termios, "\tchecking if the object is defined" );
28isa_ok( $termios, "POSIX::Termios", "\tchecking the type of the object" );
29
30# testing getattr()
220f811a 31
32SKIP: {
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
39SKIP: {
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
46SKIP: {
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()
54for 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()
61for 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