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