11 $Is_VMS = $^O eq 'VMS';
12 $Is_Dos = $^O eq 'dos';
18 sub ok { print "ok $test\n"; $test++ }
24 unlink("afile") if -f "afile";
25 print "$!\nnot " unless open(my $f,"+>afile");
28 print "not " unless -f "afile";
30 print "not " unless print $f "SomeData\n";
32 print "not " unless tell($f) == 9;
34 print "not " unless seek($f,0,0);
37 print "not " unless $b eq "SomeData\n";
39 print "not " unless -f $f;
41 eval { die "Message" };
43 print "not " unless $@ =~ /<\$f> line 1/;
45 print "not " unless close($f);
52 print "# \$!='$!'\nnot " unless open(my $f,'>', 'afile');
55 print "not " unless close($f);
57 print "not " unless -s 'afile' < 10;
63 print "# \$!='$!'\nnot " unless open(my $f,'>>', 'afile');
66 print "not " unless close($f);
68 print "not " unless -s 'afile' > 10;
74 print "# \$!='$!'\nnot " unless open(my $f, '<', 'afile');
77 print "not " unless @rows == 2;
79 print "not " unless close($f);
85 print "not " unless -s 'afile' < 20;
87 print "# \$!='$!'\nnot " unless open(my $f, '+<', 'afile');
90 print "not " unless @rows == 2;
93 print $f "yet another row\n";
94 print "not " unless close($f);
96 print "not " unless -s 'afile' > 20;
104 for (24..26) { print "ok $_ # skipped: not Unix fork\n"; $test++;}
107 print "# \$!='$!'\nnot " unless open(my $f, '-|', <<'EOC');
108 ./perl -e "print qq(a row\n); print qq(another row\n)"
112 print "not " unless @rows == 2;
114 print "not " unless close($f);
120 for (27..30) { print "ok $_ # skipped: not Unix fork\n"; $test++;}
123 print "# \$!='$!'\nnot " unless open(my $f, '|-', <<'EOC');
124 ./perl -pe "s/^not //"
128 print $f "not ok $test\n"; $test++;
129 print $f "not ok $test\n"; $test++;
130 print "#\nnot " unless close($f);
136 eval <<'EOE' and print "not ";
137 open my $f, '<&', 'afile';
141 $@ =~ /Bad filehandle:\s+afile/ or print "not ";
148 unlink("afile") if -f "afile";
149 print "$!\nnot " unless open(local $f,"+>afile");
152 print "not " unless -f "afile";
154 print "not " unless print $f "SomeData\n";
156 print "not " unless tell($f) == 9;
158 print "not " unless seek($f,0,0);
161 print "not " unless $b eq "SomeData\n";
163 print "not " unless -f $f;
165 eval { die "Message" };
167 print "not " unless $@ =~ /<\$f> line 1/;
169 print "not " unless close($f);
176 print "# \$!='$!'\nnot " unless open(local $f,'>', 'afile');
179 print "not " unless close($f);
181 print "not " unless -s 'afile' < 10;
187 print "# \$!='$!'\nnot " unless open(local $f,'>>', 'afile');
190 print "not " unless close($f);
192 print "not " unless -s 'afile' > 10;
198 print "# \$!='$!'\nnot " unless open(local $f, '<', 'afile');
201 print "not " unless @rows == 2;
203 print "not " unless close($f);
209 print "not " unless -s 'afile' < 20;
211 print "# \$!='$!'\nnot " unless open(local $f, '+<', 'afile');
214 print "not " unless @rows == 2;
217 print $f "yet another row\n";
218 print "not " unless close($f);
220 print "not " unless -s 'afile' > 20;
228 for (56..58) { print "ok $_ # skipped: not Unix fork\n"; $test++;}
231 print "# \$!='$!'\nnot " unless open(local $f, '-|', <<'EOC');
232 ./perl -e "print qq(a row\n); print qq(another row\n)"
236 print "not " unless @rows == 2;
238 print "not " unless close($f);
244 for (59..62) { print "ok $_ # skipped: not Unix fork\n"; $test++;}
247 print "# \$!='$!'\nnot " unless open(local $f, '|-', <<'EOC');
248 ./perl -pe "s/^not //"
252 print $f "not ok $test\n"; $test++;
253 print $f "not ok $test\n"; $test++;
254 print "#\nnot " unless close($f);
260 eval <<'EOE' and print "not ";
261 open local $f, '<&', 'afile';
265 $@ =~ /Bad filehandle:\s+afile/ or print "not ";
273 open(F, "echo \\#foo|") or print "not ";
275 open(F, "echo #foo|") or print "not ";
283 open(F, "-|", "echo \\#foo") or print "not ";
285 open(F, "-|", "echo #foo") or print "not ";
293 # 67..70 - magic temporary file via 3 arg open with undef
295 open(my $x,"+<",undef) or print "not ";
297 print "not " unless defined(fileno($x));
304 print "not " unless tell($x) > 3;