4 require Config; import Config;
5 unless ($Config{'useperlio'}) {
6 print "1..0 # Skip: PerlIO not used\n";
11 use Test::More tests => 35;
23 ok(open($txtfh, ">:crlf", $txt));
25 ok(open($binfh, ">:raw", $bin));
27 ok(open($utffh, ">:utf8", $utf));
40 print $utffh "foo\x{ff}\n";
41 print $utffh "bar\x{abcd}\n";
45 ok(open($txtfh, "<:crlf", $txt));
47 ok(open($binfh, "<:raw", $bin));
50 ok(open($utffh, "<:utf8", $utf));
52 is(scalar <$txtfh>, "foo\n");
53 is(scalar <$txtfh>, "bar\n");
55 is(scalar <$binfh>, "foo\n");
56 is(scalar <$binfh>, "bar\n");
58 is(scalar <$utffh>, "foo\x{ff}\n");
59 is(scalar <$utffh>, "bar\x{abcd}\n");
73 # magic temporary file via 3 arg open with undef
75 ok( open(my $x,"+<",undef), 'magic temp file via 3 arg open with undef');
76 ok( defined fileno($x), ' fileno' );
79 ok( (print "ok\n"), ' print' );
82 ok( seek($x,0,0), ' seek' );
83 is( scalar <$x>, "ok\n", ' readline' );
84 ok( tell($x) >= 3, ' tell' );
86 # test magic temp file over STDOUT
87 open OLDOUT, ">&STDOUT" or die "cannot dup STDOUT: $!";
88 my $status = open(STDOUT,"+<",undef);
89 open STDOUT, ">&OLDOUT" or die "cannot dup OLDOUT: $!";
90 # report after STDOUT is restored
91 ok($status, ' re-open STDOUT');
98 ok( open(my $x,"+<",\$var), 'magic in-memory file via 3 arg open with \\$var');
99 ok( defined fileno($x), ' fileno' );
102 ok( (print "ok\n"), ' print' );
105 ok( seek($x,0,0), ' seek' );
106 is( scalar <$x>, "ok\n", ' readline' );
107 ok( tell($x) >= 3, ' tell' );