More accurate line numbers in messages
[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
5e1c7ca2 86 The stat preceding lstat() wasn't an lstat %s [pp_stat]
9d837945 87 lstat(STDIN);
88
767a6a26 89 warn(warn_nl, "stat"); [pp_stat]
599cee73 90
2dd78f96 91 -T on closed filehandle %s
92 stat() on closed filehandle %s
93 close STDIN ; -T STDIN ; stat(STDIN) ;
599cee73 94
767a6a26 95 warn(warn_nl, "open"); [pp_fttext]
599cee73 96 -T "abc\ndef" ;
97
767a6a26 98 Filehandle %s opened only for output [pp_sysread]
99 my $file = "./xcv" ;
100 open(F, ">$file") ;
101 my $a = sysread(F, $a,10) ;
102
599cee73 103
104
105__END__
767a6a26 106# pp_sys.c [pp_untie]
4438c4b7 107use warnings 'untie' ;
599cee73 108sub TIESCALAR { bless [] } ;
109$b = tie $a, 'main';
110untie $a ;
4438c4b7 111no warnings 'untie' ;
0453d815 112$c = tie $d, 'main';
113untie $d ;
599cee73 114EXPECT
115untie attempted while 1 inner references still exist at - line 5.
116########
767a6a26 117# pp_sys.c [pp_leavewrite]
4438c4b7 118use warnings 'io' ;
599cee73 119format STDIN =
120.
121write STDIN;
4438c4b7 122no warnings 'io' ;
0453d815 123write STDIN;
599cee73 124EXPECT
43693395 125Filehandle STDIN opened only for input at - line 5.
599cee73 126########
767a6a26 127# pp_sys.c [pp_leavewrite]
4438c4b7 128use warnings 'closed' ;
599cee73 129format STDIN =
130.
131close STDIN;
132write STDIN;
69282e91 133opendir STDIN, ".";
134write STDIN;
135closedir STDIN;
4438c4b7 136no warnings 'closed' ;
0453d815 137write STDIN;
69282e91 138opendir STDIN, ".";
139write STDIN;
599cee73 140EXPECT
43693395 141write() on closed filehandle STDIN at - line 6.
142write() on closed filehandle STDIN at - line 8.
143 (Are you trying to call write() on dirhandle STDIN?)
599cee73 144########
767a6a26 145# pp_sys.c [pp_leavewrite]
4438c4b7 146use warnings 'io' ;
599cee73 147format STDOUT_TOP =
148abc
149.
150format STDOUT =
151def
152ghi
153.
154$= = 1 ;
155$- =1 ;
3eeba6fb 156open STDOUT, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
599cee73 157write ;
4438c4b7 158no warnings 'io' ;
0453d815 159write ;
599cee73 160EXPECT
161page overflow at - line 13.
162########
767a6a26 163# pp_sys.c [pp_prtf]
4438c4b7 164use warnings 'unopened' ;
599cee73 165$a = "abc";
0453d815 166printf $a "fred";
4438c4b7 167no warnings 'unopened' ;
0453d815 168printf $a "fred";
599cee73 169EXPECT
2dd78f96 170printf() on unopened filehandle abc at - line 4.
599cee73 171########
767a6a26 172# pp_sys.c [pp_prtf]
4438c4b7 173use warnings 'closed' ;
599cee73 174close STDIN ;
0453d815 175printf STDIN "fred";
69282e91 176opendir STDIN, ".";
177printf STDIN "fred";
178closedir STDIN;
4438c4b7 179no warnings 'closed' ;
0453d815 180printf STDIN "fred";
69282e91 181opendir STDIN, ".";
182printf STDIN "fred";
599cee73 183EXPECT
43693395 184printf() on closed filehandle STDIN at - line 4.
185printf() on closed filehandle STDIN at - line 6.
186 (Are you trying to call printf() on dirhandle STDIN?)
599cee73 187########
767a6a26 188# pp_sys.c [pp_prtf]
4438c4b7 189use warnings 'io' ;
0453d815 190printf STDIN "fred";
4438c4b7 191no warnings 'io' ;
0453d815 192printf STDIN "fred";
599cee73 193EXPECT
43693395 194Filehandle STDIN opened only for input at - line 3.
599cee73 195########
767a6a26 196# pp_sys.c [pp_send]
4438c4b7 197use warnings 'closed' ;
599cee73 198close STDIN;
199syswrite STDIN, "fred", 1;
69282e91 200opendir STDIN, ".";
201syswrite STDIN, "fred", 1;
202closedir STDIN;
4438c4b7 203no warnings 'closed' ;
0453d815 204syswrite STDIN, "fred", 1;
69282e91 205opendir STDIN, ".";
206syswrite STDIN, "fred", 1;
599cee73 207EXPECT
43693395 208syswrite() on closed filehandle STDIN at - line 4.
209syswrite() on closed filehandle STDIN at - line 6.
210 (Are you trying to call syswrite() on dirhandle STDIN?)
69282e91 211########
212# pp_sys.c [pp_flock]
f0963acb 213use Config;
214BEGIN {
9bdf8ebc 215 if ( !$Config{d_flock} &&
216 !$Config{d_fcntl_can_lock} &&
217 !$Config{d_lockf} ) {
f0963acb 218 print <<EOM ;
219SKIPPED
220# flock not present
221EOM
222 exit ;
223 }
224}
bc37a18f 225use warnings qw(unopened closed);
69282e91 226close STDIN;
227flock STDIN, 8;
228opendir STDIN, ".";
229flock STDIN, 8;
bc37a18f 230flock FOO, 8;
231flock $a, 8;
232no warnings qw(unopened closed);
69282e91 233flock STDIN, 8;
234opendir STDIN, ".";
235flock STDIN, 8;
bc37a18f 236flock FOO, 8;
237flock $a, 8;
69282e91 238EXPECT
43693395 239flock() on closed filehandle STDIN at - line 16.
c934501c 240flock() on closed filehandle STDIN at - line 18.
43693395 241 (Are you trying to call flock() on dirhandle STDIN?)
c934501c 242flock() on unopened filehandle FOO at - line 19.
243flock() on unopened filehandle at - line 20.
599cee73 244########
767a6a26 245# pp_sys.c [pp_prtf pp_send pp_bind pp_connect pp_listen pp_accept pp_shutdown pp_ssockopt ppp_getpeername]
4438c4b7 246use warnings 'io' ;
599cee73 247use Config;
248BEGIN {
249 if ( $^O ne 'VMS' and ! $Config{d_socket}) {
250 print <<EOM ;
251SKIPPED
252# send not present
253# bind not present
254# connect not present
255# accept not present
256# shutdown not present
257# setsockopt not present
258# getsockopt not present
259# getsockname not present
260# getpeername not present
261EOM
262 exit ;
263 }
264}
265close STDIN;
266send STDIN, "fred", 1;
267bind STDIN, "fred" ;
268connect STDIN, "fred" ;
269listen STDIN, 2;
69282e91 270accept "fred", STDIN;
271shutdown STDIN, 0;
272setsockopt STDIN, 1,2,3;
273getsockopt STDIN, 1,2;
274getsockname STDIN;
275getpeername STDIN;
276opendir STDIN, ".";
277send STDIN, "fred", 1;
278bind STDIN, "fred" ;
279connect STDIN, "fred" ;
280listen STDIN, 2;
281accept "fred", STDIN;
599cee73 282shutdown STDIN, 0;
283setsockopt STDIN, 1,2,3;
284getsockopt STDIN, 1,2;
285getsockname STDIN;
286getpeername STDIN;
69282e91 287closedir STDIN;
4438c4b7 288no warnings 'io' ;
0453d815 289send STDIN, "fred", 1;
290bind STDIN, "fred" ;
291connect STDIN, "fred" ;
292listen STDIN, 2;
293accept STDIN, "fred" ;
294shutdown STDIN, 0;
295setsockopt STDIN, 1,2,3;
296getsockopt STDIN, 1,2;
297getsockname STDIN;
298getpeername STDIN;
69282e91 299opendir STDIN, ".";
300send STDIN, "fred", 1;
301bind STDIN, "fred" ;
302connect STDIN, "fred" ;
303listen STDIN, 2;
304accept "fred", STDIN;
305shutdown STDIN, 0;
306setsockopt STDIN, 1,2,3;
307getsockopt STDIN, 1,2;
308getsockname STDIN;
309getpeername STDIN;
599cee73 310EXPECT
43693395 311send() on closed socket STDIN at - line 22.
312bind() on closed socket STDIN at - line 23.
313connect() on closed socket STDIN at - line 24.
314listen() on closed socket STDIN at - line 25.
315accept() on closed socket STDIN at - line 26.
316shutdown() on closed socket STDIN at - line 27.
317setsockopt() on closed socket STDIN at - line 28.
318getsockopt() on closed socket STDIN at - line 29.
319getsockname() on closed socket STDIN at - line 30.
320getpeername() on closed socket STDIN at - line 31.
321send() on closed socket STDIN at - line 33.
322 (Are you trying to call send() on dirhandle STDIN?)
323bind() on closed socket STDIN at - line 34.
324 (Are you trying to call bind() on dirhandle STDIN?)
325connect() on closed socket STDIN at - line 35.
326 (Are you trying to call connect() on dirhandle STDIN?)
327listen() on closed socket STDIN at - line 36.
328 (Are you trying to call listen() on dirhandle STDIN?)
329accept() on closed socket STDIN at - line 37.
330 (Are you trying to call accept() on dirhandle STDIN?)
331shutdown() on closed socket STDIN at - line 38.
332 (Are you trying to call shutdown() on dirhandle STDIN?)
333setsockopt() on closed socket STDIN at - line 39.
334 (Are you trying to call setsockopt() on dirhandle STDIN?)
335getsockopt() on closed socket STDIN at - line 40.
336 (Are you trying to call getsockopt() on dirhandle STDIN?)
337getsockname() on closed socket STDIN at - line 41.
338 (Are you trying to call getsockname() on dirhandle STDIN?)
339getpeername() on closed socket STDIN at - line 42.
340 (Are you trying to call getpeername() on dirhandle STDIN?)
599cee73 341########
767a6a26 342# pp_sys.c [pp_stat]
4438c4b7 343use warnings 'newline' ;
599cee73 344stat "abc\ndef";
4438c4b7 345no warnings 'newline' ;
0453d815 346stat "abc\ndef";
599cee73 347EXPECT
348Unsuccessful stat on filename containing newline at - line 3.
349########
9d837945 350# pp_sys.c [pp_stat]
351use Config;
352BEGIN {
353 if ($^O eq 'd_lstat') {
354 print <<EOM ;
355SKIPPED
356# lstat not present
357EOM
358 exit ;
359 }
360}
361use warnings 'io' ;
362lstat(STDIN) ;
363no warnings 'io' ;
364lstat(STDIN) ;
365EXPECT
5e1c7ca2 366The stat preceding lstat() wasn't an lstat at - line 13.
9d837945 367########
767a6a26 368# pp_sys.c [pp_fttext]
2dd78f96 369use warnings qw(unopened closed) ;
599cee73 370close STDIN ;
371-T STDIN ;
9ddeeac9 372stat(STDIN) ;
2dd78f96 373-T HOCUS;
374stat(POCUS);
375no warnings qw(unopened closed) ;
0453d815 376-T STDIN ;
9ddeeac9 377stat(STDIN);
2dd78f96 378-T HOCUS;
379stat(POCUS);
599cee73 380EXPECT
2dd78f96 381-T on closed filehandle STDIN at - line 4.
382stat() on closed filehandle STDIN at - line 5.
383-T on unopened filehandle HOCUS at - line 6.
384stat() on unopened filehandle POCUS at - line 7.
599cee73 385########
767a6a26 386# pp_sys.c [pp_fttext]
4438c4b7 387use warnings 'newline' ;
599cee73 388-T "abc\ndef" ;
4438c4b7 389no warnings 'newline' ;
0453d815 390-T "abc\ndef" ;
599cee73 391EXPECT
392Unsuccessful open on filename containing newline at - line 3.
767a6a26 393########
394# pp_sys.c [pp_sysread]
395use warnings 'io' ;
6bbf1b34 396if ($^O eq 'dos') {
397 print <<EOM ;
398SKIPPED
399# skipped on dos
400EOM
401 exit ;
402}
767a6a26 403my $file = "./xcv" ;
404open(F, ">$file") ;
405my $a = sysread(F, $a,10) ;
406no warnings 'io' ;
407my $a = sysread(F, $a,10) ;
408close F ;
409unlink $file ;
410EXPECT
c6f2523f 411Filehandle F opened only for output at - line 12.
c289d2f7 412########
413# pp_sys.c [pp_binmode]
414use warnings 'unopened' ;
415binmode(BLARG);
416$a = "BLERG";binmode($a);
417EXPECT
418binmode() on unopened filehandle BLARG at - line 3.
419binmode() on unopened filehandle at - line 4.