(?p{}) has been deprecated for a long time.
[p5sagit/p5-mst-13.2.git] / t / lib / warnings / 7fatal
1 Check FATAL functionality
2
3 __END__
4
5 # Check compile time warning
6 use warnings FATAL => 'syntax' ;
7 {
8     no warnings ;
9     $a =+ 1 ;
10 }
11 $a =+ 1 ;
12 print STDERR "The End.\n" ;
13 EXPECT
14 Reversed += operator at - line 8.
15 ########
16
17 # Check compile time warning
18 use warnings FATAL => 'all' ;
19 {
20     no warnings ;
21     my $a =+ 1 ;
22 }
23 my $a =+ 1 ;
24 print STDERR "The End.\n" ;
25 EXPECT
26 Reversed += operator at - line 8.
27 ########
28
29 # Check runtime scope of pragma
30 use warnings FATAL => 'uninitialized' ;
31 {
32     no warnings ;
33     my $b ; chop $b ;
34 }
35 my $b ; chop $b ;
36 print STDERR "The End.\n" ;
37 EXPECT
38 Use of uninitialized value $b in scalar chop at - line 8.
39 ########
40
41 # Check runtime scope of pragma
42 use warnings FATAL => 'all' ;
43 {
44     no warnings ;
45     my $b ; chop $b ;
46 }
47 my $b ; chop $b ;
48 print STDERR "The End.\n" ;
49 EXPECT
50 Use of uninitialized value $b in scalar chop at - line 8.
51 ########
52
53 # Check runtime scope of pragma
54 no warnings ;
55 {
56     use warnings FATAL => 'uninitialized' ;
57     $a = sub { my $b ; chop $b ; }
58 }
59 &$a ;
60 print STDERR "The End.\n" ;
61 EXPECT
62 Use of uninitialized value $b in scalar chop at - line 6.
63 ########
64
65 # Check runtime scope of pragma
66 no warnings ;
67 {
68     use warnings FATAL => 'all' ;
69     $a = sub { my $b ; chop $b ; }
70 }
71 &$a ;
72 print STDERR "The End.\n" ;
73 EXPECT
74 Use of uninitialized value $b in scalar chop at - line 6.
75 ########
76
77 --FILE-- abc
78 $a =+ 1 ;
79 1;
80 --FILE-- 
81 use warnings FATAL => 'syntax' ;
82 require "./abc";
83 EXPECT
84
85 ########
86
87 --FILE-- abc
88 use warnings FATAL => 'syntax' ;
89 1;
90 --FILE-- 
91 require "./abc";
92 $a =+ 1 ;
93 EXPECT
94
95 ########
96
97 --FILE-- abc
98 use warnings 'syntax' ;
99 $a =+ 1 ;
100 1;
101 --FILE-- 
102 use warnings FATAL => 'uninitialized' ;
103 require "./abc";
104 my $a ; chop $a ;
105 print STDERR "The End.\n" ;
106 EXPECT
107 Reversed += operator at ./abc line 2.
108 Use of uninitialized value $a in scalar chop at - line 3.
109 ########
110
111 --FILE-- abc.pm
112 use warnings 'syntax' ;
113 $a =+ 1 ;
114 1;
115 --FILE-- 
116 use warnings FATAL => 'uninitialized' ;
117 use abc;
118 my $a ; chop $a ;
119 print STDERR "The End.\n" ;
120 EXPECT
121 Reversed += operator at abc.pm line 2.
122 Use of uninitialized value $a in scalar chop at - line 3.
123 ########
124
125 # Check scope of pragma with eval
126 no warnings ;
127 eval {
128     use warnings FATAL => 'uninitialized' ;
129     my $b ; chop $b ;
130 }; print STDERR "-- $@" ;
131 my $b ; chop $b ;
132 print STDERR "The End.\n" ;
133 EXPECT
134 -- Use of uninitialized value $b in scalar chop at - line 6.
135 The End.
136 ########
137
138 # Check scope of pragma with eval
139 use warnings FATAL => 'uninitialized' ;
140 eval {
141     my $b ; chop $b ;
142 }; print STDERR "-- $@" ;
143 my $b ; chop $b ;
144 print STDERR "The End.\n" ;
145 EXPECT
146 -- Use of uninitialized value $b in scalar chop at - line 5.
147 Use of uninitialized value $b in scalar chop at - line 7.
148 ########
149
150 # Check scope of pragma with eval
151 use warnings FATAL => 'uninitialized' ;
152 eval {
153     no warnings ;
154     my $b ; chop $b ;
155 }; print STDERR $@ ;
156 my $b ; chop $b ;
157 print STDERR "The End.\n" ;
158 EXPECT
159 Use of uninitialized value $b in scalar chop at - line 8.
160 ########
161
162 # Check scope of pragma with eval
163 no warnings ;
164 eval {
165     use warnings FATAL => 'syntax' ;
166     $a =+ 1 ;
167 }; print STDERR "-- $@" ;
168 $a =+ 1 ;
169 print STDERR "The End.\n" ;
170 EXPECT
171 Reversed += operator at - line 6.
172 ########
173
174 # Check scope of pragma with eval
175 use warnings FATAL => 'syntax' ;
176 eval {
177     $a =+ 1 ;
178 }; print STDERR "-- $@" ;
179 $a =+ 1 ;
180 print STDERR "The End.\n" ;
181 EXPECT
182 Reversed += operator at - line 5.
183 ########
184
185 # Check scope of pragma with eval
186 use warnings FATAL => 'syntax' ;
187 eval {
188     no warnings ;
189     $a =+ 1 ;
190 }; print STDERR $@ ;
191 $a =+ 1 ;
192 print STDERR "The End.\n" ;
193 EXPECT
194 Reversed += operator at - line 8.
195 ########
196
197 # Check scope of pragma with eval
198 no warnings ;
199 eval {
200     use warnings FATAL => 'syntax' ;
201 }; print STDERR $@ ;
202 $a =+ 1 ;
203 print STDERR "The End.\n" ;
204 EXPECT
205 The End.
206 ########
207
208 # Check scope of pragma with eval
209 no warnings ;
210 eval q[ 
211     use warnings FATAL => 'uninitialized' ;
212     my $b ; chop $b ;
213 ]; print STDERR "-- $@";
214 my $b ; chop $b ;
215 print STDERR "The End.\n" ;
216 EXPECT
217 -- Use of uninitialized value $b in scalar chop at (eval 1) line 3.
218 The End.
219 ########
220
221 # Check scope of pragma with eval
222 use warnings FATAL => 'uninitialized' ;
223 eval '
224     my $b ; chop $b ;
225 '; print STDERR "-- $@" ;
226 my $b ; chop $b ;
227 print STDERR "The End.\n" ;
228 EXPECT
229 -- Use of uninitialized value $b in scalar chop at (eval 1) line 2.
230 Use of uninitialized value $b in scalar chop at - line 7.
231 ########
232
233 # Check scope of pragma with eval
234 use warnings FATAL => 'uninitialized' ;
235 eval '
236     no warnings ;
237     my $b ; chop $b ;
238 '; print STDERR $@ ;
239 my $b ; chop $b ;
240 print STDERR "The End.\n" ;
241 EXPECT
242 Use of uninitialized value $b in scalar chop at - line 8.
243 ########
244
245 # Check scope of pragma with eval
246 no warnings ;
247 eval q[ 
248     use warnings FATAL => 'syntax' ;
249     $a =+ 1 ;
250 ]; print STDERR "-- $@";
251 $a =+ 1 ;
252 print STDERR "The End.\n" ;
253 EXPECT
254 -- Reversed += operator at (eval 1) line 3.
255 The End.
256 ########
257
258 # Check scope of pragma with eval
259 use warnings FATAL => 'syntax' ;
260 eval '
261     $a =+ 1 ;
262 '; print STDERR "-- $@";
263 print STDERR "The End.\n" ;
264 EXPECT
265 -- Reversed += operator at (eval 1) line 2.
266 The End.
267 ########
268
269 # Check scope of pragma with eval
270 use warnings FATAL => 'syntax' ;
271 eval '
272     no warnings ;
273     $a =+ 1 ;
274 '; print STDERR "-- $@";
275 $a =+ 1 ;
276 print STDERR "The End.\n" ;
277 EXPECT
278 Reversed += operator at - line 8.
279 ########
280 # TODO ? !$Config{usethreads} && $::UTF8 && ($ENV{PERL_DESTRUCT_LEVEL} || 0) > 1 ? "Parser leaks OPs, which leak shared hash keys" : ''
281
282 use warnings 'void' ;
283
284 time ;
285
286 {
287     use warnings FATAL => qw(void) ;
288     length "abc" ;
289 }
290
291 join "", 1,2,3 ;
292
293 print "done\n" ;
294 EXPECT
295 Useless use of time in void context at - line 4.
296 Useless use of length in void context at - line 8.
297 ########
298 # TODO ? !$Config{usethreads} && $::UTF8 && ($ENV{PERL_DESTRUCT_LEVEL} || 0) > 1 ? "Parser leaks OPs, which leak shared hash keys" : ''
299
300 use warnings ;
301
302 time ;
303
304 {
305     use warnings FATAL => qw(void) ;
306     length "abc" ;
307 }
308
309 join "", 1,2,3 ;
310
311 print "done\n" ;
312 EXPECT
313 Useless use of time in void context at - line 4.
314 Useless use of length in void context at - line 8.
315 ########
316
317 use warnings FATAL => 'all';
318 {
319     no warnings;
320     my $b ; chop $b;
321     {
322         use warnings ;
323         my $b ; chop $b;
324     }
325 }
326 my $b ; chop $b;
327 print STDERR "The End.\n" ;
328 EXPECT
329 Use of uninitialized value $b in scalar chop at - line 8.
330 Use of uninitialized value $b in scalar chop at - line 11.
331 ########
332
333 use warnings FATAL => 'all';
334 {
335     no warnings FATAL => 'all';
336     my $b ; chop $b;
337     {
338         use warnings ;
339         my $b ; chop $b;
340     }
341 }
342 my $b ; chop $b;
343 print STDERR "The End.\n" ;
344 EXPECT
345 Use of uninitialized value $b in scalar chop at - line 8.
346 Use of uninitialized value $b in scalar chop at - line 11.
347 ########
348
349 use warnings FATAL => 'all';
350 {
351     no warnings 'syntax';
352     {
353         use warnings ;
354         my $b ; chop $b;
355     }
356 }
357 my $b ; chop $b;
358 print STDERR "The End.\n" ;
359 EXPECT
360 Use of uninitialized value $b in scalar chop at - line 7.
361 ########
362
363 use warnings FATAL => 'syntax', NONFATAL => 'void' ;
364
365 length "abc";
366 print STDERR "The End.\n" ;
367 EXPECT
368 Useless use of length in void context at - line 4.
369 The End.
370 ########
371
372 use warnings FATAL => 'all', NONFATAL => 'void' ;
373
374 length "abc";
375 print STDERR "The End.\n" ;
376 EXPECT
377 Useless use of length in void context at - line 4.
378 The End.
379 ########
380
381 use warnings FATAL => 'all', NONFATAL => 'void' ;
382
383 my $a ; chomp $a;
384 length "abc";
385 print STDERR "The End.\n" ;
386 EXPECT
387 Useless use of length in void context at - line 5.
388 Use of uninitialized value $a in scalar chomp at - line 4.
389 ########
390
391 use warnings FATAL => 'void', NONFATAL => 'void' ;
392
393 length "abc";
394 print STDERR "The End.\n" ;
395 EXPECT
396 Useless use of length in void context at - line 4.
397 The End.
398 ########
399 # TODO ? !$Config{usethreads} && $::UTF8 && ($ENV{PERL_DESTRUCT_LEVEL} || 0) > 1 ? "Parser leaks OPs, which leak shared hash keys" : ''
400
401 use warnings NONFATAL => 'void', FATAL => 'void' ;
402
403 length "abc";
404 print STDERR "The End.\n" ;
405 EXPECT
406 Useless use of length in void context at - line 4.
407 ########
408
409 use warnings FATAL => 'all', NONFATAL => 'io';
410 no warnings 'once';
411
412 open(F, "<true\ncd");
413 close "fred" ;
414 print STDERR "The End.\n" ;
415 EXPECT
416 Unsuccessful open on filename containing newline at - line 5.
417 close() on unopened filehandle fred at - line 6.
418 The End.
419 ########
420
421 use warnings FATAL => 'all', NONFATAL => 'io', FATAL => 'unopened' ;
422 no warnings 'once';
423
424 open(F, "<true\ncd");
425 close "fred" ;
426 print STDERR "The End.\n" ;
427 EXPECT
428 Unsuccessful open on filename containing newline at - line 5.
429 close() on unopened filehandle fred at - line 6.