This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
6d590ff6881c4435fa6abfeb2258ac33daef24ac
[perl5.git] / t / io / read.t
1 #!./perl
2
3 # $RCSfile$
4
5 BEGIN {
6     chdir 't' if -d 't';
7     @INC = '../lib';
8     require './test.pl';
9 }
10
11 use strict;
12 eval 'use Errno';
13 die $@ if $@ and !$ENV{PERL_CORE_MINITEST};
14
15 plan tests => 2;
16
17 open(A,"+>a");
18 print A "_";
19 seek(A,0,0);
20
21 my $b = "abcd"; 
22 $b = "";
23
24 read(A,$b,1,4);
25
26 close(A);
27
28 unlink("a");
29
30 is($b,"\000\000\000\000_"); # otherwise probably "\000bcd_"
31
32 unlink 'a';
33
34 SKIP: {
35     skip "no EBADF", 1 if (!exists &Errno::EBADF);
36
37     $! = 0;
38     no warnings 'unopened';
39     read(B,$b,1);
40     ok($! == &Errno::EBADF);
41 }