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