Remove code specific to MacOS Classic from core tests
[p5sagit/p5-mst-13.2.git] / t / lib / warnings / doio
CommitLineData
767a6a26 1 doio.c
599cee73 2
9a7dcd9c 3 Can't open bidirectional pipe [Perl_do_open9]
599cee73 4 open(F, "| true |");
5
767a6a26 6 Missing command in piped open [Perl_do_open9]
06eaf0bc 7 open(F, "| ");
8
767a6a26 9 Missing command in piped open [Perl_do_open9]
06eaf0bc 10 open(F, " |");
11
767a6a26 12 warn(warn_nl, "open"); [Perl_do_open9]
599cee73 13 open(F, "true\ncd")
14
2dd78f96 15 close() on unopened filehandle %s [Perl_do_close]
767a6a26 16 $a = "fred";close("$a")
599cee73 17
2dd78f96 18 tell() on closed filehandle [Perl_do_tell]
599cee73 19 $a = "fred";$a = tell($a)
20
2dd78f96 21 seek() on closed filehandle [Perl_do_seek]
599cee73 22 $a = "fred";$a = seek($a,1,1)
23
2dd78f96 24 sysseek() on closed filehandle [Perl_do_sysseek]
599cee73 25 $a = "fred";$a = seek($a,1,1)
26
767a6a26 27 warn(warn_uninit); [Perl_do_print]
599cee73 28 print $a ;
29
2dd78f96 30 -x on closed filehandle %s [Perl_my_stat]
599cee73 31 close STDIN ; -x STDIN ;
32
767a6a26 33 warn(warn_nl, "stat"); [Perl_my_stat]
599cee73 34 stat "ab\ncd"
35
767a6a26 36 warn(warn_nl, "lstat"); [Perl_my_lstat]
599cee73 37 lstat "ab\ncd"
38
5d3e98de 39 Use of -l on filehandle %s [Perl_my_lstat]
40
767a6a26 41 Can't exec \"%s\": %s [Perl_do_aexec5]
599cee73 42
767a6a26 43 Can't exec \"%s\": %s [Perl_do_exec3]
599cee73 44
767a6a26 45 Filehandle %s opened only for output [Perl_do_eof]
46 my $a = eof STDOUT
599cee73 47
0453d815 48 Mandatory Warnings ALL TODO
49 ------------------
767a6a26 50 Can't do inplace edit: %s is not a regular file [Perl_nextargv]
0453d815 51 edit a directory
52
767a6a26 53 Can't do inplace edit: %s would not be unique [Perl_nextargv]
54 Can't rename %s to %s: %s, skipping file [Perl_nextargv]
55 Can't rename %s to %s: %s, skipping file [Perl_nextargv]
56 Can't remove %s: %s, skipping file [Perl_nextargv]
57 Can't do inplace edit on %s: %s [Perl_nextargv]
0453d815 58
59
599cee73 60__END__
767a6a26 61# doio.c [Perl_do_open9]
4438c4b7 62use warnings 'io' ;
16ed4686 63open(F, '|'."$^X -e 1|");
3eeba6fb 64close(F);
4438c4b7 65no warnings 'io' ;
16ed4686 66open(G, '|'."$^X -e 1|");
0453d815 67close(G);
599cee73 68EXPECT
9a7dcd9c 69Can't open bidirectional pipe at - line 3.
599cee73 70########
767a6a26 71# doio.c [Perl_do_open9]
4438c4b7 72use warnings 'io' ;
0453d815 73open(F, "| ");
4438c4b7 74no warnings 'io' ;
0453d815 75open(G, "| ");
06eaf0bc 76EXPECT
77Missing command in piped open at - line 3.
78########
767a6a26 79# doio.c [Perl_do_open9]
4438c4b7 80use warnings 'io' ;
0453d815 81open(F, " |");
4438c4b7 82no warnings 'io' ;
0453d815 83open(G, " |");
06eaf0bc 84EXPECT
85Missing command in piped open at - line 3.
86########
767a6a26 87# doio.c [Perl_do_open9]
4438c4b7 88use warnings 'io' ;
0453d815 89open(F, "<true\ncd");
4438c4b7 90no warnings 'io' ;
0453d815 91open(G, "<true\ncd");
599cee73 92EXPECT
93Unsuccessful open on filename containing newline at - line 3.
94########
767a6a26 95# doio.c [Perl_do_close] <<TODO
96use warnings 'unopened' ;
97close "fred" ;
98no warnings 'unopened' ;
99close "joe" ;
100EXPECT
9ddeeac9 101close() on unopened filehandle fred at - line 3.
767a6a26 102########
103# doio.c [Perl_do_tell Perl_do_seek Perl_do_sysseek Perl_my_stat]
4438c4b7 104use warnings 'io' ;
599cee73 105close STDIN ;
106tell(STDIN);
107$a = seek(STDIN,1,1);
108$a = sysseek(STDIN,1,1);
109-x STDIN ;
9ddeeac9 110stat(STDIN) ;
2dd78f96 111$a = "fred";
112tell($a);
113seek($a,1,1);
114sysseek($a,1,1);
115-x $a; # ok
116stat($a); # ok
4438c4b7 117no warnings 'io' ;
0453d815 118close STDIN ;
119tell(STDIN);
120$a = seek(STDIN,1,1);
121$a = sysseek(STDIN,1,1);
122-x STDIN ;
9ddeeac9 123stat(STDIN) ;
2dd78f96 124$a = "fred";
125tell($a);
126seek($a,1,1);
127sysseek($a,1,1);
128-x $a;
129stat($a);
599cee73 130EXPECT
2dd78f96 131tell() on closed filehandle STDIN at - line 4.
132seek() on closed filehandle STDIN at - line 5.
133sysseek() on closed filehandle STDIN at - line 6.
134-x on closed filehandle STDIN at - line 7.
135stat() on closed filehandle STDIN at - line 8.
136tell() on unopened filehandle at - line 10.
137seek() on unopened filehandle at - line 11.
138sysseek() on unopened filehandle at - line 12.
599cee73 139########
767a6a26 140# doio.c [Perl_do_print]
4438c4b7 141use warnings 'uninitialized' ;
599cee73 142print $a ;
4438c4b7 143no warnings 'uninitialized' ;
0453d815 144print $b ;
599cee73 145EXPECT
29489e7c 146Use of uninitialized value $a in print at - line 3.
599cee73 147########
767a6a26 148# doio.c [Perl_my_stat Perl_my_lstat]
4438c4b7 149use warnings 'io' ;
599cee73 150stat "ab\ncd";
151lstat "ab\ncd";
4438c4b7 152no warnings 'io' ;
0453d815 153stat "ab\ncd";
154lstat "ab\ncd";
599cee73 155EXPECT
156Unsuccessful stat on filename containing newline at - line 3.
157Unsuccessful stat on filename containing newline at - line 4.
158########
5d3e98de 159# doio.c [Perl_my_stat]
160use warnings 'io';
161-l STDIN;
162-l $fh;
163open $fh, $0 or die "# $!";
164-l $fh;
165no warnings 'io';
166-l STDIN;
167-l $fh;
168close $fh;
169EXPECT
170Use of -l on filehandle STDIN at - line 3.
171Use of -l on filehandle $fh at - line 6.
172########
767a6a26 173# doio.c [Perl_do_aexec5]
4438c4b7 174use warnings 'io' ;
dfe13c55 175exec "lskdjfalksdjfdjfkls","" ;
4438c4b7 176no warnings 'io' ;
0453d815 177exec "lskdjfalksdjfdjfkls","" ;
599cee73 178EXPECT
e5e1b98b 179OPTION regex
c4f6c246 180Can't exec "lskdjfalksdjfdjfkls": .+
599cee73 181########
767a6a26 182# doio.c [Perl_do_exec3]
4438c4b7 183use warnings 'io' ;
599cee73 184exec "lskdjfalksdjfdjfkls", "abc" ;
4438c4b7 185no warnings 'io' ;
0453d815 186exec "lskdjfalksdjfdjfkls", "abc" ;
599cee73 187EXPECT
e5e1b98b 188OPTION regex
3eeba6fb 189Can't exec "lskdjfalksdjfdjfkls(:? abc)?": .+
0453d815 190########
0698c26b 191# doio.c [win32_execvp]
192use warnings 'exec' ;
193exec $^X, "-e0" ;
194EXPECT
195########
767a6a26 196# doio.c [Perl_nextargv]
0453d815 197$^W = 0 ;
ccc2aad8 198my $filename = "./temp.dir" ;
0453d815 199mkdir $filename, 0777
200 or die "Cannot create directory $filename: $!\n" ;
201{
202 local (@ARGV) = ($filename) ;
203 local ($^I) = "" ;
204 my $x = <> ;
205}
206{
4438c4b7 207 no warnings 'inplace' ;
0453d815 208 local (@ARGV) = ($filename) ;
209 local ($^I) = "" ;
210 my $x = <> ;
211}
212{
4438c4b7 213 use warnings 'inplace' ;
0453d815 214 local (@ARGV) = ($filename) ;
215 local ($^I) = "" ;
216 my $x = <> ;
217}
218rmdir $filename ;
219EXPECT
ccc2aad8 220Can't do inplace edit: ./temp.dir is not a regular file at - line 9.
221Can't do inplace edit: ./temp.dir is not a regular file at - line 21.
0453d815 222
767a6a26 223########
224# doio.c [Perl_do_eof]
225use warnings 'io' ;
226my $a = eof STDOUT ;
227no warnings 'io' ;
228$a = eof STDOUT ;
229EXPECT
43693395 230Filehandle STDOUT opened only for output at - line 3.
9a869a14 231########
232# doio.c [Perl_do_openn]
233use Config;
234BEGIN {
235 if ($Config{useperlio}) {
236 print <<EOM;
237SKIPPED
238# warns only without perlio
239EOM
240 exit;
241 }
242}
243use warnings 'io';
244my $x = "foo";
245open FOO, '>', \$x;
35066d42 246open BAR, '>&', \*STDOUT; # should not warn
9a869a14 247no warnings 'io';
248open FOO, '>', \$x;
249EXPECT
250Can't open a reference at - line 14.
97828cef 251########
252# doio.c [Perl_do_openn]
253use Config;
254BEGIN {
255 if (!$Config{useperlio}) {
256 print <<EOM;
257SKIPPED
258# warns only with perlio
259EOM
260 exit;
261 }
262}
263use warnings 'io' ;
264close STDOUT;
265open FH1, "harness"; close FH1;
266no warnings 'io' ;
267open FH2, "harness"; close FH2;
268EXPECT
269Filehandle STDOUT reopened as FH1 only for input at - line 14.
270########
271# doio.c [Perl_do_openn]
272use Config;
273BEGIN {
274 if (!$Config{useperlio}) {
275 print <<EOM;
276SKIPPED
277# warns only with perlio
278EOM
279 exit;
280 }
281}
282use warnings 'io' ;
283close STDIN;
284open my $fh1, ">doiowarn.tmp"; close $fh1;
285no warnings 'io' ;
286open my $fh2, ">doiowarn.tmp"; close $fh2;
287unlink "doiowarn.tmp";
288EXPECT
289Filehandle STDIN reopened as $fh1 only for output at - line 14.