Another patch for Lexical Warnings
[p5sagit/p5-mst-13.2.git] / t / pragma / warn / 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
767a6a26 6 Filehandle %s opened only for input [pp_leavewrite]
599cee73 7 format STDIN =
8 .
9 write STDIN;
10
767a6a26 11 Write on closed filehandle %s [pp_leavewrite]
599cee73 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 20 $a = "abc"; printf $a "fred"
21
767a6a26 22 Filehandle %s opened only for input [pp_prtf]
599cee73 23 $a = "abc";
24 printf $a "fred"
25
767a6a26 26 printf on closed filehandle %s [pp_prtf]
599cee73 27 close STDIN ;
28 printf STDIN "fred"
29
767a6a26 30 Syswrite on closed filehandle [pp_send]
599cee73 31 close STDIN;
32 syswrite STDIN, "fred", 1;
33
767a6a26 34 Send on closed socket [pp_send]
599cee73 35 close STDIN;
36 send STDIN, "fred", 1
37
767a6a26 38 bind() on closed fd [pp_bind]
599cee73 39 close STDIN;
40 bind STDIN, "fred" ;
41
42
767a6a26 43 connect() on closed fd [pp_connect]
599cee73 44 close STDIN;
45 connect STDIN, "fred" ;
46
767a6a26 47 listen() on closed fd [pp_listen]
599cee73 48 close STDIN;
49 listen STDIN, 2;
50
767a6a26 51 accept() on closed fd [pp_accept]
599cee73 52 close STDIN;
53 accept STDIN, "fred" ;
54
767a6a26 55 shutdown() on closed fd [pp_shutdown]
599cee73 56 close STDIN;
57 shutdown STDIN, 0;
58
767a6a26 59 [gs]etsockopt() on closed fd [pp_ssockopt]
599cee73 60 close STDIN;
61 setsockopt STDIN, 1,2,3;
62 getsockopt STDIN, 1,2;
63
767a6a26 64 get{sock, peer}name() on closed fd [pp_getpeername]
599cee73 65 close STDIN;
66 getsockname STDIN;
67 getpeername STDIN;
68
767a6a26 69 warn(warn_nl, "stat"); [pp_stat]
599cee73 70
71 Test on unopened file <%s>
72 close STDIN ; -T STDIN ;
73
767a6a26 74 warn(warn_nl, "open"); [pp_fttext]
599cee73 75 -T "abc\ndef" ;
76
767a6a26 77 Filehandle %s opened only for output [pp_sysread]
78 my $file = "./xcv" ;
79 open(F, ">$file") ;
80 my $a = sysread(F, $a,10) ;
81
599cee73 82
83
84__END__
767a6a26 85# pp_sys.c [pp_untie]
4438c4b7 86use warnings 'untie' ;
599cee73 87sub TIESCALAR { bless [] } ;
88$b = tie $a, 'main';
89untie $a ;
4438c4b7 90no warnings 'untie' ;
0453d815 91$c = tie $d, 'main';
92untie $d ;
599cee73 93EXPECT
94untie attempted while 1 inner references still exist at - line 5.
95########
767a6a26 96# pp_sys.c [pp_leavewrite]
4438c4b7 97use warnings 'io' ;
599cee73 98format STDIN =
99.
100write STDIN;
4438c4b7 101no warnings 'io' ;
0453d815 102write STDIN;
599cee73 103EXPECT
af8c498a 104Filehandle main::STDIN opened only for input at - line 5.
599cee73 105########
767a6a26 106# pp_sys.c [pp_leavewrite]
4438c4b7 107use warnings 'closed' ;
599cee73 108format STDIN =
109.
110close STDIN;
111write STDIN;
4438c4b7 112no warnings 'closed' ;
0453d815 113write STDIN;
599cee73 114EXPECT
af8c498a 115Write on closed filehandle main::STDIN at - line 6.
599cee73 116########
767a6a26 117# pp_sys.c [pp_leavewrite]
4438c4b7 118use warnings 'io' ;
599cee73 119format STDOUT_TOP =
120abc
121.
122format STDOUT =
123def
124ghi
125.
126$= = 1 ;
127$- =1 ;
3eeba6fb 128open STDOUT, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
599cee73 129write ;
4438c4b7 130no warnings 'io' ;
0453d815 131write ;
599cee73 132EXPECT
133page overflow at - line 13.
134########
767a6a26 135# pp_sys.c [pp_prtf]
4438c4b7 136use warnings 'unopened' ;
599cee73 137$a = "abc";
0453d815 138printf $a "fred";
4438c4b7 139no warnings 'unopened' ;
0453d815 140printf $a "fred";
599cee73 141EXPECT
142Filehandle main::abc never opened at - line 4.
143########
767a6a26 144# pp_sys.c [pp_prtf]
4438c4b7 145use warnings 'closed' ;
599cee73 146close STDIN ;
0453d815 147printf STDIN "fred";
4438c4b7 148no warnings 'closed' ;
0453d815 149printf STDIN "fred";
599cee73 150EXPECT
151printf on closed filehandle main::STDIN at - line 4.
152########
767a6a26 153# pp_sys.c [pp_prtf]
4438c4b7 154use warnings 'io' ;
0453d815 155printf STDIN "fred";
4438c4b7 156no warnings 'io' ;
0453d815 157printf STDIN "fred";
599cee73 158EXPECT
159Filehandle main::STDIN opened only for input at - line 3.
160########
767a6a26 161# pp_sys.c [pp_send]
4438c4b7 162use warnings 'closed' ;
599cee73 163close STDIN;
164syswrite STDIN, "fred", 1;
4438c4b7 165no warnings 'closed' ;
0453d815 166syswrite STDIN, "fred", 1;
599cee73 167EXPECT
168Syswrite on closed filehandle at - line 4.
169########
767a6a26 170# pp_sys.c [pp_prtf pp_send pp_bind pp_connect pp_listen pp_accept pp_shutdown pp_ssockopt ppp_getpeername]
4438c4b7 171use warnings 'io' ;
599cee73 172use Config;
173BEGIN {
174 if ( $^O ne 'VMS' and ! $Config{d_socket}) {
175 print <<EOM ;
176SKIPPED
177# send not present
178# bind not present
179# connect not present
180# accept not present
181# shutdown not present
182# setsockopt not present
183# getsockopt not present
184# getsockname not present
185# getpeername not present
186EOM
187 exit ;
188 }
189}
190close STDIN;
191send STDIN, "fred", 1;
192bind STDIN, "fred" ;
193connect STDIN, "fred" ;
194listen STDIN, 2;
195accept STDIN, "fred" ;
196shutdown STDIN, 0;
197setsockopt STDIN, 1,2,3;
198getsockopt STDIN, 1,2;
199getsockname STDIN;
200getpeername STDIN;
4438c4b7 201no warnings 'io' ;
0453d815 202send STDIN, "fred", 1;
203bind STDIN, "fred" ;
204connect STDIN, "fred" ;
205listen STDIN, 2;
206accept STDIN, "fred" ;
207shutdown STDIN, 0;
208setsockopt STDIN, 1,2,3;
209getsockopt STDIN, 1,2;
210getsockname STDIN;
211getpeername STDIN;
599cee73 212EXPECT
213Send on closed socket at - line 22.
214bind() on closed fd at - line 23.
215connect() on closed fd at - line 24.
216listen() on closed fd at - line 25.
217accept() on closed fd at - line 26.
218shutdown() on closed fd at - line 27.
219[gs]etsockopt() on closed fd at - line 28.
220[gs]etsockopt() on closed fd at - line 29.
221get{sock, peer}name() on closed fd at - line 30.
222get{sock, peer}name() on closed fd at - line 31.
223########
767a6a26 224# pp_sys.c [pp_stat]
4438c4b7 225use warnings 'newline' ;
599cee73 226stat "abc\ndef";
4438c4b7 227no warnings 'newline' ;
0453d815 228stat "abc\ndef";
599cee73 229EXPECT
230Unsuccessful stat on filename containing newline at - line 3.
231########
767a6a26 232# pp_sys.c [pp_fttext]
4438c4b7 233use warnings 'unopened' ;
599cee73 234close STDIN ;
235-T STDIN ;
4438c4b7 236no warnings 'unopened' ;
0453d815 237-T STDIN ;
599cee73 238EXPECT
239Test on unopened file <STDIN> at - line 4.
240########
767a6a26 241# pp_sys.c [pp_fttext]
4438c4b7 242use warnings 'newline' ;
599cee73 243-T "abc\ndef" ;
4438c4b7 244no warnings 'newline' ;
0453d815 245-T "abc\ndef" ;
599cee73 246EXPECT
247Unsuccessful open on filename containing newline at - line 3.
767a6a26 248########
249# pp_sys.c [pp_sysread]
250use warnings 'io' ;
251my $file = "./xcv" ;
252open(F, ">$file") ;
253my $a = sysread(F, $a,10) ;
254no warnings 'io' ;
255my $a = sysread(F, $a,10) ;
256close F ;
257unlink $file ;
258EXPECT
259Filehandle main::F opened only for output at - line 5.