4 require Config; import Config;
5 unless ($Config{'useperlio'}) {
6 print "1..0 # Skip: PerlIO not used\n";
11 use Test::More tests => 37;
23 ok(open($txtfh, ">:crlf", $txt));
25 ok(open($binfh, ">:raw", $bin));
27 ok(open($utffh, ">:utf8", $utf));
39 print $utffh "foo\x{ff}\n";
40 print $utffh "bar\x{abcd}\n";
44 ok(open($txtfh, "<:crlf", $txt));
46 ok(open($binfh, "<:raw", $bin));
49 ok(open($utffh, "<:utf8", $utf));
51 is(scalar <$txtfh>, "foo\n");
52 is(scalar <$txtfh>, "bar\n");
54 is(scalar <$binfh>, "foo\n");
55 is(scalar <$binfh>, "bar\n");
57 is(scalar <$utffh>, "foo\x{ff}\n");
58 is(scalar <$utffh>, "bar\x{abcd}\n");
72 # magic temporary file via 3 arg open with undef
74 ok( open(my $x,"+<",undef), 'magic temp file via 3 arg open with undef');
75 ok( defined fileno($x), ' fileno' );
78 ok( (print "ok\n"), ' print' );
81 ok( seek($x,0,0), ' seek' );
82 is( scalar <$x>, "ok\n", ' readline' );
83 ok( tell($x) >= 3, ' tell' );
85 # test magic temp file over STDOUT
86 open OLDOUT, ">&STDOUT" or die "cannot dup STDOUT: $!";
87 my $status = open(STDOUT,"+<",undef);
88 open STDOUT, ">&OLDOUT" or die "cannot dup OLDOUT: $!";
89 # report after STDOUT is restored
90 ok($status, ' re-open STDOUT');
97 ok( open(my $x,"+<",\$var), 'magic in-memory file via 3 arg open with \\$var');
98 ok( defined fileno($x), ' fileno' );
101 ok( (print "ok\n"), ' print' );
104 ok( seek($x,0,0), ' seek' );
105 is( scalar <$x>, "ok\n", ' readline' );
106 ok( tell($x) >= 3, ' tell' );
109 local $TODO = "broken";
111 # test in-memory open over STDOUT
112 open OLDOUT, ">&STDOUT" or die "cannot dup STDOUT: $!";
114 my $status = open(STDOUT,">",\$var);
115 my $error = "$!" unless $status; # remember the error
116 close STDOUT unless $status;
117 open STDOUT, ">&OLDOUT" or die "cannot dup OLDOUT: $!";
118 print "# $error\n" unless $status;
119 # report after STDOUT is restored
120 ok($status, ' open STDOUT into in-memory var');
122 # test in-memory open over STDERR
123 open OLDERR, ">&STDERR" or die "cannot dup STDERR: $!";
125 ok( open(STDERR,">",\$var), ' open STDERR into in-memory var');
126 open STDERR, ">&OLDERR" or die "cannot dup OLDERR: $!";