1#!./perl 2 3BEGIN { 4 chdir 't' if -d 't'; 5 @INC = '../lib'; 6 if ($ENV{PERL_CORE_MINITEST}) { 7 print "1..0 # Skip: no Fcntl under miniperl\n"; 8 exit 0; 9 } 10 unless (find PerlIO::Layer 'perlio') { 11 print "1..0 # Skip: not perlio\n"; 12 exit 0; 13 } 14 use Config; 15 unless (" $Config{extensions} " =~ / Fcntl /) { 16 print "1..0 # Skip: no Fcntl (how did you get this far?)\n"; 17 exit 0; 18 } 19} 20 21use strict; 22use warnings; 23 24use Test::More tests => 6; 25 26use Fcntl qw(:seek); 27 28{ 29 ok((open my $fh, "+>", undef), "open my \$fh, '+>', undef"); 30 print $fh "the right write stuff"; 31 ok(seek($fh, 0, SEEK_SET), "seek to zero"); 32 my $data = <$fh>; 33 is($data, "the right write stuff", "found the right stuff"); 34} 35 36{ 37 ok((open my $fh, "+<", undef), "open my \$fh, '+<', undef"); 38 print $fh "the right read stuff"; 39 ok(seek($fh, 0, SEEK_SET), "seek to zero"); 40 my $data = <$fh>; 41 is($data, "the right read stuff", "found the right stuff"); 42} 43 44 45 46 47