1#!./perl
2
3BEGIN {
4    chdir 't' if -d 't';
5    require './test.pl';
6    set_up_inc('../lib');
7    eval 'use Errno';
8    die $@ if $@ and !is_miniperl();
9}
10
11use strict;
12
13plan tests => 2;
14
15my $tmpfile = tempfile();
16
17open(A,"+>$tmpfile");
18print A "_";
19seek(A,0,0);
20
21my $b = "abcd"; 
22$b = "";
23
24read(A,$b,1,4);
25
26close(A);
27
28is($b,"\000\000\000\000_"); # otherwise probably "\000bcd_"
29
30SKIP: {
31    skip "no EBADF", 1 if (!exists &Errno::EBADF);
32
33    $! = 0;
34    no warnings 'unopened';
35    read(B,$b,1);
36    ok($! == &Errno::EBADF);
37}
38