Turn the "$# / $* is no longer supported" warnings into
[p5sagit/p5-mst-13.2.git] / t / lib / warnings / pp_sys
CommitLineData
599cee73 1 pp_sys.c AOK
2
767a6a26 3 untie attempted while %d inner references still exist [pp_untie]
599cee73 4 sub TIESCALAR { bless [] } ; tie $a, 'main'; untie $a ;
5
c289d2f7 6 fileno() on unopened filehandle abc [pp_fileno]
7 $a = "abc"; fileno($a)
8
9 binmode() on unopened filehandle abc [pp_binmode]
10 $a = "abc"; fileno($a)
11
12 printf() on unopened filehandle abc [pp_prtf]
13 $a = "abc"; printf $a "fred"
14
767a6a26 15 Filehandle %s opened only for input [pp_leavewrite]
599cee73 16 format STDIN =
17 .
18 write STDIN;
19
9a7dcd9c 20 write() on closed filehandle %s [pp_leavewrite]
599cee73 21 format STDIN =
22 .
23 close STDIN;
24 write STDIN ;
25
767a6a26 26 page overflow [pp_leavewrite]
599cee73 27
2dd78f96 28 printf() on unopened filehandle abc [pp_prtf]
599cee73 29 $a = "abc"; printf $a "fred"
30
767a6a26 31 Filehandle %s opened only for input [pp_prtf]
599cee73 32 $a = "abc";
33 printf $a "fred"
34
9a7dcd9c 35 printf() on closed filehandle %s [pp_prtf]
599cee73 36 close STDIN ;
37 printf STDIN "fred"
38
69282e91 39 syswrite() on closed filehandle %s [pp_send]
599cee73 40 close STDIN;
41 syswrite STDIN, "fred", 1;
42
69282e91 43 send() on closed socket %s [pp_send]
599cee73 44 close STDIN;
45 send STDIN, "fred", 1
46
69282e91 47 bind() on closed socket %s [pp_bind]
599cee73 48 close STDIN;
49 bind STDIN, "fred" ;
50
51
69282e91 52 connect() on closed socket %s [pp_connect]
599cee73 53 close STDIN;
54 connect STDIN, "fred" ;
55
69282e91 56 listen() on closed socket %s [pp_listen]
599cee73 57 close STDIN;
58 listen STDIN, 2;
59
69282e91 60 accept() on closed socket %s [pp_accept]
599cee73 61 close STDIN;
69282e91 62 accept "fred", STDIN ;
599cee73 63
69282e91 64 shutdown() on closed socket %s [pp_shutdown]
599cee73 65 close STDIN;
66 shutdown STDIN, 0;
67
69282e91 68 setsockopt() on closed socket %s [pp_ssockopt]
69 getsockopt() on closed socket %s [pp_ssockopt]
599cee73 70 close STDIN;
71 setsockopt STDIN, 1,2,3;
72 getsockopt STDIN, 1,2;
73
69282e91 74 getsockname() on closed socket %s [pp_getpeername]
75 getpeername() on closed socket %s [pp_getpeername]
599cee73 76 close STDIN;
77 getsockname STDIN;
78 getpeername STDIN;
79
69282e91 80 flock() on closed socket %s [pp_flock]
bc37a18f 81 flock() on closed socket [pp_flock]
69282e91 82 close STDIN;
83 flock STDIN, 8;
bc37a18f 84 flock $a, 8;
69282e91 85
767a6a26 86 warn(warn_nl, "stat"); [pp_stat]
599cee73 87
2dd78f96 88 -T on closed filehandle %s
89 stat() on closed filehandle %s
90 close STDIN ; -T STDIN ; stat(STDIN) ;
599cee73 91
767a6a26 92 warn(warn_nl, "open"); [pp_fttext]
599cee73 93 -T "abc\ndef" ;
94
767a6a26 95 Filehandle %s opened only for output [pp_sysread]
96 my $file = "./xcv" ;
97 open(F, ">$file") ;
98 my $a = sysread(F, $a,10) ;
5d3e98de 99
90133b69 100 lstat on filehandle %s [pp_lstat]
101
102 getc() on unopened filehandle [pp_getc]
103
104 getc() on closed filehandle [pp_getc]
599cee73 105
4ef2275c 106 Non-string passed as bitmask [pp_sselect]
107
599cee73 108__END__
767a6a26 109# pp_sys.c [pp_untie]
4438c4b7 110use warnings 'untie' ;
599cee73 111sub TIESCALAR { bless [] } ;
112$b = tie $a, 'main';
113untie $a ;
4438c4b7 114no warnings 'untie' ;
0453d815 115$c = tie $d, 'main';
116untie $d ;
599cee73 117EXPECT
118untie attempted while 1 inner references still exist at - line 5.
119########
767a6a26 120# pp_sys.c [pp_leavewrite]
4438c4b7 121use warnings 'io' ;
599cee73 122format STDIN =
123.
124write STDIN;
4438c4b7 125no warnings 'io' ;
0453d815 126write STDIN;
599cee73 127EXPECT
43693395 128Filehandle STDIN opened only for input at - line 5.
599cee73 129########
767a6a26 130# pp_sys.c [pp_leavewrite]
4438c4b7 131use warnings 'closed' ;
599cee73 132format STDIN =
133.
134close STDIN;
135write STDIN;
69282e91 136opendir STDIN, ".";
137write STDIN;
138closedir STDIN;
4438c4b7 139no warnings 'closed' ;
0453d815 140write STDIN;
69282e91 141opendir STDIN, ".";
142write STDIN;
599cee73 143EXPECT
43693395 144write() on closed filehandle STDIN at - line 6.
145write() on closed filehandle STDIN at - line 8.
146 (Are you trying to call write() on dirhandle STDIN?)
599cee73 147########
767a6a26 148# pp_sys.c [pp_leavewrite]
4438c4b7 149use warnings 'io' ;
599cee73 150format STDOUT_TOP =
151abc
152.
153format STDOUT =
154def
155ghi
156.
157$= = 1 ;
158$- =1 ;
3eeba6fb 159open STDOUT, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
599cee73 160write ;
4438c4b7 161no warnings 'io' ;
0453d815 162write ;
599cee73 163EXPECT
164page overflow at - line 13.
165########
767a6a26 166# pp_sys.c [pp_prtf]
4438c4b7 167use warnings 'unopened' ;
599cee73 168$a = "abc";
0453d815 169printf $a "fred";
4438c4b7 170no warnings 'unopened' ;
0453d815 171printf $a "fred";
599cee73 172EXPECT
2dd78f96 173printf() on unopened filehandle abc at - line 4.
599cee73 174########
767a6a26 175# pp_sys.c [pp_prtf]
4438c4b7 176use warnings 'closed' ;
599cee73 177close STDIN ;
0453d815 178printf STDIN "fred";
69282e91 179opendir STDIN, ".";
180printf STDIN "fred";
181closedir STDIN;
4438c4b7 182no warnings 'closed' ;
0453d815 183printf STDIN "fred";
69282e91 184opendir STDIN, ".";
185printf STDIN "fred";
599cee73 186EXPECT
43693395 187printf() on closed filehandle STDIN at - line 4.
188printf() on closed filehandle STDIN at - line 6.
189 (Are you trying to call printf() on dirhandle STDIN?)
599cee73 190########
767a6a26 191# pp_sys.c [pp_prtf]
4438c4b7 192use warnings 'io' ;
0453d815 193printf STDIN "fred";
4438c4b7 194no warnings 'io' ;
0453d815 195printf STDIN "fred";
599cee73 196EXPECT
43693395 197Filehandle STDIN opened only for input at - line 3.
599cee73 198########
767a6a26 199# pp_sys.c [pp_send]
cf167416 200use warnings 'io' ;
201syswrite STDIN, "fred";
202no warnings 'io' ;
203syswrite STDIN, "fred";
204EXPECT
205Filehandle STDIN opened only for input at - line 3.
206########
207# pp_sys.c [pp_send]
4438c4b7 208use warnings 'closed' ;
599cee73 209close STDIN;
210syswrite STDIN, "fred", 1;
69282e91 211opendir STDIN, ".";
212syswrite STDIN, "fred", 1;
213closedir STDIN;
4438c4b7 214no warnings 'closed' ;
0453d815 215syswrite STDIN, "fred", 1;
69282e91 216opendir STDIN, ".";
217syswrite STDIN, "fred", 1;
599cee73 218EXPECT
43693395 219syswrite() on closed filehandle STDIN at - line 4.
220syswrite() on closed filehandle STDIN at - line 6.
221 (Are you trying to call syswrite() on dirhandle STDIN?)
69282e91 222########
223# pp_sys.c [pp_flock]
f0963acb 224use Config;
225BEGIN {
9bdf8ebc 226 if ( !$Config{d_flock} &&
227 !$Config{d_fcntl_can_lock} &&
228 !$Config{d_lockf} ) {
f0963acb 229 print <<EOM ;
230SKIPPED
231# flock not present
232EOM
233 exit ;
234 }
235}
bc37a18f 236use warnings qw(unopened closed);
69282e91 237close STDIN;
238flock STDIN, 8;
239opendir STDIN, ".";
240flock STDIN, 8;
bc37a18f 241flock FOO, 8;
242flock $a, 8;
243no warnings qw(unopened closed);
69282e91 244flock STDIN, 8;
245opendir STDIN, ".";
246flock STDIN, 8;
bc37a18f 247flock FOO, 8;
248flock $a, 8;
69282e91 249EXPECT
43693395 250flock() on closed filehandle STDIN at - line 16.
c934501c 251flock() on closed filehandle STDIN at - line 18.
43693395 252 (Are you trying to call flock() on dirhandle STDIN?)
c934501c 253flock() on unopened filehandle FOO at - line 19.
254flock() on unopened filehandle at - line 20.
599cee73 255########
767a6a26 256# pp_sys.c [pp_prtf pp_send pp_bind pp_connect pp_listen pp_accept pp_shutdown pp_ssockopt ppp_getpeername]
4438c4b7 257use warnings 'io' ;
599cee73 258use Config;
259BEGIN {
260 if ( $^O ne 'VMS' and ! $Config{d_socket}) {
261 print <<EOM ;
262SKIPPED
263# send not present
264# bind not present
265# connect not present
266# accept not present
267# shutdown not present
268# setsockopt not present
269# getsockopt not present
270# getsockname not present
271# getpeername not present
272EOM
273 exit ;
274 }
275}
276close STDIN;
277send STDIN, "fred", 1;
278bind STDIN, "fred" ;
279connect STDIN, "fred" ;
280listen STDIN, 2;
69282e91 281accept "fred", STDIN;
282shutdown STDIN, 0;
283setsockopt STDIN, 1,2,3;
284getsockopt STDIN, 1,2;
285getsockname STDIN;
286getpeername STDIN;
287opendir STDIN, ".";
288send STDIN, "fred", 1;
289bind STDIN, "fred" ;
290connect STDIN, "fred" ;
291listen STDIN, 2;
292accept "fred", STDIN;
599cee73 293shutdown STDIN, 0;
294setsockopt STDIN, 1,2,3;
295getsockopt STDIN, 1,2;
296getsockname STDIN;
297getpeername STDIN;
69282e91 298closedir STDIN;
4438c4b7 299no warnings 'io' ;
0453d815 300send STDIN, "fred", 1;
301bind STDIN, "fred" ;
302connect STDIN, "fred" ;
303listen STDIN, 2;
304accept STDIN, "fred" ;
305shutdown STDIN, 0;
306setsockopt STDIN, 1,2,3;
307getsockopt STDIN, 1,2;
308getsockname STDIN;
309getpeername STDIN;
69282e91 310opendir STDIN, ".";
311send STDIN, "fred", 1;
312bind STDIN, "fred" ;
313connect STDIN, "fred" ;
314listen STDIN, 2;
315accept "fred", STDIN;
316shutdown STDIN, 0;
317setsockopt STDIN, 1,2,3;
318getsockopt STDIN, 1,2;
319getsockname STDIN;
320getpeername STDIN;
599cee73 321EXPECT
43693395 322send() on closed socket STDIN at - line 22.
323bind() on closed socket STDIN at - line 23.
324connect() on closed socket STDIN at - line 24.
325listen() on closed socket STDIN at - line 25.
326accept() on closed socket STDIN at - line 26.
327shutdown() on closed socket STDIN at - line 27.
328setsockopt() on closed socket STDIN at - line 28.
329getsockopt() on closed socket STDIN at - line 29.
330getsockname() on closed socket STDIN at - line 30.
331getpeername() on closed socket STDIN at - line 31.
332send() on closed socket STDIN at - line 33.
333 (Are you trying to call send() on dirhandle STDIN?)
334bind() on closed socket STDIN at - line 34.
335 (Are you trying to call bind() on dirhandle STDIN?)
336connect() on closed socket STDIN at - line 35.
337 (Are you trying to call connect() on dirhandle STDIN?)
338listen() on closed socket STDIN at - line 36.
339 (Are you trying to call listen() on dirhandle STDIN?)
340accept() on closed socket STDIN at - line 37.
341 (Are you trying to call accept() on dirhandle STDIN?)
342shutdown() on closed socket STDIN at - line 38.
343 (Are you trying to call shutdown() on dirhandle STDIN?)
344setsockopt() on closed socket STDIN at - line 39.
345 (Are you trying to call setsockopt() on dirhandle STDIN?)
346getsockopt() on closed socket STDIN at - line 40.
347 (Are you trying to call getsockopt() on dirhandle STDIN?)
348getsockname() on closed socket STDIN at - line 41.
349 (Are you trying to call getsockname() on dirhandle STDIN?)
350getpeername() on closed socket STDIN at - line 42.
351 (Are you trying to call getpeername() on dirhandle STDIN?)
599cee73 352########
767a6a26 353# pp_sys.c [pp_stat]
4438c4b7 354use warnings 'newline' ;
599cee73 355stat "abc\ndef";
4438c4b7 356no warnings 'newline' ;
0453d815 357stat "abc\ndef";
599cee73 358EXPECT
359Unsuccessful stat on filename containing newline at - line 3.
360########
767a6a26 361# pp_sys.c [pp_fttext]
2dd78f96 362use warnings qw(unopened closed) ;
599cee73 363close STDIN ;
364-T STDIN ;
9ddeeac9 365stat(STDIN) ;
2dd78f96 366-T HOCUS;
367stat(POCUS);
368no warnings qw(unopened closed) ;
0453d815 369-T STDIN ;
9ddeeac9 370stat(STDIN);
2dd78f96 371-T HOCUS;
372stat(POCUS);
599cee73 373EXPECT
2dd78f96 374-T on closed filehandle STDIN at - line 4.
375stat() on closed filehandle STDIN at - line 5.
376-T on unopened filehandle HOCUS at - line 6.
377stat() on unopened filehandle POCUS at - line 7.
599cee73 378########
767a6a26 379# pp_sys.c [pp_fttext]
4438c4b7 380use warnings 'newline' ;
599cee73 381-T "abc\ndef" ;
4438c4b7 382no warnings 'newline' ;
0453d815 383-T "abc\ndef" ;
599cee73 384EXPECT
385Unsuccessful open on filename containing newline at - line 3.
767a6a26 386########
387# pp_sys.c [pp_sysread]
388use warnings 'io' ;
6bbf1b34 389if ($^O eq 'dos') {
390 print <<EOM ;
391SKIPPED
392# skipped on dos
393EOM
394 exit ;
395}
767a6a26 396my $file = "./xcv" ;
397open(F, ">$file") ;
398my $a = sysread(F, $a,10) ;
399no warnings 'io' ;
400my $a = sysread(F, $a,10) ;
401close F ;
b5fe5ca2 402use warnings 'io' ;
403sysread(F, $a, 10);
404read(F, $a, 10);
405sysread(NONEXISTENT, $a, 10);
406read(NONEXISTENT, $a, 10);
767a6a26 407unlink $file ;
408EXPECT
c6f2523f 409Filehandle F opened only for output at - line 12.
b5fe5ca2 410sysread() on closed filehandle F at - line 17.
411read() on closed filehandle F at - line 18.
412sysread() on unopened filehandle NONEXISTENT at - line 19.
413read() on unopened filehandle NONEXISTENT at - line 20.
c289d2f7 414########
415# pp_sys.c [pp_binmode]
416use warnings 'unopened' ;
417binmode(BLARG);
418$a = "BLERG";binmode($a);
419EXPECT
420binmode() on unopened filehandle BLARG at - line 3.
421binmode() on unopened filehandle at - line 4.
5d3e98de 422########
423# pp_sys.c [pp_lstat]
424use warnings 'io';
365c80fa 425open FH, "harness" or die "# $!";
426lstat FH;
5d3e98de 427open my $fh, $0 or die "# $!";
428lstat $fh;
429no warnings 'io';
365c80fa 430lstat FH;
5d3e98de 431lstat $fh;
365c80fa 432close FH;
5d3e98de 433close $fh;
434EXPECT
365c80fa 435lstat() on filehandle FH at - line 4.
436lstat() on filehandle $fh at - line 6.
90133b69 437########
438# pp_sys.c [pp_getc]
439use warnings qw(unopened closed) ;
440getc FOO;
441close STDIN;
442getc STDIN;
97e322ff 443# Create an empty file
444$file = 'getcwarn.tmp';
445open FH1, ">$file" or die "# $!"; close FH1;
446open FH2, $file or die "# $!";
447getc FH2; # Should not warn at EOF
448close FH2;
449getc FH2; # Warns, now
450unlink $file;
90133b69 451no warnings qw(unopened closed) ;
452getc FOO;
453getc STDIN;
97e322ff 454getc FH2;
90133b69 455EXPECT
456getc() on unopened filehandle FOO at - line 3.
457getc() on closed filehandle STDIN at - line 5.
97e322ff 458getc() on closed filehandle FH2 at - line 12.
4ef2275c 459########
460# pp_sys.c [pp_sselect]
461use warnings 'misc';
462$x = 1;
ce712ebb 463select $x, undef, undef, 1;
4ef2275c 464no warnings 'misc';
ce712ebb 465select $x, undef, undef, 1;
4ef2275c 466EXPECT
467Non-string passed as bitmask at - line 4.
4dc171f0 468########
8aee01e7 469use Config;
470BEGIN {
471 if (!$Config{d_fchdir}) {
472 print <<EOM;
473SKIPPED
474# fchdir not present
475EOM
476 exit;
477 }
478}
4dc171f0 479opendir FOO, '.'; closedir FOO;
480open BAR, '.'; close BAR;
481opendir $dh, '.'; closedir $dh;
482open $fh, '.'; close $fh;
483chdir FOO;
484chdir BAR;
485chdir $dh;
486chdir $fh;
487use warnings qw(unopened closed) ;
488chdir FOO;
489chdir BAR;
490chdir $dh;
491chdir $fh;
492EXPECT
8aee01e7 493chdir() on unopened filehandle FOO at - line 20.
494chdir() on closed filehandle BAR at - line 21.
495chdir() on unopened filehandle $dh at - line 22.
496chdir() on closed filehandle $fh at - line 23.
abc718f2 497########
498# pp_sys.c [pp_open]
499use warnings;
500opendir FOO, ".";
501opendir my $foo, ".";
502open FOO, "TEST";
503open $foo, "TEST";
504no warnings qw(io deprecated);
505open FOO, "TEST";
506open $foo, "TEST";
507EXPECT
508Opening dirhandle FOO also as a file at - line 5.
509Opening dirhandle $foo also as a file at - line 6.
510########
511# pp_sys.c [pp_open_dir]
512use warnings;
513open FOO, "TEST";
514open my $foo, "TEST";
515opendir FOO, ".";
516opendir $foo, ".";
517no warnings qw(io deprecated);
518opendir FOO, ".";
519opendir $foo, ".";
520EXPECT
521Opening filehandle FOO also as a directory at - line 5.
522Opening filehandle $foo also as a directory at - line 6.