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