Commit | Line | Data |
8d93267c |
1 | Check warnings::enabled & warnings::warn |
2 | |
3 | __END__ |
4 | |
5 | --FILE-- abc.pm |
6 | package abc ; |
7 | use warnings "io" ; |
d3a7d8c7 |
8 | print "ok1\n" if ! warnings::enabled('all') ; |
8d93267c |
9 | print "ok2\n" if ! warnings::enabled("io") ; |
10 | 1; |
11 | --FILE-- |
12 | no warnings; |
13 | use abc ; |
14 | EXPECT |
15 | ok1 |
16 | ok2 |
17 | ######## |
18 | |
19 | --FILE-- abc.pm |
20 | package abc ; |
21 | no warnings ; |
d3a7d8c7 |
22 | print "ok1\n" if !warnings::enabled('all') ; |
8d93267c |
23 | print "ok2\n" if warnings::enabled("syntax") ; |
24 | 1; |
25 | --FILE-- |
26 | use warnings 'syntax' ; |
27 | use abc ; |
28 | EXPECT |
29 | ok1 |
30 | ok2 |
31 | ######## |
32 | |
33 | --FILE-- abc.pm |
34 | package abc ; |
35 | use warnings 'syntax' ; |
d3a7d8c7 |
36 | print "ok1\n" if warnings::enabled('io') ; |
8d93267c |
37 | print "ok2\n" if ! warnings::enabled("syntax") ; |
38 | 1; |
39 | --FILE-- |
40 | use warnings 'io' ; |
41 | use abc ; |
42 | EXPECT |
43 | ok1 |
44 | ok2 |
45 | ######## |
46 | |
47 | --FILE-- abc |
48 | no warnings ; |
d3a7d8c7 |
49 | print "ok1\n" if !warnings::enabled('all') ; |
4f527b71 |
50 | print "ok2\n" if !warnings::enabled("syntax") ; |
8d93267c |
51 | 1; |
52 | --FILE-- |
53 | use warnings 'syntax' ; |
54 | require "abc" ; |
55 | EXPECT |
56 | ok1 |
57 | ok2 |
58 | ######## |
59 | |
60 | --FILE-- abc |
61 | use warnings 'syntax' ; |
d3a7d8c7 |
62 | print "ok1\n" if ! warnings::enabled('all') ; |
8d93267c |
63 | print "ok2\n" if ! warnings::enabled("syntax") ; |
4f527b71 |
64 | print "ok3\n" if ! warnings::enabled("io") ; |
8d93267c |
65 | 1; |
66 | --FILE-- |
67 | use warnings 'io' ; |
68 | require "abc" ; |
69 | EXPECT |
70 | ok1 |
71 | ok2 |
72 | ok3 |
73 | ######## |
74 | |
75 | --FILE-- abc.pm |
76 | package abc ; |
77 | no warnings ; |
78 | sub check { |
d3a7d8c7 |
79 | print "ok1\n" if !warnings::enabled('all') ; |
8d93267c |
80 | print "ok2\n" if warnings::enabled("syntax") ; |
81 | } |
82 | 1; |
83 | --FILE-- |
84 | use warnings 'syntax' ; |
85 | use abc ; |
86 | abc::check() ; |
87 | EXPECT |
88 | ok1 |
89 | ok2 |
90 | ######## |
91 | |
92 | --FILE-- abc.pm |
93 | package abc ; |
94 | use warnings 'io' ; |
95 | sub check { |
d3a7d8c7 |
96 | print "ok1\n" if ! warnings::enabled('all') ; |
97 | print "ok2\n" if warnings::enabled("syntax") ; |
8d93267c |
98 | print "ok3\n" if ! warnings::enabled("io") ; |
99 | } |
100 | 1; |
101 | --FILE-- |
102 | use warnings 'syntax' ; |
103 | use abc ; |
104 | abc::check() ; |
105 | EXPECT |
106 | ok1 |
107 | ok2 |
108 | ok3 |
109 | ######## |
110 | |
111 | --FILE-- abc |
112 | package abc ; |
113 | no warnings ; |
114 | sub check { |
d3a7d8c7 |
115 | print "ok1\n" if !warnings::enabled('all') ; |
8d93267c |
116 | print "ok2\n" if warnings::enabled("syntax") ; |
117 | } |
118 | 1; |
119 | --FILE-- |
120 | use warnings 'syntax' ; |
121 | require "abc" ; |
122 | abc::check() ; |
123 | EXPECT |
124 | ok1 |
125 | ok2 |
126 | ######## |
127 | |
128 | --FILE-- abc |
129 | package abc ; |
130 | use warnings 'io' ; |
131 | sub check { |
d3a7d8c7 |
132 | print "ok1\n" if ! warnings::enabled('all') ; |
133 | print "ok2\n" if warnings::enabled("syntax") ; |
8d93267c |
134 | print "ok3\n" if ! warnings::enabled("io") ; |
135 | } |
136 | 1; |
137 | --FILE-- |
138 | use warnings 'syntax' ; |
139 | require "abc" ; |
140 | abc::check() ; |
141 | EXPECT |
142 | ok1 |
143 | ok2 |
144 | ok3 |
145 | ######## |
146 | |
147 | --FILE-- abc.pm |
148 | package abc ; |
149 | use warnings "io" ; |
d3a7d8c7 |
150 | print "ok1\n" if ! warnings::enabled('all') ; |
8d93267c |
151 | print "ok2\n" if ! warnings::enabled("io") ; |
152 | 1; |
153 | --FILE-- def.pm |
f89e79d6 |
154 | package def; |
8d93267c |
155 | no warnings; |
156 | use abc ; |
157 | 1; |
158 | --FILE-- |
159 | use warnings; |
160 | use def ; |
161 | EXPECT |
162 | ok1 |
163 | ok2 |
164 | ######## |
165 | |
166 | --FILE-- abc.pm |
167 | package abc ; |
168 | no warnings ; |
d3a7d8c7 |
169 | print "ok1\n" if ! warnings::enabled('all') ; |
8d93267c |
170 | print "ok2\n" if warnings::enabled("syntax") ; |
171 | print "ok3\n" if !warnings::enabled("io") ; |
172 | 1; |
173 | --FILE-- def.pm |
174 | use warnings 'syntax' ; |
d3a7d8c7 |
175 | print "ok4\n" if !warnings::enabled('all') ; |
4f527b71 |
176 | print "ok5\n" if !warnings::enabled("io") ; |
8d93267c |
177 | use abc ; |
178 | 1; |
179 | --FILE-- |
180 | use warnings 'io' ; |
181 | use def ; |
182 | EXPECT |
183 | ok1 |
184 | ok2 |
185 | ok3 |
186 | ok4 |
187 | ok5 |
188 | ######## |
189 | |
190 | --FILE-- abc.pm |
191 | package abc ; |
192 | no warnings ; |
193 | sub check { |
d3a7d8c7 |
194 | print "ok1\n" if !warnings::enabled('all') ; |
8d93267c |
195 | print "ok2\n" if warnings::enabled("syntax") ; |
196 | } |
197 | 1; |
198 | --FILE-- |
199 | use warnings 'syntax' ; |
200 | use abc ; |
c3186b65 |
201 | eval { |
202 | abc::check() ; |
203 | }; |
8d93267c |
204 | print $@ ; |
205 | EXPECT |
206 | ok1 |
207 | ok2 |
208 | ######## |
209 | |
210 | --FILE-- abc.pm |
211 | package abc ; |
212 | use warnings 'io' ; |
213 | sub check { |
d3a7d8c7 |
214 | print "ok1\n" if ! warnings::enabled('all') ; |
215 | print "ok2\n" if warnings::enabled("syntax") ; |
8d93267c |
216 | print "ok3\n" if ! warnings::enabled("io") ; |
217 | } |
218 | 1; |
219 | --FILE-- |
220 | use warnings 'syntax' ; |
221 | use abc ; |
c3186b65 |
222 | eval { |
223 | abc::check() ; |
224 | } ; |
8d93267c |
225 | print $@ ; |
226 | EXPECT |
227 | ok1 |
228 | ok2 |
229 | ok3 |
230 | ######## |
231 | |
232 | --FILE-- abc |
233 | package abc ; |
234 | no warnings ; |
235 | sub check { |
d3a7d8c7 |
236 | print "ok1\n" if !warnings::enabled('all') ; |
8d93267c |
237 | print "ok2\n" if warnings::enabled("syntax") ; |
238 | } |
239 | 1; |
240 | --FILE-- |
241 | use warnings 'syntax' ; |
242 | require "abc" ; |
c3186b65 |
243 | eval { |
244 | abc::check() ; |
245 | } ; |
8d93267c |
246 | print $@ ; |
247 | EXPECT |
248 | ok1 |
249 | ok2 |
250 | ######## |
251 | |
252 | --FILE-- abc |
253 | package abc ; |
254 | use warnings 'io' ; |
255 | sub check { |
d3a7d8c7 |
256 | print "ok1\n" if !warnings::enabled('all') ; |
8d93267c |
257 | print "ok2\n" if warnings::enabled("syntax") ; |
258 | print "ok3\n" if warnings::enabled("io") ; |
259 | } |
260 | 1; |
261 | --FILE-- |
262 | use warnings 'syntax' ; |
263 | require "abc" ; |
c3186b65 |
264 | eval { |
265 | use warnings 'io' ; |
266 | abc::check() ; |
267 | }; |
8d93267c |
268 | abc::check() ; |
269 | print $@ ; |
270 | EXPECT |
271 | ok1 |
272 | ok2 |
273 | ok3 |
274 | ok1 |
275 | ok2 |
276 | ######## |
277 | |
278 | --FILE-- abc.pm |
279 | package abc ; |
280 | use warnings 'io' ; |
281 | sub check { |
d3a7d8c7 |
282 | print "ok1\n" if ! warnings::enabled('all') ; |
8d93267c |
283 | print "ok2\n" if warnings::enabled("syntax") ; |
284 | print "ok3\n" if ! warnings::enabled("io") ; |
285 | } |
286 | 1; |
287 | --FILE-- |
288 | use warnings 'syntax' ; |
289 | use abc ; |
290 | sub fred { abc::check() } |
291 | fred() ; |
292 | EXPECT |
293 | ok1 |
294 | ok2 |
295 | ok3 |
296 | ######## |
297 | |
298 | --FILE-- abc.pm |
299 | package abc ; |
300 | use warnings 'io' ; |
301 | sub check { |
d3a7d8c7 |
302 | print "ok1\n" if ! warnings::enabled('all') ; |
8d93267c |
303 | } |
304 | 1; |
305 | --FILE-- |
306 | use warnings 'syntax' ; |
307 | use abc ; |
308 | sub fred { no warnings ; abc::check() } |
309 | fred() ; |
310 | EXPECT |
311 | ok1 |
312 | ######## |
313 | |
314 | --FILE-- abc.pm |
315 | package abc ; |
316 | use warnings 'misc' ; |
317 | sub check { |
d3a7d8c7 |
318 | print "ok1\n" if ! warnings::enabled('all') ; |
8d93267c |
319 | print "ok2\n" if warnings::enabled("syntax") ; |
320 | print "ok3\n" if warnings::enabled("io") ; |
321 | print "ok4\n" if ! warnings::enabled("misc") ; |
322 | } |
323 | 1; |
324 | --FILE-- |
325 | use warnings 'syntax' ; |
326 | use abc ; |
327 | sub fred { use warnings 'io' ; abc::check() } |
328 | fred() ; |
329 | EXPECT |
330 | ok1 |
331 | ok2 |
332 | ok3 |
333 | ok4 |
334 | ######## |
335 | |
336 | # check warnings::warn |
337 | use warnings ; |
c3186b65 |
338 | eval { |
339 | warnings::warn() |
340 | } ; |
8d93267c |
341 | print $@ ; |
c3186b65 |
342 | eval { |
343 | warnings::warn("fred", "joe") |
344 | } ; |
8d93267c |
345 | print $@ ; |
346 | EXPECT |
c3186b65 |
347 | Usage: warnings::warn([category,] 'message') at - line 5 |
348 | Unknown warnings category 'fred' at - line 9 |
7e6d00f8 |
349 | ######## |
350 | |
351 | # check warnings::warnif |
352 | use warnings ; |
c3186b65 |
353 | eval { |
354 | warnings::warnif() |
355 | } ; |
7e6d00f8 |
356 | print $@ ; |
c3186b65 |
357 | eval { |
358 | warnings::warnif("fred", "joe") |
359 | } ; |
7e6d00f8 |
360 | print $@ ; |
361 | EXPECT |
c3186b65 |
362 | Usage: warnings::warnif([category,] 'message') at - line 5 |
363 | Unknown warnings category 'fred' at - line 9 |
8d93267c |
364 | ######## |
365 | |
366 | --FILE-- abc.pm |
367 | package abc ; |
368 | use warnings 'misc' ; |
369 | sub check { warnings::warn("io", "hello") } |
370 | 1; |
371 | --FILE-- |
372 | use warnings "io" ; |
373 | use abc; |
374 | abc::check() ; |
375 | EXPECT |
376 | hello at - line 3 |
377 | ######## |
378 | |
379 | --FILE-- abc.pm |
380 | package abc ; |
381 | use warnings 'misc' ; |
382 | sub check { warnings::warn("misc", "hello") } |
383 | 1; |
384 | --FILE-- |
385 | use warnings "io" ; |
386 | use abc; |
387 | abc::check() ; |
388 | EXPECT |
389 | hello at - line 3 |
390 | ######## |
391 | |
392 | --FILE-- abc.pm |
393 | package abc ; |
394 | use warnings 'misc' ; |
395 | sub check { warnings::warn("io", "hello") } |
396 | 1; |
397 | --FILE-- |
398 | use warnings qw( FATAL deprecated ) ; |
399 | use abc; |
c3186b65 |
400 | eval { |
401 | abc::check() ; |
402 | } ; |
8d93267c |
403 | print "[[$@]]\n"; |
404 | EXPECT |
c3186b65 |
405 | hello at - line 4 |
8d93267c |
406 | [[]] |
407 | ######## |
408 | |
409 | --FILE-- abc.pm |
410 | package abc ; |
411 | use warnings 'misc' ; |
412 | sub check { warnings::warn("io", "hello") } |
413 | 1; |
414 | --FILE-- |
415 | use warnings qw( FATAL io ) ; |
416 | use abc; |
c3186b65 |
417 | eval { |
418 | abc::check() ; |
419 | } ; |
8d93267c |
420 | print "[[$@]]\n"; |
421 | EXPECT |
c3186b65 |
422 | [[hello at - line 4 |
8d93267c |
423 | ]] |
d3a7d8c7 |
424 | ######## |
425 | -W |
426 | --FILE-- abc.pm |
427 | package abc ; |
428 | use warnings "io" ; |
429 | print "ok1\n" if warnings::enabled("io") ; |
430 | print "ok2\n" if warnings::enabled("all") ; |
431 | 1; |
432 | --FILE-- |
433 | no warnings; |
434 | use abc ; |
435 | EXPECT |
436 | ok1 |
437 | ok2 |
438 | ######## |
439 | -X |
440 | --FILE-- abc.pm |
441 | package abc ; |
442 | use warnings "io" ; |
443 | print "ok1\n" if !warnings::enabled("io") ; |
444 | print "ok2\n" if !warnings::enabled("all") ; |
445 | 1; |
446 | --FILE-- |
447 | use warnings; |
448 | use abc ; |
449 | EXPECT |
450 | ok1 |
451 | ok2 |
452 | ######## |
453 | |
454 | --FILE-- abc.pm |
455 | package abc ; |
456 | no warnings ; |
457 | sub check { |
458 | print "ok\n" if ! warnings::enabled() ; |
459 | } |
460 | 1; |
461 | --FILE-- |
462 | use warnings 'syntax' ; |
463 | use abc ; |
464 | abc::check() ; |
465 | EXPECT |
7e6d00f8 |
466 | package 'abc' not registered for warnings at abc.pm line 4 |
467 | ######## |
468 | |
469 | --FILE-- abc.pm |
470 | package abc ; |
471 | no warnings ; |
472 | sub check { |
473 | warnings::warn("fred") ; |
474 | } |
475 | 1; |
476 | --FILE-- |
477 | use warnings 'syntax' ; |
478 | use abc ; |
479 | abc::check() ; |
480 | EXPECT |
481 | package 'abc' not registered for warnings at abc.pm line 4 |
482 | ######## |
483 | |
484 | --FILE-- abc.pm |
485 | package abc ; |
486 | no warnings ; |
487 | sub check { |
488 | warnings::warnif("fred") ; |
489 | } |
490 | 1; |
491 | --FILE-- |
492 | use warnings 'syntax' ; |
493 | use abc ; |
494 | abc::check() ; |
495 | EXPECT |
496 | package 'abc' not registered for warnings at abc.pm line 4 |
d3a7d8c7 |
497 | ######## |
498 | |
499 | --FILE-- abc.pm |
500 | package abc ; |
501 | use warnings 'io' ; |
502 | use warnings::register ; |
503 | sub check { |
504 | print "ok1\n" if warnings::enabled ; |
505 | print "ok2\n" if warnings::enabled("syntax") ; |
506 | print "ok3\n" if !warnings::enabled("io") ; |
507 | } |
508 | 1; |
509 | --FILE-- |
510 | use warnings 'syntax' ; |
511 | use abc ; |
512 | use warnings 'abc' ; |
513 | abc::check() ; |
514 | EXPECT |
515 | ok1 |
516 | ok2 |
517 | ok3 |
518 | ######## |
519 | |
520 | --FILE-- abc.pm |
521 | package abc ; |
522 | use warnings 'io' ; |
523 | use warnings::register ; |
524 | sub check { |
525 | print "ok1\n" if !warnings::enabled ; |
526 | print "ok2\n" if warnings::enabled("syntax") ; |
527 | print "ok3\n" if !warnings::enabled("io") ; |
528 | } |
529 | 1; |
530 | --FILE-- |
531 | use warnings 'syntax' ; |
532 | use abc ; |
533 | abc::check() ; |
534 | EXPECT |
535 | ok1 |
536 | ok2 |
537 | ok3 |
538 | ######## |
539 | |
540 | --FILE-- abc.pm |
541 | package abc ; |
542 | no warnings ; |
543 | use warnings::register ; |
544 | sub check { |
545 | print "ok1\n" if warnings::enabled ; |
546 | print "ok2\n" if warnings::enabled("syntax") ; |
547 | } |
548 | 1; |
549 | --FILE-- |
550 | use warnings 'syntax' ; |
551 | use abc ; |
552 | use warnings 'abc' ; |
553 | eval { abc::check() ; }; |
554 | print $@ ; |
555 | EXPECT |
556 | ok1 |
557 | ok2 |
558 | ######## |
559 | |
560 | --FILE-- abc.pm |
561 | package abc ; |
562 | use warnings 'io' ; |
563 | use warnings::register ; |
564 | sub check { |
565 | print "ok1\n" if !warnings::enabled ; |
566 | print "ok2\n" if warnings::enabled("syntax") ; |
567 | print "ok3\n" if !warnings::enabled("io") ; |
568 | } |
569 | 1; |
570 | --FILE-- |
571 | use warnings 'syntax' ; |
572 | use abc ; |
573 | eval { abc::check() ; } ; |
574 | print $@ ; |
575 | EXPECT |
576 | ok1 |
577 | ok2 |
578 | ok3 |
579 | ######## |
580 | |
581 | --FILE-- abc.pm |
582 | package abc ; |
583 | use warnings 'io' ; |
584 | use warnings::register ; |
585 | sub check { |
586 | print "ok1\n" if warnings::enabled ; |
587 | print "ok2\n" if warnings::enabled("syntax") ; |
588 | print "ok3\n" if !warnings::enabled("io") ; |
589 | } |
590 | 1; |
591 | --FILE-- |
592 | use warnings 'syntax' ; |
593 | use abc ; |
594 | use warnings 'abc' ; |
595 | sub fred { abc::check() } |
596 | fred() ; |
597 | EXPECT |
598 | ok1 |
599 | ok2 |
600 | ok3 |
601 | ######## |
602 | |
603 | --FILE-- abc.pm |
604 | package abc ; |
605 | use warnings 'io' ; |
606 | use warnings::register ; |
607 | sub check { |
608 | print "ok1\n" if ! warnings::enabled ; |
609 | } |
610 | 1; |
611 | --FILE-- |
612 | use warnings 'syntax' ; |
613 | use abc ; |
614 | sub fred { no warnings ; abc::check() } |
615 | fred() ; |
616 | EXPECT |
617 | ok1 |
618 | ######## |
619 | |
620 | --FILE-- abc.pm |
621 | package abc ; |
622 | use warnings 'misc' ; |
623 | use warnings::register; |
624 | sub check { |
625 | print "ok1\n" if warnings::enabled ; |
626 | print "ok2\n" if warnings::enabled("syntax") ; |
627 | print "ok3\n" if warnings::enabled("io") ; |
628 | print "ok4\n" if ! warnings::enabled("misc") ; |
629 | } |
630 | 1; |
631 | --FILE-- |
632 | use warnings 'syntax' ; |
633 | use abc ; |
634 | use warnings 'abc' ; |
635 | sub fred { use warnings 'io' ; abc::check() } |
636 | fred() ; |
637 | EXPECT |
638 | ok1 |
639 | ok2 |
640 | ok3 |
641 | ok4 |
642 | ######## |
643 | |
644 | --FILE-- abc.pm |
645 | package abc ; |
646 | use warnings 'misc' ; |
647 | use warnings::register; |
648 | sub check { warnings::warn("hello") } |
649 | 1; |
650 | --FILE-- |
651 | use abc; |
652 | use warnings "abc" ; |
653 | abc::check() ; |
654 | EXPECT |
655 | hello at - line 3 |
656 | ######## |
657 | |
658 | --FILE-- abc.pm |
659 | package abc ; |
660 | use warnings::register; |
661 | sub check { warnings::warn("hello") } |
662 | 1; |
663 | --FILE-- |
664 | use abc; |
665 | abc::check() ; |
666 | EXPECT |
667 | hello at - line 2 |
668 | ######## |
669 | |
670 | --FILE-- abc.pm |
671 | package abc ; |
672 | use warnings::register ; |
673 | sub check { warnings::warn("hello") } |
674 | 1; |
675 | --FILE-- |
676 | use abc; |
677 | use warnings qw( FATAL deprecated ) ; |
c3186b65 |
678 | eval { |
679 | abc::check() ; |
680 | } ; |
d3a7d8c7 |
681 | print "[[$@]]\n"; |
682 | EXPECT |
c3186b65 |
683 | hello at - line 4 |
d3a7d8c7 |
684 | [[]] |
685 | ######## |
686 | |
687 | --FILE-- abc.pm |
688 | package abc ; |
689 | use warnings::register ; |
690 | sub check { warnings::warn("hello") } |
691 | 1; |
692 | --FILE-- |
693 | use abc; |
694 | use warnings qw( FATAL abc ) ; |
c3186b65 |
695 | eval { |
696 | abc::check() ; |
697 | } ; |
d3a7d8c7 |
698 | print "[[$@]]\n"; |
699 | EXPECT |
c3186b65 |
700 | [[hello at - line 4 |
d3a7d8c7 |
701 | ]] |
702 | ######## |
703 | -W |
704 | --FILE-- abc.pm |
705 | package abc ; |
706 | use warnings "io" ; |
707 | use warnings::register ; |
708 | sub check { |
709 | print "ok1\n" if warnings::enabled() ; |
710 | print "ok2\n" if warnings::enabled("io") ; |
711 | print "ok3\n" if warnings::enabled("all") ; |
712 | } |
713 | 1; |
714 | --FILE-- |
715 | no warnings; |
716 | use abc ; |
717 | abc::check() ; |
718 | EXPECT |
719 | ok1 |
720 | ok2 |
721 | ok3 |
722 | ######## |
723 | -X |
724 | --FILE-- abc.pm |
725 | package abc ; |
726 | use warnings "io" ; |
727 | use warnings::register ; |
728 | sub check { |
729 | print "ok1\n" if !warnings::enabled() ; |
730 | print "ok2\n" if !warnings::enabled("io") ; |
731 | print "ok3\n" if !warnings::enabled("all") ; |
732 | } |
733 | 1; |
734 | --FILE-- |
735 | no warnings; |
736 | use abc ; |
737 | abc::check() ; |
738 | EXPECT |
739 | ok1 |
740 | ok2 |
741 | ok3 |
742 | ######## |
743 | |
744 | --FILE-- abc.pm |
745 | package abc ; |
746 | use warnings "io" ; |
747 | use warnings::register ; |
748 | sub check { |
749 | print "ok1\n" if warnings::enabled() ; |
750 | print "ok2\n" if warnings::enabled("io") ; |
751 | print "ok3\n" if warnings::enabled("all") ; |
752 | } |
753 | 1; |
754 | --FILE-- |
755 | use warnings 'all'; |
756 | use abc ; |
757 | abc::check() ; |
758 | EXPECT |
759 | ok1 |
760 | ok2 |
761 | ok3 |
762 | ######## |
763 | |
764 | --FILE-- abc.pm |
765 | package abc ; |
766 | use warnings "io" ; |
767 | use warnings::register ; |
768 | sub check { |
769 | print "ok1\n" if !warnings::enabled() ; |
770 | print "ok2\n" if !warnings::enabled("io") ; |
771 | print "ok3\n" if !warnings::enabled("all") ; |
772 | } |
773 | 1; |
774 | --FILE-- |
775 | use abc ; |
776 | no warnings ; |
777 | abc::check() ; |
778 | EXPECT |
779 | ok1 |
780 | ok2 |
781 | ok3 |
782 | ######## |
783 | |
784 | --FILE-- abc.pm |
785 | package abc ; |
786 | use warnings "io" ; |
787 | use warnings::register ; |
788 | sub check { |
789 | print "ok1\n" if !warnings::enabled() ; |
790 | print "ok2\n" if !warnings::enabled("io") ; |
791 | print "ok3\n" if !warnings::enabled("all") ; |
7e6d00f8 |
792 | warnings::warnif("my message 1") ; |
793 | warnings::warnif('abc', "my message 2") ; |
794 | warnings::warnif('io', "my message 3") ; |
795 | warnings::warnif('all', "my message 4") ; |
d3a7d8c7 |
796 | } |
797 | 1; |
798 | --FILE-- |
799 | use abc ; |
800 | use warnings 'abc'; |
801 | no warnings ; |
802 | abc::check() ; |
803 | EXPECT |
804 | ok1 |
805 | ok2 |
806 | ok3 |
807 | ######## |
808 | |
809 | --FILE-- abc.pm |
810 | package abc ; |
811 | use warnings "io" ; |
812 | use warnings::register ; |
813 | sub check { |
814 | print "abc self" . (warnings::enabled() ? "" : " not") . " enabled\n" ; |
815 | print "abc def" . (warnings::enabled('def') ? "" : " not") . " enabled\n" ; |
816 | print "abc all" . (warnings::enabled('all') ? "" : " not") . " enabled\n" ; |
817 | } |
818 | 1; |
819 | --FILE-- def.pm |
820 | package def ; |
821 | use warnings "io" ; |
822 | use warnings::register ; |
823 | sub check { |
824 | print "def self" . (warnings::enabled() ? "" : " not") . " enabled\n" ; |
825 | print "def abc" . (warnings::enabled('abc') ? "" : " not") . " enabled\n" ; |
826 | print "def all" . (warnings::enabled('all') ? "" : " not") . " enabled\n" ; |
827 | } |
828 | 1; |
829 | --FILE-- |
830 | use abc ; |
831 | use def ; |
832 | use warnings 'abc'; |
833 | abc::check() ; |
834 | def::check() ; |
835 | no warnings 'abc' ; |
836 | use warnings 'def' ; |
837 | abc::check() ; |
838 | def::check() ; |
839 | use warnings 'abc' ; |
840 | use warnings 'def' ; |
841 | abc::check() ; |
842 | def::check() ; |
843 | no warnings 'abc' ; |
844 | no warnings 'def' ; |
845 | abc::check() ; |
846 | def::check() ; |
847 | use warnings; |
848 | abc::check() ; |
849 | def::check() ; |
850 | no warnings 'abc' ; |
851 | abc::check() ; |
852 | def::check() ; |
853 | EXPECT |
854 | abc self enabled |
855 | abc def not enabled |
856 | abc all not enabled |
857 | def self not enabled |
858 | def abc enabled |
859 | def all not enabled |
860 | abc self not enabled |
861 | abc def enabled |
862 | abc all not enabled |
863 | def self enabled |
864 | def abc not enabled |
865 | def all not enabled |
866 | abc self enabled |
867 | abc def enabled |
868 | abc all not enabled |
869 | def self enabled |
870 | def abc enabled |
871 | def all not enabled |
872 | abc self not enabled |
873 | abc def not enabled |
874 | abc all not enabled |
875 | def self not enabled |
876 | def abc not enabled |
877 | def all not enabled |
878 | abc self enabled |
879 | abc def enabled |
880 | abc all enabled |
881 | def self enabled |
882 | def abc enabled |
883 | def all enabled |
884 | abc self not enabled |
885 | abc def enabled |
886 | abc all not enabled |
887 | def self enabled |
888 | def abc not enabled |
889 | def all not enabled |
114bafba |
890 | ######## |
891 | -w |
892 | --FILE-- abc.pm |
893 | package abc ; |
894 | no warnings ; |
895 | use warnings::register ; |
896 | sub check { |
897 | print "ok1\n" if warnings::enabled() ; |
898 | print "ok2\n" if warnings::enabled("io") ; |
899 | print "ok3\n" if warnings::enabled("all") ; |
900 | } |
901 | 1; |
902 | --FILE-- |
903 | use abc ; |
904 | abc::check() ; |
905 | EXPECT |
906 | ok1 |
907 | ok2 |
908 | ok3 |
909 | ######## |
910 | -w |
911 | --FILE-- abc.pm |
912 | package abc ; |
913 | no warnings ; |
914 | use warnings::register ; |
915 | sub check { |
916 | print "ok1\n" if !warnings::enabled() ; |
917 | print "ok2\n" if !warnings::enabled("io") ; |
918 | print "ok3\n" if !warnings::enabled("all") ; |
919 | } |
920 | 1; |
921 | --FILE-- |
922 | use abc ; |
923 | use warnings 'abc'; |
924 | no warnings ; |
925 | abc::check() ; |
926 | EXPECT |
927 | ok1 |
928 | ok2 |
929 | ok3 |
930 | ######## |
931 | |
932 | --FILE-- abc.pm |
933 | package abc ; |
934 | no warnings ; |
935 | use warnings::register ; |
936 | sub check { |
937 | print "ok1\n" if !warnings::enabled() ; |
938 | print "ok2\n" if !warnings::enabled("io") ; |
939 | print "ok3\n" if !warnings::enabled("all") ; |
7e6d00f8 |
940 | warnings::warnif("my message 1") ; |
941 | warnings::warnif('abc', "my message 2") ; |
942 | warnings::warnif('io', "my message 3") ; |
943 | warnings::warnif('all', "my message 4") ; |
114bafba |
944 | } |
945 | 1; |
946 | --FILE-- |
947 | use abc ; |
948 | use warnings 'abc'; |
949 | no warnings ; |
950 | BEGIN { $^W = 1 ; } |
951 | abc::check() ; |
952 | EXPECT |
953 | ok1 |
954 | ok2 |
955 | ok3 |
956 | ######## |
957 | |
958 | --FILE-- abc.pm |
959 | package abc ; |
960 | no warnings ; |
961 | use warnings::register ; |
962 | sub check { |
963 | print "ok1\n" if !warnings::enabled() ; |
964 | print "ok2\n" if !warnings::enabled("io") ; |
965 | print "ok3\n" if !warnings::enabled("all") ; |
966 | } |
967 | 1; |
968 | --FILE-- |
969 | use abc ; |
970 | use warnings 'abc'; |
971 | no warnings ; |
972 | $^W = 1 ; |
973 | abc::check() ; |
974 | EXPECT |
975 | ok1 |
976 | ok2 |
977 | ok3 |
7e6d00f8 |
978 | ######## |
979 | |
980 | --FILE-- abc.pm |
a781f7c3 |
981 | $| = 1; |
7e6d00f8 |
982 | package abc ; |
983 | no warnings ; |
984 | use warnings::register ; |
985 | sub check { |
986 | print "ok1\n" if warnings::enabled() ; |
987 | print "ok2\n" if !warnings::enabled("io") ; |
988 | print "ok3\n" if !warnings::enabled("all") ; |
989 | print "ok4\n" if warnings::enabled("abc") ; |
990 | warnings::warn("my message 1") ; |
991 | warnings::warnif("my message 2") ; |
992 | warnings::warnif('abc', "my message 3") ; |
993 | warnings::warnif('io', "my message 4") ; |
994 | warnings::warnif('all', "my message 5") ; |
995 | } |
996 | sub in2 { no warnings ; check() } |
997 | sub in1 { no warnings ; in2() } |
998 | 1; |
999 | --FILE-- |
1000 | use abc ; |
1001 | use warnings 'abc'; |
1002 | abc::in1() ; |
1003 | EXPECT |
7e6d00f8 |
1004 | ok1 |
1005 | ok2 |
1006 | ok3 |
1007 | ok4 |
a781f7c3 |
1008 | my message 1 at - line 3 |
1009 | my message 2 at - line 3 |
1010 | my message 3 at - line 3 |
7e6d00f8 |
1011 | ######## |
1012 | |
1013 | --FILE-- def.pm |
1014 | package def ; |
1015 | no warnings ; |
1016 | use warnings::register ; |
1017 | sub check { |
1018 | print "ok1\n" if warnings::enabled() ; |
1019 | print "ok2\n" if !warnings::enabled("io") ; |
1020 | print "ok3\n" if !warnings::enabled("all") ; |
1021 | print "ok4\n" if warnings::enabled("def") ; |
1022 | warnings::warn("my message 1") ; |
1023 | warnings::warnif("my message 2") ; |
1024 | warnings::warnif('def', "my message 3") ; |
1025 | warnings::warnif('io', "my message 4") ; |
1026 | warnings::warnif('all', "my message 5") ; |
1027 | } |
1028 | sub in2 { no warnings ; check() } |
1029 | sub in1 { no warnings ; in2() } |
1030 | 1; |
1031 | --FILE-- abc.pm |
a781f7c3 |
1032 | $| = 1; |
7e6d00f8 |
1033 | package abc ; |
1034 | use def ; |
1035 | use warnings 'def'; |
1036 | sub in1 { def::in1() ; } |
1037 | 1; |
1038 | --FILE-- |
1039 | use abc ; |
1040 | no warnings; |
1041 | abc::in1() ; |
1042 | EXPECT |
7e6d00f8 |
1043 | ok1 |
1044 | ok2 |
1045 | ok3 |
1046 | ok4 |
a781f7c3 |
1047 | my message 1 at abc.pm line 5 |
a781f7c3 |
1048 | my message 2 at abc.pm line 5 |
a781f7c3 |
1049 | my message 3 at abc.pm line 5 |
7e6d00f8 |
1050 | ######## |
1051 | |
1052 | --FILE-- def.pm |
a781f7c3 |
1053 | $| = 1; |
7e6d00f8 |
1054 | package def ; |
1055 | no warnings ; |
1056 | use warnings::register ; |
1057 | require Exporter; |
1058 | @ISA = qw( Exporter ) ; |
1059 | @EXPORT = qw( in1 ) ; |
1060 | sub check { |
1061 | print "ok1\n" if warnings::enabled() ; |
1062 | print "ok2\n" if !warnings::enabled("io") ; |
1063 | print "ok3\n" if !warnings::enabled("all") ; |
1064 | print "ok4\n" if warnings::enabled("abc") ; |
1065 | print "ok5\n" if !warnings::enabled("def") ; |
1066 | warnings::warn("my message 1") ; |
1067 | warnings::warnif("my message 2") ; |
1068 | warnings::warnif('abc', "my message 3") ; |
1069 | warnings::warnif('def', "my message 4") ; |
1070 | warnings::warnif('io', "my message 5") ; |
1071 | warnings::warnif('all', "my message 6") ; |
1072 | } |
1073 | sub in2 { no warnings ; check() } |
1074 | sub in1 { no warnings ; in2() } |
1075 | 1; |
1076 | --FILE-- abc.pm |
1077 | package abc ; |
1078 | use warnings::register ; |
1079 | use def ; |
1080 | #@ISA = qw(def) ; |
1081 | 1; |
1082 | --FILE-- |
1083 | use abc ; |
1084 | no warnings; |
1085 | use warnings 'abc'; |
1086 | abc::in1() ; |
1087 | EXPECT |
7e6d00f8 |
1088 | ok2 |
1089 | ok3 |
1090 | ok4 |
1091 | ok5 |
a781f7c3 |
1092 | my message 1 at - line 4 |
1093 | my message 3 at - line 4 |
7e6d00f8 |
1094 | ######## |
1095 | |
1096 | --FILE-- def.pm |
1097 | package def ; |
1098 | no warnings ; |
1099 | use warnings::register ; |
1100 | |
1101 | sub new |
1102 | { |
1103 | my $class = shift ; |
1104 | bless [], $class ; |
1105 | } |
1106 | |
1107 | sub check |
1108 | { |
1109 | my $self = shift ; |
1110 | print "ok1\n" if !warnings::enabled() ; |
1111 | print "ok2\n" if !warnings::enabled("io") ; |
1112 | print "ok3\n" if !warnings::enabled("all") ; |
1113 | print "ok4\n" if warnings::enabled("abc") ; |
1114 | print "ok5\n" if !warnings::enabled("def") ; |
1115 | print "ok6\n" if warnings::enabled($self) ; |
1116 | |
1117 | warnings::warn("my message 1") ; |
1118 | warnings::warn($self, "my message 2") ; |
1119 | |
1120 | warnings::warnif("my message 3") ; |
1121 | warnings::warnif('abc', "my message 4") ; |
1122 | warnings::warnif('def', "my message 5") ; |
1123 | warnings::warnif('io', "my message 6") ; |
1124 | warnings::warnif('all', "my message 7") ; |
1125 | warnings::warnif($self, "my message 8") ; |
1126 | } |
1127 | sub in2 |
1128 | { |
1129 | no warnings ; |
1130 | my $self = shift ; |
1131 | $self->check() ; |
1132 | } |
1133 | sub in1 |
1134 | { |
1135 | no warnings ; |
1136 | my $self = shift ; |
1137 | $self->in2(); |
1138 | } |
1139 | 1; |
1140 | --FILE-- abc.pm |
a781f7c3 |
1141 | $| = 1; |
7e6d00f8 |
1142 | package abc ; |
1143 | use warnings::register ; |
1144 | use def ; |
1145 | @ISA = qw(def) ; |
1146 | sub new |
1147 | { |
1148 | my $class = shift ; |
1149 | bless [], $class ; |
1150 | } |
1151 | |
1152 | 1; |
1153 | --FILE-- |
1154 | use abc ; |
1155 | no warnings; |
1156 | use warnings 'abc'; |
1157 | $a = new abc ; |
1158 | $a->in1() ; |
1159 | print "**\n"; |
1160 | $b = new def ; |
1161 | $b->in1() ; |
1162 | EXPECT |
7e6d00f8 |
1163 | ok1 |
1164 | ok2 |
1165 | ok3 |
1166 | ok4 |
1167 | ok5 |
1168 | ok6 |
a781f7c3 |
1169 | my message 1 at - line 5 |
1170 | my message 2 at - line 5 |
1171 | my message 4 at - line 5 |
1172 | my message 8 at - line 5 |
7e6d00f8 |
1173 | ** |
1174 | ok1 |
1175 | ok2 |
1176 | ok3 |
1177 | ok4 |
1178 | ok5 |
a781f7c3 |
1179 | my message 1 at - line 8 |
1180 | my message 2 at - line 8 |
1181 | my message 4 at - line 8 |
4f527b71 |
1182 | ######## |
1183 | |
1184 | --FILE-- |
1185 | # test for bug [perl #15395] |
1186 | my ( $warn_cat, # warning category we'll try to control |
1187 | $warn_msg, # the error message to catch |
1188 | ); |
1189 | |
1190 | package SomeModule; |
1191 | use warnings::register; |
1192 | |
1193 | BEGIN { |
1194 | $warn_cat = __PACKAGE__; |
1195 | $warn_msg = 'from ' . __PACKAGE__; |
1196 | } |
1197 | |
1198 | # a sub that generates a random warning |
1199 | sub gen_warning { |
1200 | warnings::warnif( $warn_msg ); |
1201 | } |
1202 | |
1203 | package ClientModule; |
1204 | # use SomeModule; (would go here) |
1205 | our @CARP_NOT = ( $warn_cat ); # deliver warnings to *our* client |
1206 | |
1207 | # call_warner provokes a warning. It is delivered to its caller, |
1208 | # who should also be able to control it |
1209 | sub call_warner { |
1210 | SomeModule::gen_warning(); |
1211 | } |
1212 | |
1213 | # user |
1214 | |
1215 | package main; |
1216 | my $warn_line = __LINE__ + 3; # this line should be in the error message |
1217 | eval { |
1218 | use warnings FATAL => $warn_cat; # we want to know if this works |
1219 | ClientModule::call_warner(); |
1220 | }; |
1221 | |
1222 | # have we caught an error, and is it the one we generated? |
1223 | print "ok1\n" if $@ =~ /$warn_msg/; |
1224 | |
1225 | # does it indicate the right line? |
1226 | print "ok2\n" if $@ =~ /line $warn_line/; |
1227 | EXPECT |
1228 | ok1 |
1229 | ok2 |