summaryrefslogtreecommitdiff
path: root/t/io
diff options
context:
space:
mode:
authorSlaven Rezic <slaven@rezic.de>2002-10-24 02:44:35 +0200
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2002-11-06 20:43:14 +0000
commitb5fe5ca2134a9ef76f895fb7bc7abec4e8196b08 (patch)
treed5d5274d84dd6dfa2a4103e403440d05c5478c54 /t/io
parent62e36f8a468863e09ecdb7f4dfc6bb112b1a327e (diff)
downloadperl-b5fe5ca2134a9ef76f895fb7bc7abec4e8196b08.tar.gz
Re: [perl #18048] read \*FH, ... returns undef but doesn' t set $! if \*FH not open
Message-ID: <87vg3sixm4.fsf@vran.herceg.de> p4raw-id: //depot/perl@18115
Diffstat (limited to 't/io')
-rw-r--r--t/io/binmode.t14
-rwxr-xr-xt/io/print.t27
-rwxr-xr-xt/io/read.t27
3 files changed, 54 insertions, 14 deletions
diff --git a/t/io/binmode.t b/t/io/binmode.t
index 3775290bf5..f50d0f7fa8 100644
--- a/t/io/binmode.t
+++ b/t/io/binmode.t
@@ -3,12 +3,13 @@
BEGIN {
chdir 't' if -d 't';
@INC = qw(. ../lib);
+ require './test.pl';
}
use Config;
+use Errno;
-require "test.pl";
-plan(tests => 8);
+plan(tests => 9);
ok( binmode(STDERR), 'STDERR made binary' );
if (find PerlIO::Layer 'perlio') {
@@ -28,3 +29,12 @@ if (find PerlIO::Layer 'perlio') {
}
ok( binmode(STDOUT, ":raw"), ' raw' );
ok( binmode(STDOUT, ":crlf"), ' and crlf' );
+
+SKIP: {
+ skip "no EBADF", 1 if (!exists &Errno::EBADF);
+
+ no warnings 'io';
+ $! = 0;
+ binmode(B);
+ ok($! == &Errno::EBADF);
+}
diff --git a/t/io/print.t b/t/io/print.t
index 0578ee6a29..f33aa666a3 100755
--- a/t/io/print.t
+++ b/t/io/print.t
@@ -1,8 +1,16 @@
#!./perl
-print "1..18\n";
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+use strict 'vars';
+use Errno;
+
+print "1..19\n";
-$foo = 'STDOUT';
+my $foo = 'STDOUT';
print $foo "ok 1\n";
print "ok 2\n","ok 3\n","ok 4\n";
@@ -14,7 +22,7 @@ print foo "ok 6\n";
printf "ok %d\n",7;
printf("ok %d\n",8);
-@a = ("ok %d%c",9,ord("\n"));
+my @a = ("ok %d%c",9,ord("\n"));
printf @a;
$a[1] = 10;
@@ -25,10 +33,19 @@ $\ = "\n";
print "ok","11";
-@x = ("ok","12\nok","13\nok");
-@y = ("15\nok","16");
+my @x = ("ok","12\nok","13\nok");
+my @y = ("15\nok","16");
print @x,"14\nok",@y;
{
local $\ = "ok 17\n# null =>[\000]\nok 18\n";
print "";
}
+
+if (!exists &Errno::EBADF) {
+ print "ok 19 # skipped: no EBADF\n";
+} else {
+ $! = 0;
+ print NONEXISTENT "foo";
+ print "not " if ($! != &Errno::EBADF);
+ print "ok 19\n";
+}
diff --git a/t/io/read.t b/t/io/read.t
index b27fde17c7..ea2672dedb 100755
--- a/t/io/read.t
+++ b/t/io/read.t
@@ -2,13 +2,22 @@
# $RCSfile$
-print "1..1\n";
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ require './test.pl';
+}
+
+use strict;
+use Errno;
+
+plan tests => 2;
open(A,"+>a");
print A "_";
seek(A,0,0);
-$b = "abcd";
+my $b = "abcd";
$b = "";
read(A,$b,1,4);
@@ -17,10 +26,14 @@ close(A);
unlink("a");
-if ($b eq "\000\000\000\000_") {
- print "ok 1\n";
-} else { # Probably "\000bcd_"
- print "not ok 1\n";
-}
+is($b,"\000\000\000\000_"); # otherwise probably "\000bcd_"
unlink 'a';
+
+SKIP: {
+ skip "no EBADF", 1 if (!exists &Errno::EBADF);
+
+ $! = 0;
+ read(B,$b,1);
+ ok($! == &Errno::EBADF);
+}