This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
More careful detection of how well NVs and UVs mix.
[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 {
9bdf8ebc
JH
206 if ( !$Config{d_flock} &&
207 !$Config{d_fcntl_can_lock} &&
208 !$Config{d_lockf} ) {
f0963acb
GS
209 print <<EOM ;
210SKIPPED
211# flock not present
212EOM
213 exit ;
214 }
215}
bc37a18f 216use warnings qw(unopened closed);
69282e91
GS
217close STDIN;
218flock STDIN, 8;
219opendir STDIN, ".";
220flock STDIN, 8;
bc37a18f
RG
221flock FOO, 8;
222flock $a, 8;
223no warnings qw(unopened closed);
69282e91
GS
224flock STDIN, 8;
225opendir STDIN, ".";
226flock STDIN, 8;
bc37a18f
RG
227flock FOO, 8;
228flock $a, 8;
69282e91 229EXPECT
43693395
GS
230flock() on closed filehandle STDIN at - line 14.
231flock() on closed filehandle STDIN at - line 16.
232 (Are you trying to call flock() on dirhandle STDIN?)
bc37a18f
RG
233flock() on unopened filehandle FOO at - line 17.
234flock() on unopened filehandle at - line 18.
599cee73 235########
767a6a26 236# pp_sys.c [pp_prtf pp_send pp_bind pp_connect pp_listen pp_accept pp_shutdown pp_ssockopt ppp_getpeername]
4438c4b7 237use warnings 'io' ;
599cee73
PM
238use Config;
239BEGIN {
240 if ( $^O ne 'VMS' and ! $Config{d_socket}) {
241 print <<EOM ;
242SKIPPED
243# send not present
244# bind not present
245# connect not present
246# accept not present
247# shutdown not present
248# setsockopt not present
249# getsockopt not present
250# getsockname not present
251# getpeername not present
252EOM
253 exit ;
254 }
255}
256close STDIN;
257send STDIN, "fred", 1;
258bind STDIN, "fred" ;
259connect STDIN, "fred" ;
260listen STDIN, 2;
69282e91
GS
261accept "fred", STDIN;
262shutdown STDIN, 0;
263setsockopt STDIN, 1,2,3;
264getsockopt STDIN, 1,2;
265getsockname STDIN;
266getpeername STDIN;
267opendir STDIN, ".";
268send STDIN, "fred", 1;
269bind STDIN, "fred" ;
270connect STDIN, "fred" ;
271listen STDIN, 2;
272accept "fred", STDIN;
599cee73
PM
273shutdown STDIN, 0;
274setsockopt STDIN, 1,2,3;
275getsockopt STDIN, 1,2;
276getsockname STDIN;
277getpeername STDIN;
69282e91 278closedir STDIN;
4438c4b7 279no warnings 'io' ;
0453d815
PM
280send STDIN, "fred", 1;
281bind STDIN, "fred" ;
282connect STDIN, "fred" ;
283listen STDIN, 2;
284accept STDIN, "fred" ;
285shutdown STDIN, 0;
286setsockopt STDIN, 1,2,3;
287getsockopt STDIN, 1,2;
288getsockname STDIN;
289getpeername STDIN;
69282e91
GS
290opendir STDIN, ".";
291send STDIN, "fred", 1;
292bind STDIN, "fred" ;
293connect STDIN, "fred" ;
294listen STDIN, 2;
295accept "fred", STDIN;
296shutdown STDIN, 0;
297setsockopt STDIN, 1,2,3;
298getsockopt STDIN, 1,2;
299getsockname STDIN;
300getpeername STDIN;
599cee73 301EXPECT
43693395
GS
302send() on closed socket STDIN at - line 22.
303bind() on closed socket STDIN at - line 23.
304connect() on closed socket STDIN at - line 24.
305listen() on closed socket STDIN at - line 25.
306accept() on closed socket STDIN at - line 26.
307shutdown() on closed socket STDIN at - line 27.
308setsockopt() on closed socket STDIN at - line 28.
309getsockopt() on closed socket STDIN at - line 29.
310getsockname() on closed socket STDIN at - line 30.
311getpeername() on closed socket STDIN at - line 31.
312send() on closed socket STDIN at - line 33.
313 (Are you trying to call send() on dirhandle STDIN?)
314bind() on closed socket STDIN at - line 34.
315 (Are you trying to call bind() on dirhandle STDIN?)
316connect() on closed socket STDIN at - line 35.
317 (Are you trying to call connect() on dirhandle STDIN?)
318listen() on closed socket STDIN at - line 36.
319 (Are you trying to call listen() on dirhandle STDIN?)
320accept() on closed socket STDIN at - line 37.
321 (Are you trying to call accept() on dirhandle STDIN?)
322shutdown() on closed socket STDIN at - line 38.
323 (Are you trying to call shutdown() on dirhandle STDIN?)
324setsockopt() on closed socket STDIN at - line 39.
325 (Are you trying to call setsockopt() on dirhandle STDIN?)
326getsockopt() on closed socket STDIN at - line 40.
327 (Are you trying to call getsockopt() on dirhandle STDIN?)
328getsockname() on closed socket STDIN at - line 41.
329 (Are you trying to call getsockname() on dirhandle STDIN?)
330getpeername() on closed socket STDIN at - line 42.
331 (Are you trying to call getpeername() on dirhandle STDIN?)
599cee73 332########
767a6a26 333# pp_sys.c [pp_stat]
4438c4b7 334use warnings 'newline' ;
599cee73 335stat "abc\ndef";
4438c4b7 336no warnings 'newline' ;
0453d815 337stat "abc\ndef";
599cee73
PM
338EXPECT
339Unsuccessful stat on filename containing newline at - line 3.
340########
9d837945
TM
341# pp_sys.c [pp_stat]
342use Config;
343BEGIN {
344 if ($^O eq 'd_lstat') {
345 print <<EOM ;
346SKIPPED
347# lstat not present
348EOM
349 exit ;
350 }
351}
352use warnings 'io' ;
353lstat(STDIN) ;
354no warnings 'io' ;
355lstat(STDIN) ;
356EXPECT
357lstat() on filehandle STDIN at - line 13.
358########
767a6a26 359# pp_sys.c [pp_fttext]
2dd78f96 360use warnings qw(unopened closed) ;
599cee73
PM
361close STDIN ;
362-T STDIN ;
9ddeeac9 363stat(STDIN) ;
2dd78f96
JH
364-T HOCUS;
365stat(POCUS);
366no warnings qw(unopened closed) ;
0453d815 367-T STDIN ;
9ddeeac9 368stat(STDIN);
2dd78f96
JH
369-T HOCUS;
370stat(POCUS);
599cee73 371EXPECT
2dd78f96
JH
372-T on closed filehandle STDIN at - line 4.
373stat() on closed filehandle STDIN at - line 5.
374-T on unopened filehandle HOCUS at - line 6.
375stat() on unopened filehandle POCUS at - line 7.
599cee73 376########
767a6a26 377# pp_sys.c [pp_fttext]
4438c4b7 378use warnings 'newline' ;
599cee73 379-T "abc\ndef" ;
4438c4b7 380no warnings 'newline' ;
0453d815 381-T "abc\ndef" ;
599cee73
PM
382EXPECT
383Unsuccessful open on filename containing newline at - line 3.
767a6a26
PM
384########
385# pp_sys.c [pp_sysread]
386use warnings 'io' ;
6bbf1b34
LM
387if ($^O eq 'dos') {
388 print <<EOM ;
389SKIPPED
390# skipped on dos
391EOM
392 exit ;
393}
767a6a26
PM
394my $file = "./xcv" ;
395open(F, ">$file") ;
396my $a = sysread(F, $a,10) ;
397no warnings 'io' ;
398my $a = sysread(F, $a,10) ;
399close F ;
400unlink $file ;
401EXPECT
c6f2523f 402Filehandle F opened only for output at - line 12.