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') ; |
8d93267c |
50 | print "ok2\n" if warnings::enabled("syntax") ; |
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") ; |
64 | print "ok3\n" if warnings::enabled("io") ; |
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 |
154 | no warnings; |
155 | use abc ; |
156 | 1; |
157 | --FILE-- |
158 | use warnings; |
159 | use def ; |
160 | EXPECT |
161 | ok1 |
162 | ok2 |
163 | ######## |
164 | |
165 | --FILE-- abc.pm |
166 | package abc ; |
167 | no warnings ; |
d3a7d8c7 |
168 | print "ok1\n" if ! warnings::enabled('all') ; |
8d93267c |
169 | print "ok2\n" if warnings::enabled("syntax") ; |
170 | print "ok3\n" if !warnings::enabled("io") ; |
171 | 1; |
172 | --FILE-- def.pm |
173 | use warnings 'syntax' ; |
d3a7d8c7 |
174 | print "ok4\n" if !warnings::enabled('all') ; |
8d93267c |
175 | print "ok5\n" if warnings::enabled("io") ; |
176 | use abc ; |
177 | 1; |
178 | --FILE-- |
179 | use warnings 'io' ; |
180 | use def ; |
181 | EXPECT |
182 | ok1 |
183 | ok2 |
184 | ok3 |
185 | ok4 |
186 | ok5 |
187 | ######## |
188 | |
189 | --FILE-- abc.pm |
190 | package abc ; |
191 | no warnings ; |
192 | sub check { |
d3a7d8c7 |
193 | print "ok1\n" if !warnings::enabled('all') ; |
8d93267c |
194 | print "ok2\n" if warnings::enabled("syntax") ; |
195 | } |
196 | 1; |
197 | --FILE-- |
198 | use warnings 'syntax' ; |
199 | use abc ; |
200 | eval { abc::check() ; }; |
201 | print $@ ; |
202 | EXPECT |
203 | ok1 |
204 | ok2 |
205 | ######## |
206 | |
207 | --FILE-- abc.pm |
208 | package abc ; |
209 | use warnings 'io' ; |
210 | sub check { |
d3a7d8c7 |
211 | print "ok1\n" if ! warnings::enabled('all') ; |
212 | print "ok2\n" if warnings::enabled("syntax") ; |
8d93267c |
213 | print "ok3\n" if ! warnings::enabled("io") ; |
214 | } |
215 | 1; |
216 | --FILE-- |
217 | use warnings 'syntax' ; |
218 | use abc ; |
219 | eval { abc::check() ; } ; |
220 | print $@ ; |
221 | EXPECT |
222 | ok1 |
223 | ok2 |
224 | ok3 |
225 | ######## |
226 | |
227 | --FILE-- abc |
228 | package abc ; |
229 | no warnings ; |
230 | sub check { |
d3a7d8c7 |
231 | print "ok1\n" if !warnings::enabled('all') ; |
8d93267c |
232 | print "ok2\n" if warnings::enabled("syntax") ; |
233 | } |
234 | 1; |
235 | --FILE-- |
236 | use warnings 'syntax' ; |
237 | require "abc" ; |
238 | eval { abc::check() ; } ; |
239 | print $@ ; |
240 | EXPECT |
241 | ok1 |
242 | ok2 |
243 | ######## |
244 | |
245 | --FILE-- abc |
246 | package abc ; |
247 | use warnings 'io' ; |
248 | sub check { |
d3a7d8c7 |
249 | print "ok1\n" if !warnings::enabled('all') ; |
8d93267c |
250 | print "ok2\n" if warnings::enabled("syntax") ; |
251 | print "ok3\n" if warnings::enabled("io") ; |
252 | } |
253 | 1; |
254 | --FILE-- |
255 | use warnings 'syntax' ; |
256 | require "abc" ; |
257 | eval { use warnings 'io' ; abc::check() ; }; |
258 | abc::check() ; |
259 | print $@ ; |
260 | EXPECT |
261 | ok1 |
262 | ok2 |
263 | ok3 |
264 | ok1 |
265 | ok2 |
266 | ######## |
267 | |
268 | --FILE-- abc.pm |
269 | package abc ; |
270 | use warnings 'io' ; |
271 | sub check { |
d3a7d8c7 |
272 | print "ok1\n" if ! warnings::enabled('all') ; |
8d93267c |
273 | print "ok2\n" if warnings::enabled("syntax") ; |
274 | print "ok3\n" if ! warnings::enabled("io") ; |
275 | } |
276 | 1; |
277 | --FILE-- |
278 | use warnings 'syntax' ; |
279 | use abc ; |
280 | sub fred { abc::check() } |
281 | fred() ; |
282 | EXPECT |
283 | ok1 |
284 | ok2 |
285 | ok3 |
286 | ######## |
287 | |
288 | --FILE-- abc.pm |
289 | package abc ; |
290 | use warnings 'io' ; |
291 | sub check { |
d3a7d8c7 |
292 | print "ok1\n" if ! warnings::enabled('all') ; |
8d93267c |
293 | } |
294 | 1; |
295 | --FILE-- |
296 | use warnings 'syntax' ; |
297 | use abc ; |
298 | sub fred { no warnings ; abc::check() } |
299 | fred() ; |
300 | EXPECT |
301 | ok1 |
302 | ######## |
303 | |
304 | --FILE-- abc.pm |
305 | package abc ; |
306 | use warnings 'misc' ; |
307 | sub check { |
d3a7d8c7 |
308 | print "ok1\n" if ! warnings::enabled('all') ; |
8d93267c |
309 | print "ok2\n" if warnings::enabled("syntax") ; |
310 | print "ok3\n" if warnings::enabled("io") ; |
311 | print "ok4\n" if ! warnings::enabled("misc") ; |
312 | } |
313 | 1; |
314 | --FILE-- |
315 | use warnings 'syntax' ; |
316 | use abc ; |
317 | sub fred { use warnings 'io' ; abc::check() } |
318 | fred() ; |
319 | EXPECT |
320 | ok1 |
321 | ok2 |
322 | ok3 |
323 | ok4 |
324 | ######## |
325 | |
326 | # check warnings::warn |
327 | use warnings ; |
328 | eval { warnings::warn() } ; |
329 | print $@ ; |
d3a7d8c7 |
330 | eval { warnings::warn("fred", "joe") } ; |
8d93267c |
331 | print $@ ; |
332 | EXPECT |
d3a7d8c7 |
333 | Usage: warnings::warn([category,] 'message') at - line 4 |
334 | unknown warnings category 'fred' at - line 6 |
7e6d00f8 |
335 | ######## |
336 | |
337 | # check warnings::warnif |
338 | use warnings ; |
339 | eval { warnings::warnif() } ; |
340 | print $@ ; |
341 | eval { warnings::warnif("fred", "joe") } ; |
342 | print $@ ; |
343 | EXPECT |
344 | Usage: warnings::warnif([category,] 'message') at - line 4 |
345 | unknown warnings category 'fred' at - line 6 |
8d93267c |
346 | ######## |
347 | |
348 | --FILE-- abc.pm |
349 | package abc ; |
350 | use warnings 'misc' ; |
351 | sub check { warnings::warn("io", "hello") } |
352 | 1; |
353 | --FILE-- |
354 | use warnings "io" ; |
355 | use abc; |
356 | abc::check() ; |
357 | EXPECT |
358 | hello at - line 3 |
359 | ######## |
360 | |
361 | --FILE-- abc.pm |
362 | package abc ; |
363 | use warnings 'misc' ; |
364 | sub check { warnings::warn("misc", "hello") } |
365 | 1; |
366 | --FILE-- |
367 | use warnings "io" ; |
368 | use abc; |
369 | abc::check() ; |
370 | EXPECT |
371 | hello at - line 3 |
372 | ######## |
373 | |
374 | --FILE-- abc.pm |
375 | package abc ; |
376 | use warnings 'misc' ; |
377 | sub check { warnings::warn("io", "hello") } |
378 | 1; |
379 | --FILE-- |
380 | use warnings qw( FATAL deprecated ) ; |
381 | use abc; |
382 | eval { abc::check() ; } ; |
383 | print "[[$@]]\n"; |
384 | EXPECT |
385 | hello at - line 3 |
7e6d00f8 |
386 | eval {...} called at - line 3 |
8d93267c |
387 | [[]] |
388 | ######## |
389 | |
390 | --FILE-- abc.pm |
391 | package abc ; |
392 | use warnings 'misc' ; |
393 | sub check { warnings::warn("io", "hello") } |
394 | 1; |
395 | --FILE-- |
396 | use warnings qw( FATAL io ) ; |
397 | use abc; |
398 | eval { abc::check() ; } ; |
399 | print "[[$@]]\n"; |
400 | EXPECT |
401 | [[hello at - line 3 |
7e6d00f8 |
402 | eval {...} called at - line 3 |
8d93267c |
403 | ]] |
d3a7d8c7 |
404 | ######## |
405 | -W |
406 | --FILE-- abc.pm |
407 | package abc ; |
408 | use warnings "io" ; |
409 | print "ok1\n" if warnings::enabled("io") ; |
410 | print "ok2\n" if warnings::enabled("all") ; |
411 | 1; |
412 | --FILE-- |
413 | no warnings; |
414 | use abc ; |
415 | EXPECT |
416 | ok1 |
417 | ok2 |
418 | ######## |
419 | -X |
420 | --FILE-- abc.pm |
421 | package abc ; |
422 | use warnings "io" ; |
423 | print "ok1\n" if !warnings::enabled("io") ; |
424 | print "ok2\n" if !warnings::enabled("all") ; |
425 | 1; |
426 | --FILE-- |
427 | use warnings; |
428 | use abc ; |
429 | EXPECT |
430 | ok1 |
431 | ok2 |
432 | ######## |
433 | |
434 | --FILE-- abc.pm |
435 | package abc ; |
436 | no warnings ; |
437 | sub check { |
438 | print "ok\n" if ! warnings::enabled() ; |
439 | } |
440 | 1; |
441 | --FILE-- |
442 | use warnings 'syntax' ; |
443 | use abc ; |
444 | abc::check() ; |
445 | EXPECT |
7e6d00f8 |
446 | package 'abc' not registered for warnings at abc.pm line 4 |
447 | ######## |
448 | |
449 | --FILE-- abc.pm |
450 | package abc ; |
451 | no warnings ; |
452 | sub check { |
453 | warnings::warn("fred") ; |
454 | } |
455 | 1; |
456 | --FILE-- |
457 | use warnings 'syntax' ; |
458 | use abc ; |
459 | abc::check() ; |
460 | EXPECT |
461 | package 'abc' not registered for warnings at abc.pm line 4 |
462 | ######## |
463 | |
464 | --FILE-- abc.pm |
465 | package abc ; |
466 | no warnings ; |
467 | sub check { |
468 | warnings::warnif("fred") ; |
469 | } |
470 | 1; |
471 | --FILE-- |
472 | use warnings 'syntax' ; |
473 | use abc ; |
474 | abc::check() ; |
475 | EXPECT |
476 | package 'abc' not registered for warnings at abc.pm line 4 |
d3a7d8c7 |
477 | ######## |
478 | |
479 | --FILE-- abc.pm |
480 | package abc ; |
481 | use warnings 'io' ; |
482 | use warnings::register ; |
483 | sub check { |
484 | print "ok1\n" if warnings::enabled ; |
485 | print "ok2\n" if warnings::enabled("syntax") ; |
486 | print "ok3\n" if !warnings::enabled("io") ; |
487 | } |
488 | 1; |
489 | --FILE-- |
490 | use warnings 'syntax' ; |
491 | use abc ; |
492 | use warnings 'abc' ; |
493 | abc::check() ; |
494 | EXPECT |
495 | ok1 |
496 | ok2 |
497 | ok3 |
498 | ######## |
499 | |
500 | --FILE-- abc.pm |
501 | package abc ; |
502 | use warnings 'io' ; |
503 | use warnings::register ; |
504 | sub check { |
505 | print "ok1\n" if !warnings::enabled ; |
506 | print "ok2\n" if warnings::enabled("syntax") ; |
507 | print "ok3\n" if !warnings::enabled("io") ; |
508 | } |
509 | 1; |
510 | --FILE-- |
511 | use warnings 'syntax' ; |
512 | use abc ; |
513 | abc::check() ; |
514 | EXPECT |
515 | ok1 |
516 | ok2 |
517 | ok3 |
518 | ######## |
519 | |
520 | --FILE-- abc.pm |
521 | package abc ; |
522 | no warnings ; |
523 | use warnings::register ; |
524 | sub check { |
525 | print "ok1\n" if warnings::enabled ; |
526 | print "ok2\n" if warnings::enabled("syntax") ; |
527 | } |
528 | 1; |
529 | --FILE-- |
530 | use warnings 'syntax' ; |
531 | use abc ; |
532 | use warnings 'abc' ; |
533 | eval { abc::check() ; }; |
534 | print $@ ; |
535 | EXPECT |
536 | ok1 |
537 | ok2 |
538 | ######## |
539 | |
540 | --FILE-- abc.pm |
541 | package abc ; |
542 | use warnings 'io' ; |
543 | use warnings::register ; |
544 | sub check { |
545 | print "ok1\n" if !warnings::enabled ; |
546 | print "ok2\n" if warnings::enabled("syntax") ; |
547 | print "ok3\n" if !warnings::enabled("io") ; |
548 | } |
549 | 1; |
550 | --FILE-- |
551 | use warnings 'syntax' ; |
552 | use abc ; |
553 | eval { abc::check() ; } ; |
554 | print $@ ; |
555 | EXPECT |
556 | ok1 |
557 | ok2 |
558 | ok3 |
559 | ######## |
560 | |
561 | --FILE-- abc.pm |
562 | package abc ; |
563 | use warnings 'io' ; |
564 | use warnings::register ; |
565 | sub check { |
566 | print "ok1\n" if warnings::enabled ; |
567 | print "ok2\n" if warnings::enabled("syntax") ; |
568 | print "ok3\n" if !warnings::enabled("io") ; |
569 | } |
570 | 1; |
571 | --FILE-- |
572 | use warnings 'syntax' ; |
573 | use abc ; |
574 | use warnings 'abc' ; |
575 | sub fred { abc::check() } |
576 | fred() ; |
577 | EXPECT |
578 | ok1 |
579 | ok2 |
580 | ok3 |
581 | ######## |
582 | |
583 | --FILE-- abc.pm |
584 | package abc ; |
585 | use warnings 'io' ; |
586 | use warnings::register ; |
587 | sub check { |
588 | print "ok1\n" if ! warnings::enabled ; |
589 | } |
590 | 1; |
591 | --FILE-- |
592 | use warnings 'syntax' ; |
593 | use abc ; |
594 | sub fred { no warnings ; abc::check() } |
595 | fred() ; |
596 | EXPECT |
597 | ok1 |
598 | ######## |
599 | |
600 | --FILE-- abc.pm |
601 | package abc ; |
602 | use warnings 'misc' ; |
603 | use warnings::register; |
604 | sub check { |
605 | print "ok1\n" if warnings::enabled ; |
606 | print "ok2\n" if warnings::enabled("syntax") ; |
607 | print "ok3\n" if warnings::enabled("io") ; |
608 | print "ok4\n" if ! warnings::enabled("misc") ; |
609 | } |
610 | 1; |
611 | --FILE-- |
612 | use warnings 'syntax' ; |
613 | use abc ; |
614 | use warnings 'abc' ; |
615 | sub fred { use warnings 'io' ; abc::check() } |
616 | fred() ; |
617 | EXPECT |
618 | ok1 |
619 | ok2 |
620 | ok3 |
621 | ok4 |
622 | ######## |
623 | |
624 | --FILE-- abc.pm |
625 | package abc ; |
626 | use warnings 'misc' ; |
627 | use warnings::register; |
628 | sub check { warnings::warn("hello") } |
629 | 1; |
630 | --FILE-- |
631 | use abc; |
632 | use warnings "abc" ; |
633 | abc::check() ; |
634 | EXPECT |
635 | hello at - line 3 |
636 | ######## |
637 | |
638 | --FILE-- abc.pm |
639 | package abc ; |
640 | use warnings::register; |
641 | sub check { warnings::warn("hello") } |
642 | 1; |
643 | --FILE-- |
644 | use abc; |
645 | abc::check() ; |
646 | EXPECT |
647 | hello at - line 2 |
648 | ######## |
649 | |
650 | --FILE-- abc.pm |
651 | package abc ; |
652 | use warnings::register ; |
653 | sub check { warnings::warn("hello") } |
654 | 1; |
655 | --FILE-- |
656 | use abc; |
657 | use warnings qw( FATAL deprecated ) ; |
658 | eval { abc::check() ; } ; |
659 | print "[[$@]]\n"; |
660 | EXPECT |
661 | hello at - line 3 |
7e6d00f8 |
662 | eval {...} called at - line 3 |
d3a7d8c7 |
663 | [[]] |
664 | ######## |
665 | |
666 | --FILE-- abc.pm |
667 | package abc ; |
668 | use warnings::register ; |
669 | sub check { warnings::warn("hello") } |
670 | 1; |
671 | --FILE-- |
672 | use abc; |
673 | use warnings qw( FATAL abc ) ; |
674 | eval { abc::check() ; } ; |
675 | print "[[$@]]\n"; |
676 | EXPECT |
677 | [[hello at - line 3 |
7e6d00f8 |
678 | eval {...} called at - line 3 |
d3a7d8c7 |
679 | ]] |
680 | ######## |
681 | -W |
682 | --FILE-- abc.pm |
683 | package abc ; |
684 | use warnings "io" ; |
685 | use warnings::register ; |
686 | sub check { |
687 | print "ok1\n" if warnings::enabled() ; |
688 | print "ok2\n" if warnings::enabled("io") ; |
689 | print "ok3\n" if warnings::enabled("all") ; |
690 | } |
691 | 1; |
692 | --FILE-- |
693 | no warnings; |
694 | use abc ; |
695 | abc::check() ; |
696 | EXPECT |
697 | ok1 |
698 | ok2 |
699 | ok3 |
700 | ######## |
701 | -X |
702 | --FILE-- abc.pm |
703 | package abc ; |
704 | use warnings "io" ; |
705 | use warnings::register ; |
706 | sub check { |
707 | print "ok1\n" if !warnings::enabled() ; |
708 | print "ok2\n" if !warnings::enabled("io") ; |
709 | print "ok3\n" if !warnings::enabled("all") ; |
710 | } |
711 | 1; |
712 | --FILE-- |
713 | no warnings; |
714 | use abc ; |
715 | abc::check() ; |
716 | EXPECT |
717 | ok1 |
718 | ok2 |
719 | ok3 |
720 | ######## |
721 | |
722 | --FILE-- abc.pm |
723 | package abc ; |
724 | use warnings "io" ; |
725 | use warnings::register ; |
726 | sub check { |
727 | print "ok1\n" if warnings::enabled() ; |
728 | print "ok2\n" if warnings::enabled("io") ; |
729 | print "ok3\n" if warnings::enabled("all") ; |
730 | } |
731 | 1; |
732 | --FILE-- |
733 | use warnings 'all'; |
734 | use abc ; |
735 | abc::check() ; |
736 | EXPECT |
737 | ok1 |
738 | ok2 |
739 | ok3 |
740 | ######## |
741 | |
742 | --FILE-- abc.pm |
743 | package abc ; |
744 | use warnings "io" ; |
745 | use warnings::register ; |
746 | sub check { |
747 | print "ok1\n" if !warnings::enabled() ; |
748 | print "ok2\n" if !warnings::enabled("io") ; |
749 | print "ok3\n" if !warnings::enabled("all") ; |
750 | } |
751 | 1; |
752 | --FILE-- |
753 | use abc ; |
754 | no warnings ; |
755 | abc::check() ; |
756 | EXPECT |
757 | ok1 |
758 | ok2 |
759 | ok3 |
760 | ######## |
761 | |
762 | --FILE-- abc.pm |
763 | package abc ; |
764 | use warnings "io" ; |
765 | use warnings::register ; |
766 | sub check { |
767 | print "ok1\n" if !warnings::enabled() ; |
768 | print "ok2\n" if !warnings::enabled("io") ; |
769 | print "ok3\n" if !warnings::enabled("all") ; |
7e6d00f8 |
770 | warnings::warnif("my message 1") ; |
771 | warnings::warnif('abc', "my message 2") ; |
772 | warnings::warnif('io', "my message 3") ; |
773 | warnings::warnif('all', "my message 4") ; |
d3a7d8c7 |
774 | } |
775 | 1; |
776 | --FILE-- |
777 | use abc ; |
778 | use warnings 'abc'; |
779 | no warnings ; |
780 | abc::check() ; |
781 | EXPECT |
782 | ok1 |
783 | ok2 |
784 | ok3 |
785 | ######## |
786 | |
787 | --FILE-- abc.pm |
788 | package abc ; |
789 | use warnings "io" ; |
790 | use warnings::register ; |
791 | sub check { |
792 | print "abc self" . (warnings::enabled() ? "" : " not") . " enabled\n" ; |
793 | print "abc def" . (warnings::enabled('def') ? "" : " not") . " enabled\n" ; |
794 | print "abc all" . (warnings::enabled('all') ? "" : " not") . " enabled\n" ; |
795 | } |
796 | 1; |
797 | --FILE-- def.pm |
798 | package def ; |
799 | use warnings "io" ; |
800 | use warnings::register ; |
801 | sub check { |
802 | print "def self" . (warnings::enabled() ? "" : " not") . " enabled\n" ; |
803 | print "def abc" . (warnings::enabled('abc') ? "" : " not") . " enabled\n" ; |
804 | print "def all" . (warnings::enabled('all') ? "" : " not") . " enabled\n" ; |
805 | } |
806 | 1; |
807 | --FILE-- |
808 | use abc ; |
809 | use def ; |
810 | use warnings 'abc'; |
811 | abc::check() ; |
812 | def::check() ; |
813 | no warnings 'abc' ; |
814 | use warnings 'def' ; |
815 | abc::check() ; |
816 | def::check() ; |
817 | use warnings 'abc' ; |
818 | use warnings 'def' ; |
819 | abc::check() ; |
820 | def::check() ; |
821 | no warnings 'abc' ; |
822 | no warnings 'def' ; |
823 | abc::check() ; |
824 | def::check() ; |
825 | use warnings; |
826 | abc::check() ; |
827 | def::check() ; |
828 | no warnings 'abc' ; |
829 | abc::check() ; |
830 | def::check() ; |
831 | EXPECT |
832 | abc self enabled |
833 | abc def not enabled |
834 | abc all not enabled |
835 | def self not enabled |
836 | def abc enabled |
837 | def all not enabled |
838 | abc self not enabled |
839 | abc def enabled |
840 | abc all not enabled |
841 | def self enabled |
842 | def abc not enabled |
843 | def all not enabled |
844 | abc self enabled |
845 | abc def enabled |
846 | abc all not enabled |
847 | def self enabled |
848 | def abc enabled |
849 | def all not enabled |
850 | abc self not enabled |
851 | abc def not enabled |
852 | abc all not enabled |
853 | def self not enabled |
854 | def abc not enabled |
855 | def all not enabled |
856 | abc self enabled |
857 | abc def enabled |
858 | abc all enabled |
859 | def self enabled |
860 | def abc enabled |
861 | def all enabled |
862 | abc self not enabled |
863 | abc def enabled |
864 | abc all not enabled |
865 | def self enabled |
866 | def abc not enabled |
867 | def all not enabled |
114bafba |
868 | ######## |
869 | -w |
870 | --FILE-- abc.pm |
871 | package abc ; |
872 | no warnings ; |
873 | use warnings::register ; |
874 | sub check { |
875 | print "ok1\n" if warnings::enabled() ; |
876 | print "ok2\n" if warnings::enabled("io") ; |
877 | print "ok3\n" if warnings::enabled("all") ; |
878 | } |
879 | 1; |
880 | --FILE-- |
881 | use abc ; |
882 | abc::check() ; |
883 | EXPECT |
884 | ok1 |
885 | ok2 |
886 | ok3 |
887 | ######## |
888 | -w |
889 | --FILE-- abc.pm |
890 | package abc ; |
891 | no warnings ; |
892 | use warnings::register ; |
893 | sub check { |
894 | print "ok1\n" if !warnings::enabled() ; |
895 | print "ok2\n" if !warnings::enabled("io") ; |
896 | print "ok3\n" if !warnings::enabled("all") ; |
897 | } |
898 | 1; |
899 | --FILE-- |
900 | use abc ; |
901 | use warnings 'abc'; |
902 | no warnings ; |
903 | abc::check() ; |
904 | EXPECT |
905 | ok1 |
906 | ok2 |
907 | ok3 |
908 | ######## |
909 | |
910 | --FILE-- abc.pm |
911 | package abc ; |
912 | no warnings ; |
913 | use warnings::register ; |
914 | sub check { |
915 | print "ok1\n" if !warnings::enabled() ; |
916 | print "ok2\n" if !warnings::enabled("io") ; |
917 | print "ok3\n" if !warnings::enabled("all") ; |
7e6d00f8 |
918 | warnings::warnif("my message 1") ; |
919 | warnings::warnif('abc', "my message 2") ; |
920 | warnings::warnif('io', "my message 3") ; |
921 | warnings::warnif('all', "my message 4") ; |
114bafba |
922 | } |
923 | 1; |
924 | --FILE-- |
925 | use abc ; |
926 | use warnings 'abc'; |
927 | no warnings ; |
928 | BEGIN { $^W = 1 ; } |
929 | abc::check() ; |
930 | EXPECT |
931 | ok1 |
932 | ok2 |
933 | ok3 |
934 | ######## |
935 | |
936 | --FILE-- abc.pm |
937 | package abc ; |
938 | no warnings ; |
939 | use warnings::register ; |
940 | sub check { |
941 | print "ok1\n" if !warnings::enabled() ; |
942 | print "ok2\n" if !warnings::enabled("io") ; |
943 | print "ok3\n" if !warnings::enabled("all") ; |
944 | } |
945 | 1; |
946 | --FILE-- |
947 | use abc ; |
948 | use warnings 'abc'; |
949 | no warnings ; |
950 | $^W = 1 ; |
951 | abc::check() ; |
952 | EXPECT |
953 | ok1 |
954 | ok2 |
955 | ok3 |
7e6d00f8 |
956 | ######## |
957 | |
958 | --FILE-- abc.pm |
a781f7c3 |
959 | $| = 1; |
7e6d00f8 |
960 | package abc ; |
961 | no warnings ; |
962 | use warnings::register ; |
963 | sub check { |
964 | print "ok1\n" if warnings::enabled() ; |
965 | print "ok2\n" if !warnings::enabled("io") ; |
966 | print "ok3\n" if !warnings::enabled("all") ; |
967 | print "ok4\n" if warnings::enabled("abc") ; |
968 | warnings::warn("my message 1") ; |
969 | warnings::warnif("my message 2") ; |
970 | warnings::warnif('abc', "my message 3") ; |
971 | warnings::warnif('io', "my message 4") ; |
972 | warnings::warnif('all', "my message 5") ; |
973 | } |
974 | sub in2 { no warnings ; check() } |
975 | sub in1 { no warnings ; in2() } |
976 | 1; |
977 | --FILE-- |
978 | use abc ; |
979 | use warnings 'abc'; |
980 | abc::in1() ; |
981 | EXPECT |
7e6d00f8 |
982 | ok1 |
983 | ok2 |
984 | ok3 |
985 | ok4 |
a781f7c3 |
986 | my message 1 at - line 3 |
987 | my message 2 at - line 3 |
988 | my message 3 at - line 3 |
7e6d00f8 |
989 | ######## |
990 | |
991 | --FILE-- def.pm |
992 | package def ; |
993 | no warnings ; |
994 | use warnings::register ; |
995 | sub check { |
996 | print "ok1\n" if warnings::enabled() ; |
997 | print "ok2\n" if !warnings::enabled("io") ; |
998 | print "ok3\n" if !warnings::enabled("all") ; |
999 | print "ok4\n" if warnings::enabled("def") ; |
1000 | warnings::warn("my message 1") ; |
1001 | warnings::warnif("my message 2") ; |
1002 | warnings::warnif('def', "my message 3") ; |
1003 | warnings::warnif('io', "my message 4") ; |
1004 | warnings::warnif('all', "my message 5") ; |
1005 | } |
1006 | sub in2 { no warnings ; check() } |
1007 | sub in1 { no warnings ; in2() } |
1008 | 1; |
1009 | --FILE-- abc.pm |
a781f7c3 |
1010 | $| = 1; |
7e6d00f8 |
1011 | package abc ; |
1012 | use def ; |
1013 | use warnings 'def'; |
1014 | sub in1 { def::in1() ; } |
1015 | 1; |
1016 | --FILE-- |
1017 | use abc ; |
1018 | no warnings; |
1019 | abc::in1() ; |
1020 | EXPECT |
7e6d00f8 |
1021 | ok1 |
1022 | ok2 |
1023 | ok3 |
1024 | ok4 |
a781f7c3 |
1025 | my message 1 at abc.pm line 5 |
1026 | abc::in1() called at - line 3 |
1027 | my message 2 at abc.pm line 5 |
1028 | abc::in1() called at - line 3 |
1029 | my message 3 at abc.pm line 5 |
1030 | abc::in1() called at - line 3 |
7e6d00f8 |
1031 | ######## |
1032 | |
1033 | --FILE-- def.pm |
a781f7c3 |
1034 | $| = 1; |
7e6d00f8 |
1035 | package def ; |
1036 | no warnings ; |
1037 | use warnings::register ; |
1038 | require Exporter; |
1039 | @ISA = qw( Exporter ) ; |
1040 | @EXPORT = qw( in1 ) ; |
1041 | sub check { |
1042 | print "ok1\n" if warnings::enabled() ; |
1043 | print "ok2\n" if !warnings::enabled("io") ; |
1044 | print "ok3\n" if !warnings::enabled("all") ; |
1045 | print "ok4\n" if warnings::enabled("abc") ; |
1046 | print "ok5\n" if !warnings::enabled("def") ; |
1047 | warnings::warn("my message 1") ; |
1048 | warnings::warnif("my message 2") ; |
1049 | warnings::warnif('abc', "my message 3") ; |
1050 | warnings::warnif('def', "my message 4") ; |
1051 | warnings::warnif('io', "my message 5") ; |
1052 | warnings::warnif('all', "my message 6") ; |
1053 | } |
1054 | sub in2 { no warnings ; check() } |
1055 | sub in1 { no warnings ; in2() } |
1056 | 1; |
1057 | --FILE-- abc.pm |
1058 | package abc ; |
1059 | use warnings::register ; |
1060 | use def ; |
1061 | #@ISA = qw(def) ; |
1062 | 1; |
1063 | --FILE-- |
1064 | use abc ; |
1065 | no warnings; |
1066 | use warnings 'abc'; |
1067 | abc::in1() ; |
1068 | EXPECT |
7e6d00f8 |
1069 | ok2 |
1070 | ok3 |
1071 | ok4 |
1072 | ok5 |
a781f7c3 |
1073 | my message 1 at - line 4 |
1074 | my message 3 at - line 4 |
7e6d00f8 |
1075 | ######## |
1076 | |
1077 | --FILE-- def.pm |
1078 | package def ; |
1079 | no warnings ; |
1080 | use warnings::register ; |
1081 | |
1082 | sub new |
1083 | { |
1084 | my $class = shift ; |
1085 | bless [], $class ; |
1086 | } |
1087 | |
1088 | sub check |
1089 | { |
1090 | my $self = shift ; |
1091 | print "ok1\n" if !warnings::enabled() ; |
1092 | print "ok2\n" if !warnings::enabled("io") ; |
1093 | print "ok3\n" if !warnings::enabled("all") ; |
1094 | print "ok4\n" if warnings::enabled("abc") ; |
1095 | print "ok5\n" if !warnings::enabled("def") ; |
1096 | print "ok6\n" if warnings::enabled($self) ; |
1097 | |
1098 | warnings::warn("my message 1") ; |
1099 | warnings::warn($self, "my message 2") ; |
1100 | |
1101 | warnings::warnif("my message 3") ; |
1102 | warnings::warnif('abc', "my message 4") ; |
1103 | warnings::warnif('def', "my message 5") ; |
1104 | warnings::warnif('io', "my message 6") ; |
1105 | warnings::warnif('all', "my message 7") ; |
1106 | warnings::warnif($self, "my message 8") ; |
1107 | } |
1108 | sub in2 |
1109 | { |
1110 | no warnings ; |
1111 | my $self = shift ; |
1112 | $self->check() ; |
1113 | } |
1114 | sub in1 |
1115 | { |
1116 | no warnings ; |
1117 | my $self = shift ; |
1118 | $self->in2(); |
1119 | } |
1120 | 1; |
1121 | --FILE-- abc.pm |
a781f7c3 |
1122 | $| = 1; |
7e6d00f8 |
1123 | package abc ; |
1124 | use warnings::register ; |
1125 | use def ; |
1126 | @ISA = qw(def) ; |
1127 | sub new |
1128 | { |
1129 | my $class = shift ; |
1130 | bless [], $class ; |
1131 | } |
1132 | |
1133 | 1; |
1134 | --FILE-- |
1135 | use abc ; |
1136 | no warnings; |
1137 | use warnings 'abc'; |
1138 | $a = new abc ; |
1139 | $a->in1() ; |
1140 | print "**\n"; |
1141 | $b = new def ; |
1142 | $b->in1() ; |
1143 | EXPECT |
7e6d00f8 |
1144 | ok1 |
1145 | ok2 |
1146 | ok3 |
1147 | ok4 |
1148 | ok5 |
1149 | ok6 |
a781f7c3 |
1150 | my message 1 at - line 5 |
1151 | my message 2 at - line 5 |
1152 | my message 4 at - line 5 |
1153 | my message 8 at - line 5 |
7e6d00f8 |
1154 | ** |
1155 | ok1 |
1156 | ok2 |
1157 | ok3 |
1158 | ok4 |
1159 | ok5 |
a781f7c3 |
1160 | my message 1 at - line 8 |
1161 | my message 2 at - line 8 |
1162 | my message 4 at - line 8 |