Commit | Line | Data |
---|---|---|
4438c4b7 JH |
1 | Check FATAL functionality |
2 | ||
3 | __END__ | |
4 | ||
5 | # Check compile time warning | |
551cd33c | 6 | use warnings FATAL => 'syntax' ; |
4438c4b7 JH |
7 | { |
8 | no warnings ; | |
551cd33c | 9 | $a =+ 1 ; |
4438c4b7 | 10 | } |
551cd33c | 11 | $a =+ 1 ; |
4438c4b7 JH |
12 | print STDERR "The End.\n" ; |
13 | EXPECT | |
551cd33c | 14 | Reversed += operator at - line 8. |
4438c4b7 JH |
15 | ######## |
16 | ||
d5a71f30 GS |
17 | # Check compile time warning |
18 | use warnings FATAL => 'all' ; | |
19 | { | |
20 | no warnings ; | |
551cd33c | 21 | my $a =+ 1 ; |
d5a71f30 | 22 | } |
551cd33c | 23 | my $a =+ 1 ; |
d5a71f30 GS |
24 | print STDERR "The End.\n" ; |
25 | EXPECT | |
551cd33c | 26 | Reversed += operator at - line 8. |
d5a71f30 GS |
27 | ######## |
28 | ||
4438c4b7 JH |
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 | |
29489e7c | 38 | Use of uninitialized value $b in scalar chop at - line 8. |
4438c4b7 JH |
39 | ######## |
40 | ||
41 | # Check runtime scope of pragma | |
d5a71f30 GS |
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 | |
29489e7c | 50 | Use of uninitialized value $b in scalar chop at - line 8. |
d5a71f30 GS |
51 | ######## |
52 | ||
53 | # Check runtime scope of pragma | |
4438c4b7 JH |
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 | |
29489e7c | 62 | Use of uninitialized value $b in scalar chop at - line 6. |
4438c4b7 | 63 | ######## |
d5a71f30 GS |
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 | |
29489e7c | 74 | Use of uninitialized value $b in scalar chop at - line 6. |
d5a71f30 | 75 | ######## |
4438c4b7 JH |
76 | |
77 | --FILE-- abc | |
551cd33c | 78 | $a =+ 1 ; |
4438c4b7 JH |
79 | 1; |
80 | --FILE-- | |
551cd33c | 81 | use warnings FATAL => 'syntax' ; |
4438c4b7 JH |
82 | require "./abc"; |
83 | EXPECT | |
84 | ||
85 | ######## | |
86 | ||
87 | --FILE-- abc | |
551cd33c | 88 | use warnings FATAL => 'syntax' ; |
4438c4b7 JH |
89 | 1; |
90 | --FILE-- | |
91 | require "./abc"; | |
551cd33c | 92 | $a =+ 1 ; |
4438c4b7 JH |
93 | EXPECT |
94 | ||
95 | ######## | |
96 | ||
97 | --FILE-- abc | |
551cd33c JH |
98 | use warnings 'syntax' ; |
99 | $a =+ 1 ; | |
4438c4b7 JH |
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 | |
551cd33c | 107 | Reversed += operator at ./abc line 2. |
29489e7c | 108 | Use of uninitialized value $a in scalar chop at - line 3. |
4438c4b7 JH |
109 | ######## |
110 | ||
111 | --FILE-- abc.pm | |
551cd33c JH |
112 | use warnings 'syntax' ; |
113 | $a =+ 1 ; | |
4438c4b7 JH |
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 | |
551cd33c | 121 | Reversed += operator at abc.pm line 2. |
29489e7c | 122 | Use of uninitialized value $a in scalar chop at - line 3. |
4438c4b7 JH |
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 | |
29489e7c | 134 | -- Use of uninitialized value $b in scalar chop at - line 6. |
4438c4b7 JH |
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 | |
29489e7c DM |
146 | -- Use of uninitialized value $b in scalar chop at - line 5. |
147 | Use of uninitialized value $b in scalar chop at - line 7. | |
4438c4b7 JH |
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 | |
29489e7c | 159 | Use of uninitialized value $b in scalar chop at - line 8. |
4438c4b7 JH |
160 | ######## |
161 | ||
162 | # Check scope of pragma with eval | |
163 | no warnings ; | |
164 | eval { | |
551cd33c JH |
165 | use warnings FATAL => 'syntax' ; |
166 | $a =+ 1 ; | |
4438c4b7 | 167 | }; print STDERR "-- $@" ; |
551cd33c | 168 | $a =+ 1 ; |
4438c4b7 JH |
169 | print STDERR "The End.\n" ; |
170 | EXPECT | |
551cd33c | 171 | Reversed += operator at - line 6. |
4438c4b7 JH |
172 | ######## |
173 | ||
174 | # Check scope of pragma with eval | |
551cd33c | 175 | use warnings FATAL => 'syntax' ; |
4438c4b7 | 176 | eval { |
551cd33c | 177 | $a =+ 1 ; |
4438c4b7 | 178 | }; print STDERR "-- $@" ; |
551cd33c | 179 | $a =+ 1 ; |
4438c4b7 JH |
180 | print STDERR "The End.\n" ; |
181 | EXPECT | |
551cd33c | 182 | Reversed += operator at - line 5. |
4438c4b7 JH |
183 | ######## |
184 | ||
185 | # Check scope of pragma with eval | |
551cd33c | 186 | use warnings FATAL => 'syntax' ; |
4438c4b7 JH |
187 | eval { |
188 | no warnings ; | |
551cd33c | 189 | $a =+ 1 ; |
4438c4b7 | 190 | }; print STDERR $@ ; |
551cd33c | 191 | $a =+ 1 ; |
4438c4b7 JH |
192 | print STDERR "The End.\n" ; |
193 | EXPECT | |
551cd33c | 194 | Reversed += operator at - line 8. |
4438c4b7 JH |
195 | ######## |
196 | ||
197 | # Check scope of pragma with eval | |
198 | no warnings ; | |
199 | eval { | |
551cd33c | 200 | use warnings FATAL => 'syntax' ; |
4438c4b7 | 201 | }; print STDERR $@ ; |
551cd33c | 202 | $a =+ 1 ; |
4438c4b7 JH |
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 | |
29489e7c | 217 | -- Use of uninitialized value $b in scalar chop at (eval 1) line 3. |
4438c4b7 JH |
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 | |
29489e7c DM |
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. | |
4438c4b7 JH |
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 | |
29489e7c | 242 | Use of uninitialized value $b in scalar chop at - line 8. |
4438c4b7 JH |
243 | ######## |
244 | ||
245 | # Check scope of pragma with eval | |
246 | no warnings ; | |
247 | eval q[ | |
551cd33c JH |
248 | use warnings FATAL => 'syntax' ; |
249 | $a =+ 1 ; | |
4438c4b7 | 250 | ]; print STDERR "-- $@"; |
551cd33c | 251 | $a =+ 1 ; |
4438c4b7 JH |
252 | print STDERR "The End.\n" ; |
253 | EXPECT | |
551cd33c | 254 | -- Reversed += operator at (eval 1) line 3. |
4438c4b7 JH |
255 | The End. |
256 | ######## | |
257 | ||
258 | # Check scope of pragma with eval | |
551cd33c | 259 | use warnings FATAL => 'syntax' ; |
4438c4b7 | 260 | eval ' |
551cd33c | 261 | $a =+ 1 ; |
4438c4b7 JH |
262 | '; print STDERR "-- $@"; |
263 | print STDERR "The End.\n" ; | |
264 | EXPECT | |
551cd33c | 265 | -- Reversed += operator at (eval 1) line 2. |
4438c4b7 JH |
266 | The End. |
267 | ######## | |
268 | ||
269 | # Check scope of pragma with eval | |
551cd33c | 270 | use warnings FATAL => 'syntax' ; |
4438c4b7 JH |
271 | eval ' |
272 | no warnings ; | |
551cd33c | 273 | $a =+ 1 ; |
4438c4b7 | 274 | '; print STDERR "-- $@"; |
551cd33c | 275 | $a =+ 1 ; |
4438c4b7 JH |
276 | print STDERR "The End.\n" ; |
277 | EXPECT | |
551cd33c | 278 | Reversed += operator at - line 8. |
f1f33818 | 279 | ######## |
2bd168e2 | 280 | # TODO ? !$Config{usethreads} && $::UTF8 && ($ENV{PERL_DESTRUCT_LEVEL} || 0) > 1 ? "Parser leaks OPs, which leak shared hash keys" : '' |
f1f33818 PM |
281 | |
282 | use warnings 'void' ; | |
283 | ||
284 | time ; | |
285 | ||
286 | { | |
287 | use warnings FATAL => qw(void) ; | |
1518d620 NC |
288 | $a = "abc"; |
289 | length $a ; | |
f1f33818 PM |
290 | } |
291 | ||
292 | join "", 1,2,3 ; | |
293 | ||
294 | print "done\n" ; | |
295 | EXPECT | |
296 | Useless use of time in void context at - line 4. | |
1518d620 | 297 | Useless use of length in void context at - line 9. |
f1f33818 | 298 | ######## |
2bd168e2 | 299 | # TODO ? !$Config{usethreads} && $::UTF8 && ($ENV{PERL_DESTRUCT_LEVEL} || 0) > 1 ? "Parser leaks OPs, which leak shared hash keys" : '' |
f1f33818 PM |
300 | |
301 | use warnings ; | |
302 | ||
303 | time ; | |
304 | ||
305 | { | |
306 | use warnings FATAL => qw(void) ; | |
1518d620 NC |
307 | $a = "abc"; |
308 | length $a ; | |
f1f33818 PM |
309 | } |
310 | ||
311 | join "", 1,2,3 ; | |
312 | ||
313 | print "done\n" ; | |
314 | EXPECT | |
315 | Useless use of time in void context at - line 4. | |
1518d620 | 316 | Useless use of length in void context at - line 9. |
08540116 PM |
317 | ######## |
318 | ||
319 | use warnings FATAL => 'all'; | |
320 | { | |
321 | no warnings; | |
322 | my $b ; chop $b; | |
323 | { | |
324 | use warnings ; | |
325 | my $b ; chop $b; | |
326 | } | |
327 | } | |
328 | my $b ; chop $b; | |
329 | print STDERR "The End.\n" ; | |
330 | EXPECT | |
29489e7c DM |
331 | Use of uninitialized value $b in scalar chop at - line 8. |
332 | Use of uninitialized value $b in scalar chop at - line 11. | |
08540116 PM |
333 | ######## |
334 | ||
335 | use warnings FATAL => 'all'; | |
336 | { | |
337 | no warnings FATAL => 'all'; | |
338 | my $b ; chop $b; | |
339 | { | |
340 | use warnings ; | |
341 | my $b ; chop $b; | |
342 | } | |
343 | } | |
344 | my $b ; chop $b; | |
345 | print STDERR "The End.\n" ; | |
346 | EXPECT | |
29489e7c DM |
347 | Use of uninitialized value $b in scalar chop at - line 8. |
348 | Use of uninitialized value $b in scalar chop at - line 11. | |
08540116 PM |
349 | ######## |
350 | ||
351 | use warnings FATAL => 'all'; | |
352 | { | |
353 | no warnings 'syntax'; | |
354 | { | |
355 | use warnings ; | |
356 | my $b ; chop $b; | |
357 | } | |
358 | } | |
359 | my $b ; chop $b; | |
360 | print STDERR "The End.\n" ; | |
361 | EXPECT | |
29489e7c | 362 | Use of uninitialized value $b in scalar chop at - line 7. |
6e9af7e4 PM |
363 | ######## |
364 | ||
365 | use warnings FATAL => 'syntax', NONFATAL => 'void' ; | |
366 | ||
1518d620 NC |
367 | $a = "abc"; |
368 | length $a; | |
6e9af7e4 PM |
369 | print STDERR "The End.\n" ; |
370 | EXPECT | |
1518d620 | 371 | Useless use of length in void context at - line 5. |
6e9af7e4 PM |
372 | The End. |
373 | ######## | |
374 | ||
375 | use warnings FATAL => 'all', NONFATAL => 'void' ; | |
376 | ||
1518d620 NC |
377 | $a = "abc"; |
378 | length $a; | |
6e9af7e4 PM |
379 | print STDERR "The End.\n" ; |
380 | EXPECT | |
1518d620 | 381 | Useless use of length in void context at - line 5. |
6e9af7e4 PM |
382 | The End. |
383 | ######## | |
384 | ||
385 | use warnings FATAL => 'all', NONFATAL => 'void' ; | |
386 | ||
387 | my $a ; chomp $a; | |
1518d620 NC |
388 | |
389 | $b = "abc" ; | |
390 | length $b; | |
6e9af7e4 PM |
391 | print STDERR "The End.\n" ; |
392 | EXPECT | |
1518d620 | 393 | Useless use of length in void context at - line 7. |
29489e7c | 394 | Use of uninitialized value $a in scalar chomp at - line 4. |
6e9af7e4 PM |
395 | ######## |
396 | ||
397 | use warnings FATAL => 'void', NONFATAL => 'void' ; | |
1518d620 NC |
398 | $a = "abc"; |
399 | length $a; | |
6e9af7e4 PM |
400 | print STDERR "The End.\n" ; |
401 | EXPECT | |
402 | Useless use of length in void context at - line 4. | |
403 | The End. | |
404 | ######## | |
2bd168e2 | 405 | # TODO ? !$Config{usethreads} && $::UTF8 && ($ENV{PERL_DESTRUCT_LEVEL} || 0) > 1 ? "Parser leaks OPs, which leak shared hash keys" : '' |
6e9af7e4 PM |
406 | |
407 | use warnings NONFATAL => 'void', FATAL => 'void' ; | |
1518d620 NC |
408 | $a = "abc"; |
409 | length $a; | |
6e9af7e4 PM |
410 | print STDERR "The End.\n" ; |
411 | EXPECT | |
412 | Useless use of length in void context at - line 4. | |
413 | ######## | |
414 | ||
415 | use warnings FATAL => 'all', NONFATAL => 'io'; | |
416 | no warnings 'once'; | |
417 | ||
418 | open(F, "<true\ncd"); | |
7cb3f959 TC |
419 | open(G, "<truecd\n"); |
420 | open(H, "<truecd\n\0"); | |
6e9af7e4 PM |
421 | close "fred" ; |
422 | print STDERR "The End.\n" ; | |
423 | EXPECT | |
7cb3f959 TC |
424 | Unsuccessful open on filename containing newline at - line 6. |
425 | Unsuccessful open on filename containing newline at - line 7. | |
426 | close() on unopened filehandle fred at - line 8. | |
6e9af7e4 PM |
427 | The End. |
428 | ######## | |
429 | ||
430 | use warnings FATAL => 'all', NONFATAL => 'io', FATAL => 'unopened' ; | |
431 | no warnings 'once'; | |
432 | ||
7cb3f959 | 433 | open(F, "<truecd\n"); |
6e9af7e4 PM |
434 | close "fred" ; |
435 | print STDERR "The End.\n" ; | |
436 | EXPECT | |
437 | Unsuccessful open on filename containing newline at - line 5. | |
438 | close() on unopened filehandle fred at - line 6. | |
c91312d5 H |
439 | ######## |
440 | ||
441 | # 'use warnings' test as the basis for the following tests | |
442 | use warnings ; | |
443 | my $a = oct "7777777777777777777777777777777777778" ; | |
444 | my $b =+ 1 ; | |
445 | my $c ; chop $c ; | |
446 | print STDERR "The End.\n" ; | |
447 | EXPECT | |
448 | Reversed += operator at - line 5. | |
449 | Integer overflow in octal number at - line 4. | |
450 | Illegal octal digit '8' ignored at - line 4. | |
451 | Octal number > 037777777777 non-portable at - line 4. | |
452 | Use of uninitialized value $c in scalar chop at - line 6. | |
453 | The End. | |
454 | ######## | |
455 | ||
456 | # 'use warnings NONFATAL=>"all"' should be the same as 'use warnings' | |
457 | use warnings NONFATAL=>"all" ; | |
458 | my $a = oct "7777777777777777777777777777777777778" ; | |
459 | my $b =+ 1 ; | |
460 | my $c ; chop $c ; | |
461 | print STDERR "The End.\n" ; | |
462 | EXPECT | |
463 | Reversed += operator at - line 5. | |
464 | Integer overflow in octal number at - line 4. | |
465 | Illegal octal digit '8' ignored at - line 4. | |
466 | Octal number > 037777777777 non-portable at - line 4. | |
467 | Use of uninitialized value $c in scalar chop at - line 6. | |
468 | The End. | |
469 | ######## | |
470 | ||
471 | # 'use warnings "NONFATAL"' should be the same as 'use warnings' [perl #120977] | |
472 | use warnings "NONFATAL" ; | |
473 | my $a = oct "7777777777777777777777777777777777778" ; | |
474 | my $b =+ 1 ; | |
475 | my $c ; chop $c ; | |
476 | print STDERR "The End.\n" ; | |
477 | EXPECT | |
478 | Reversed += operator at - line 5. | |
479 | Integer overflow in octal number at - line 4. | |
480 | Illegal octal digit '8' ignored at - line 4. | |
481 | Octal number > 037777777777 non-portable at - line 4. | |
482 | Use of uninitialized value $c in scalar chop at - line 6. | |
483 | The End. | |
484 | ######## | |
485 | ||
486 | # 'use warnings "FATAL"' should be the same as 'use warnings FATAL=>"all"' [perl #120977] | |
487 | use warnings "FATAL" ; | |
488 | { | |
489 | no warnings ; | |
490 | my $a =+ 1 ; | |
491 | } | |
492 | my $a =+ 1 ; | |
493 | print STDERR "The End.\n" ; | |
494 | EXPECT | |
495 | Reversed += operator at - line 8. | |
496 | ######## | |
497 | ||
498 | # 'use warnings "FATAL"' should be the same as 'use warnings FATAL=>"all"' [perl #120977] | |
499 | use warnings "FATAL" ; | |
500 | { | |
501 | no warnings ; | |
502 | my $a = oct "7777777777777777777777777777777777778" ; | |
503 | } | |
504 | my $a = oct "7777777777777777777777777777777777778" ; | |
505 | print STDERR "The End.\n" ; | |
506 | EXPECT | |
507 | Integer overflow in octal number at - line 8. | |
508 | ######## | |
509 | ||
510 | # 'no warnings FATAL=>"all"' should be the same as 'no warnings' | |
511 | use warnings ; | |
512 | { | |
513 | no warnings FATAL=>"all" ; | |
514 | my $a = oct "7777777777777777777777777777777777778" ; | |
515 | my $b =+ 1 ; | |
516 | my $c ; chop $c ; | |
517 | } | |
518 | my $a =+ 1 ; | |
519 | print STDERR "The End.\n" ; | |
520 | EXPECT | |
521 | Reversed += operator at - line 10. | |
522 | The End. | |
523 | ######## | |
524 | ||
525 | # 'no warnings "FATAL"' should be the same as 'no warnings' [perl #120977] | |
526 | use warnings ; | |
527 | { | |
528 | no warnings "FATAL" ; | |
529 | my $a = oct "7777777777777777777777777777777777778" ; | |
530 | my $b =+ 1 ; | |
531 | my $c ; chop $c ; | |
532 | } | |
533 | my $a =+ 1 ; | |
534 | print STDERR "The End.\n" ; | |
535 | EXPECT | |
536 | Reversed += operator at - line 10. | |
537 | The End. | |
594b6fac LM |
538 | ######## |
539 | ||
540 | # fatal warnings shouldn't hide parse errors [perl #122966] | |
541 | use warnings FATAL => 'all'; | |
542 | if (1 { | |
543 | my $x = "hello"; | |
544 | print $x, "\n"; | |
545 | } | |
546 | EXPECT | |
547 | syntax error at - line 4, near "1 {" | |
548 | "my" variable $x masks earlier declaration in same statement at - line 6. | |
549 | syntax error at - line 7, near "}" | |
550 | Execution of - aborted due to compilation errors. | |
4221d7c5 RU |
551 | ######## |
552 | ||
553 | # fatal warnings in DESTROY should be made non-fatal [perl #123398] | |
554 | # This test will blow up your memory with SEGV without the patch | |
555 | package Foo; | |
556 | use strict; use utf8; use warnings FATAL => 'all'; | |
557 | sub new { | |
558 | return bless{ 'field' => undef }, 'Foo'; | |
559 | } | |
560 | sub DESTROY { | |
561 | my $self = shift; | |
562 | $self->{'field'}->missing_method; | |
563 | } | |
564 | package main; | |
565 | my $foo = new Foo; | |
566 | undef($foo); | |
567 | EXPECT | |
568 | (in cleanup) Can't call method "missing_method" on an undefined value at - line 11. |