5 unshift @INC, '../lib';
11 $Is_VMS = $^O eq 'VMS';
17 sub ok { print "ok $test\n"; $test++ }
23 unlink("afile") if -f "afile";
24 print "$!\nnot " unless open(my $f,"+>afile");
27 print "not " unless -f "afile";
29 print "not " unless print $f "SomeData\n";
31 print "not " unless tell($f) == 9;
33 print "not " unless seek($f,0,0);
36 print "not " unless $b eq "SomeData\n";
38 print "not " unless -f $f;
40 eval { die "Message" };
42 print "not " unless $@ =~ /<\$f> line 1/;
44 print "not " unless close($f);
51 print "# \$!='$!'\nnot " unless open(my $f,'>', 'afile');
54 print "not " unless close($f);
56 print "not " unless -s 'afile' < 10;
62 print "# \$!='$!'\nnot " unless open(my $f,'>>', 'afile');
65 print "not " unless close($f);
67 print "not " unless -s 'afile' > 10;
73 print "# \$!='$!'\nnot " unless open(my $f, '<', 'afile');
76 print "not " unless @rows == 2;
78 print "not " unless close($f);
84 print "not " unless -s 'afile' < 20;
86 print "# \$!='$!'\nnot " unless open(my $f, '+<', 'afile');
89 print "not " unless @rows == 2;
92 print $f "yet another row\n";
93 print "not " unless close($f);
95 print "not " unless -s 'afile' > 20;
103 for (24..26) { print "ok $_ # skipped: not Unix fork\n"; $test++;}
106 print "# \$!='$!'\nnot " unless open(my $f, '-|', <<'EOC');
107 ./perl -e "print qq(a row\n); print qq(another row\n)"
111 print "not " unless @rows == 2;
113 print "not " unless close($f);
119 for (27..30) { print "ok $_ # skipped: not Unix fork\n"; $test++;}
122 print "# \$!='$!'\nnot " unless open(my $f, '|-', <<'EOC');
123 ./perl -pe "s/^not //"
127 print $f "not ok $test\n"; $test++;
128 print $f "not ok $test\n"; $test++;
129 print "#\nnot " unless close($f);
135 eval <<'EOE' and print "not ";
136 open my $f, '<&', 'afile';
140 $@ =~ /Unknown open\(\) mode \'<&\'/ or print "not ";
147 unlink("afile") if -f "afile";
148 print "$!\nnot " unless open(local $f,"+>afile");
151 print "not " unless -f "afile";
153 print "not " unless print $f "SomeData\n";
155 print "not " unless tell($f) == 9;
157 print "not " unless seek($f,0,0);
160 print "not " unless $b eq "SomeData\n";
162 print "not " unless -f $f;
164 eval { die "Message" };
166 print "not " unless $@ =~ /<\$f> line 1/;
168 print "not " unless close($f);
175 print "# \$!='$!'\nnot " unless open(local $f,'>', 'afile');
178 print "not " unless close($f);
180 print "not " unless -s 'afile' < 10;
186 print "# \$!='$!'\nnot " unless open(local $f,'>>', 'afile');
189 print "not " unless close($f);
191 print "not " unless -s 'afile' > 10;
197 print "# \$!='$!'\nnot " unless open(local $f, '<', 'afile');
200 print "not " unless @rows == 2;
202 print "not " unless close($f);
208 print "not " unless -s 'afile' < 20;
210 print "# \$!='$!'\nnot " unless open(local $f, '+<', 'afile');
213 print "not " unless @rows == 2;
216 print $f "yet another row\n";
217 print "not " unless close($f);
219 print "not " unless -s 'afile' > 20;
227 for (56..58) { print "ok $_ # skipped: not Unix fork\n"; $test++;}
230 print "# \$!='$!'\nnot " unless open(local $f, '-|', <<'EOC');
231 ./perl -e "print qq(a row\n); print qq(another row\n)"
235 print "not " unless @rows == 2;
237 print "not " unless close($f);
243 for (59..62) { print "ok $_ # skipped: not Unix fork\n"; $test++;}
246 print "# \$!='$!'\nnot " unless open(local $f, '|-', <<'EOC');
247 ./perl -pe "s/^not //"
251 print $f "not ok $test\n"; $test++;
252 print $f "not ok $test\n"; $test++;
253 print "#\nnot " unless close($f);
259 eval <<'EOE' and print "not ";
260 open local $f, '<&', 'afile';
264 $@ =~ /Unknown open\(\) mode \'<&\'/ or print "not ";
271 open(F, "echo #foo|") or print "not ";
277 open(F, "-|", "echo #foo") or print "not ";