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