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