diff options
Diffstat (limited to 't')
-rw-r--r-- | t/README | 2 | ||||
-rwxr-xr-x | t/io/pipe.t | 6 | ||||
-rwxr-xr-x | t/lib/dirhand.t | 33 | ||||
-rwxr-xr-x | t/lib/filehand.t | 29 | ||||
-rwxr-xr-x | t/lib/posix.t | 50 | ||||
-rwxr-xr-x[-rw-r--r--] | t/lib/safe.t | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | t/lib/socket.t | 3 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/overload.t | 0 | ||||
-rwxr-xr-x | t/op/time.t | 2 |
9 files changed, 93 insertions, 38 deletions
@@ -8,4 +8,4 @@ If you put out extra lines with a '#' character on the front, you don't have to worry about removing the extra print statements later since TEST ignores lines beginning with '#'. -If you come up with new tests, send them to lwall@netlabs.com. +If you come up with new tests, send them to lwall@sems.com. diff --git a/t/io/pipe.t b/t/io/pipe.t index 0133c39e49..95df4dccb6 100755 --- a/t/io/pipe.t +++ b/t/io/pipe.t @@ -5,9 +5,9 @@ $| = 1; print "1..8\n"; -open(PIPE, "|-") || (exec 'tr', '[A-Z]', '[a-z]'); -print PIPE "OK 1\n"; -print PIPE "ok 2\n"; +open(PIPE, "|-") || (exec 'tr', 'YX', 'ko'); +print PIPE "Xk 1\n"; +print PIPE "oY 2\n"; close PIPE; if (open(PIPE, "-|")) { diff --git a/t/lib/dirhand.t b/t/lib/dirhand.t new file mode 100755 index 0000000000..8403609578 --- /dev/null +++ b/t/lib/dirhand.t @@ -0,0 +1,33 @@ +#!./perl + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; + require Config; import Config; + if ($Config{'extensions'} !~ /\bPOSIX\b/) { + print "1..0\n"; + exit 0; + } +} + +use DirHandle; + +print "1..5\n"; + +$dot = new DirHandle "."; +print defined($dot) ? "ok" : "not ok", " 1\n"; + +@a = <*>; +do { $first = $dot->read } while defined($first) && $first =~ /^\./; +print +(grep { $_ eq $first } @a) ? "ok" : "not ok", " 2\n"; + +@b = sort($first, (grep {/^[^.]/} $dot->read)); +print +(join("\0", @a) eq join("\0", @b)) ? "ok" : "not ok", " 3\n"; + +$dot->rewind; +@c = sort grep {/^[^.]/} $dot->read; +print +(join("\0", @b) eq join("\0", @c)) ? "ok" : "not ok", " 4\n"; + +$dot->close; +$dot->rewind; +print defined($dot->read) ? "not ok" : "ok", " 5\n"; diff --git a/t/lib/filehand.t b/t/lib/filehand.t new file mode 100755 index 0000000000..401801c7d7 --- /dev/null +++ b/t/lib/filehand.t @@ -0,0 +1,29 @@ +#!./perl + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; + require Config; import Config; + if ($Config{'extensions'} !~ /\bFileHandle\b/) { + print "1..0\n"; + exit 0; + } +} + +use FileHandle; +use strict subs; + +$mystdout = new_from_fd FileHandle 1,"w"; +autoflush STDOUT; +autoflush $mystdout; +print "1..4\n"; + +print $mystdout "ok ",fileno($mystdout),"\n"; + +$fh = new FileHandle "TEST", O_RDONLY and print "ok 2\n"; +$buffer = <$fh>; +print $buffer eq "#!./perl\n" ? "ok 3\n" : "not ok 3\n"; + +ungetc STDIN 65; +CORE::read(STDIN, $buf,1); +print $buf eq 'A' ? "ok 4\n" : "not ok 4\n"; diff --git a/t/lib/posix.t b/t/lib/posix.t index 06e209c1ba..05b1252209 100755 --- a/t/lib/posix.t +++ b/t/lib/posix.t @@ -9,66 +9,58 @@ BEGIN { exit 0; } } -use FileHandle; + use POSIX qw(fcntl_h signal_h limits_h _exit getcwd open read write); use strict subs; -$mystdout = new_from_fd FileHandle 1,"w"; -autoflush STDOUT; -autoflush $mystdout; -print "1..16\n"; - -print $mystdout "ok ",fileno($mystdout),"\n"; -write(1,"ok 2\nnot ok 2\n", 5); +$| = 1; +print "1..14\n"; -$testfd = open("TEST", O_RDONLY, 0) and print "ok 3\n"; +$testfd = open("TEST", O_RDONLY, 0) and print "ok 1\n"; read($testfd, $buffer, 9) if $testfd > 2; -print $buffer eq "#!./perl\n" ? "ok 4\n" : "not ok 4\n"; +print $buffer eq "#!./perl\n" ? "ok 2\n" : "not ok 2\n"; + +write(1,"ok 3\nnot ok 3\n", 5); @fds = POSIX::pipe(); -print $fds[0] > $testfd ? "ok 5\n" : "not ok 5\n"; -$writer = FileHandle->new_from_fd($fds[1], "w"); -$reader = FileHandle->new_from_fd($fds[0], "r"); -print $writer "ok 6\n"; +print $fds[0] > $testfd ? "ok 4\n" : "not ok 4\n"; +CORE::open($reader = \*READER, "<&=".$fds[0]); +CORE::open($writer = \*WRITER, ">&=".$fds[1]); +print $writer "ok 5\n"; close $writer; print <$reader>; close $reader; $sigset = new POSIX::SigSet 1,3; delset $sigset 1; -if (!ismember $sigset 1) { print "ok 7\n" } -if (ismember $sigset 3) { print "ok 8\n" } +if (!ismember $sigset 1) { print "ok 6\n" } +if (ismember $sigset 3) { print "ok 7\n" } $mask = new POSIX::SigSet &SIGINT; $action = new POSIX::SigAction 'main::SigHUP', $mask, 0; sigaction(&SIGHUP, $action); $SIG{'INT'} = 'SigINT'; kill 'HUP', $$; sleep 1; -print "ok 12\n"; +print "ok 11\n"; sub SigHUP { - print "ok 9\n"; + print "ok 8\n"; kill 'INT', $$; sleep 2; - print "ok 10\n"; + print "ok 9\n"; } sub SigINT { - print "ok 11\n"; + print "ok 10\n"; } -print &_POSIX_OPEN_MAX > $fds[1] ? "ok 13\n" : "not ok 13\n"; +print &_POSIX_OPEN_MAX > $fds[1] ? "ok 12\n" : "not ok 12\n"; -print getcwd() =~ m#/t$# ? "ok 14\n" : "not ok 14\n"; +print getcwd() =~ m#/t$# ? "ok 13\n" : "not ok 13\n"; # Pick up whether we're really able to dynamically load everything. -print &POSIX::acos(1.0) == 0.0 ? "ok 15\n" : "not ok 15\n"; - -ungetc STDIN 65; -CORE::read(STDIN, $buf,1); -print $buf eq 'A' ? "ok 16\n" : "not ok 16\n"; +print &POSIX::acos(1.0) == 0.0 ? "ok 14\n" : "not ok 14\n"; -flush STDOUT; -autoflush STDOUT 0; +$| = 0; print '@#!*$@(!@#$'; _exit(0); diff --git a/t/lib/safe.t b/t/lib/safe.t index c7669a05e4..dfd6032cc7 100644..100755 --- a/t/lib/safe.t +++ b/t/lib/safe.t @@ -4,7 +4,7 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; require Config; import Config; - if ($Config{'extensions'} !~ /\bSafe\b/) { + if ($Config{'extensions'} !~ /\bSafe\b/ && $Config{'osname'} ne 'VMS') { print "1..0\n"; exit 0; } @@ -81,8 +81,8 @@ push(@Root::bar, "18"); # Two steps to prevent "Identifier used only once..." print "$Root::foo\n"; print "@{$cpt->varglob('bar')}\n"; -print opname(22) eq "bless" ? "ok 19\n" : "not ok 19\n"; -print opcode("bless") == 22 ? "ok 20\n" : "not ok 20\n"; +print opname(23) eq "bless" ? "ok 19\n" : "not ok 19\n"; +print opcode("bless") == 23 ? "ok 20\n" : "not ok 20\n"; $m1 = $cpt->mask(); $cpt->trap("negate"); diff --git a/t/lib/socket.t b/t/lib/socket.t index e63c43ae4c..14c7609741 100644..100755 --- a/t/lib/socket.t +++ b/t/lib/socket.t @@ -4,7 +4,8 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib' if -d '../lib'; require Config; import Config; - if ($Config{'extensions'} !~ /\bSocket\b/ && $Config{'osname'} ne 'VMS') { + if ($Config{'extensions'} !~ /\bSocket\b/ && + !(($Config{'osname'} eq 'VMS') && $Config{d_has_socket})) { print "1..0\n"; exit 0; } diff --git a/t/op/overload.t b/t/op/overload.t index 183cb273f7..183cb273f7 100644..100755 --- a/t/op/overload.t +++ b/t/op/overload.t diff --git a/t/op/time.t b/t/op/time.t index 186a81cf8a..1bec442fe2 100755 --- a/t/op/time.t +++ b/t/op/time.t @@ -41,7 +41,7 @@ if ($sec != $xsec && $mday && $year) else {print "not ok 4\n";} -if (index(" :0:1:-1:365:366:-365:-366:",':' . ($localyday - $yday) . ':') > 0) +if (index(" :0:1:-1:364:365:-364:-365:",':' . ($localyday - $yday) . ':') > 0) {print "ok 5\n";} else {print "not ok 5\n";} |