1 Check warnings::enabled & warnings::warn
8 print "ok1\n" if ! warnings::enabled('all') ;
9 print "ok2\n" if ! warnings::enabled("io") ;
22 print "ok1\n" if !warnings::enabled('all') ;
23 print "ok2\n" if warnings::enabled("syntax") ;
26 use warnings 'syntax' ;
35 use warnings 'syntax' ;
36 print "ok1\n" if warnings::enabled('io') ;
37 print "ok2\n" if ! warnings::enabled("syntax") ;
49 print "ok1\n" if !warnings::enabled('all') ;
50 print "ok2\n" if warnings::enabled("syntax") ;
53 use warnings 'syntax' ;
61 use warnings 'syntax' ;
62 print "ok1\n" if ! warnings::enabled('all') ;
63 print "ok2\n" if ! warnings::enabled("syntax") ;
64 print "ok3\n" if warnings::enabled("io") ;
79 print "ok1\n" if !warnings::enabled('all') ;
80 print "ok2\n" if warnings::enabled("syntax") ;
84 use warnings 'syntax' ;
96 print "ok1\n" if ! warnings::enabled('all') ;
97 print "ok2\n" if warnings::enabled("syntax") ;
98 print "ok3\n" if ! warnings::enabled("io") ;
102 use warnings 'syntax' ;
115 print "ok1\n" if !warnings::enabled('all') ;
116 print "ok2\n" if warnings::enabled("syntax") ;
120 use warnings 'syntax' ;
132 print "ok1\n" if ! warnings::enabled('all') ;
133 print "ok2\n" if warnings::enabled("syntax") ;
134 print "ok3\n" if ! warnings::enabled("io") ;
138 use warnings 'syntax' ;
150 print "ok1\n" if ! warnings::enabled('all') ;
151 print "ok2\n" if ! warnings::enabled("io") ;
168 print "ok1\n" if ! warnings::enabled('all') ;
169 print "ok2\n" if warnings::enabled("syntax") ;
170 print "ok3\n" if !warnings::enabled("io") ;
173 use warnings 'syntax' ;
174 print "ok4\n" if !warnings::enabled('all') ;
175 print "ok5\n" if warnings::enabled("io") ;
193 print "ok1\n" if !warnings::enabled('all') ;
194 print "ok2\n" if warnings::enabled("syntax") ;
198 use warnings 'syntax' ;
200 eval { abc::check() ; };
211 print "ok1\n" if ! warnings::enabled('all') ;
212 print "ok2\n" if warnings::enabled("syntax") ;
213 print "ok3\n" if ! warnings::enabled("io") ;
217 use warnings 'syntax' ;
219 eval { abc::check() ; } ;
231 print "ok1\n" if !warnings::enabled('all') ;
232 print "ok2\n" if warnings::enabled("syntax") ;
236 use warnings 'syntax' ;
238 eval { abc::check() ; } ;
249 print "ok1\n" if !warnings::enabled('all') ;
250 print "ok2\n" if warnings::enabled("syntax") ;
251 print "ok3\n" if warnings::enabled("io") ;
255 use warnings 'syntax' ;
257 eval { use warnings 'io' ; abc::check() ; };
272 print "ok1\n" if ! warnings::enabled('all') ;
273 print "ok2\n" if warnings::enabled("syntax") ;
274 print "ok3\n" if ! warnings::enabled("io") ;
278 use warnings 'syntax' ;
280 sub fred { abc::check() }
292 print "ok1\n" if ! warnings::enabled('all') ;
296 use warnings 'syntax' ;
298 sub fred { no warnings ; abc::check() }
306 use warnings 'misc' ;
308 print "ok1\n" if ! warnings::enabled('all') ;
309 print "ok2\n" if warnings::enabled("syntax") ;
310 print "ok3\n" if warnings::enabled("io") ;
311 print "ok4\n" if ! warnings::enabled("misc") ;
315 use warnings 'syntax' ;
317 sub fred { use warnings 'io' ; abc::check() }
326 # check warnings::warn
328 eval { warnings::warn() } ;
330 eval { warnings::warn("fred", "joe") } ;
333 Usage: warnings::warn([category,] 'message') at - line 4
334 unknown warnings category 'fred' at - line 6
337 # check warnings::warnif
339 eval { warnings::warnif() } ;
341 eval { warnings::warnif("fred", "joe") } ;
344 Usage: warnings::warnif([category,] 'message') at - line 4
345 unknown warnings category 'fred' at - line 6
350 use warnings 'misc' ;
351 sub check { warnings::warn("io", "hello") }
363 use warnings 'misc' ;
364 sub check { warnings::warn("misc", "hello") }
376 use warnings 'misc' ;
377 sub check { warnings::warn("io", "hello") }
380 use warnings qw( FATAL deprecated ) ;
382 eval { abc::check() ; } ;
386 eval {...} called at - line 3
392 use warnings 'misc' ;
393 sub check { warnings::warn("io", "hello") }
396 use warnings qw( FATAL io ) ;
398 eval { abc::check() ; } ;
402 eval {...} called at - line 3
409 print "ok1\n" if warnings::enabled("io") ;
410 print "ok2\n" if warnings::enabled("all") ;
423 print "ok1\n" if !warnings::enabled("io") ;
424 print "ok2\n" if !warnings::enabled("all") ;
438 print "ok\n" if ! warnings::enabled() ;
442 use warnings 'syntax' ;
446 package 'abc' not registered for warnings at abc.pm line 4
453 warnings::warn("fred") ;
457 use warnings 'syntax' ;
461 package 'abc' not registered for warnings at abc.pm line 4
468 warnings::warnif("fred") ;
472 use warnings 'syntax' ;
476 package 'abc' not registered for warnings at abc.pm line 4
482 use warnings::register ;
484 print "ok1\n" if warnings::enabled ;
485 print "ok2\n" if warnings::enabled("syntax") ;
486 print "ok3\n" if !warnings::enabled("io") ;
490 use warnings 'syntax' ;
503 use warnings::register ;
505 print "ok1\n" if !warnings::enabled ;
506 print "ok2\n" if warnings::enabled("syntax") ;
507 print "ok3\n" if !warnings::enabled("io") ;
511 use warnings 'syntax' ;
523 use warnings::register ;
525 print "ok1\n" if warnings::enabled ;
526 print "ok2\n" if warnings::enabled("syntax") ;
530 use warnings 'syntax' ;
533 eval { abc::check() ; };
543 use warnings::register ;
545 print "ok1\n" if !warnings::enabled ;
546 print "ok2\n" if warnings::enabled("syntax") ;
547 print "ok3\n" if !warnings::enabled("io") ;
551 use warnings 'syntax' ;
553 eval { abc::check() ; } ;
564 use warnings::register ;
566 print "ok1\n" if warnings::enabled ;
567 print "ok2\n" if warnings::enabled("syntax") ;
568 print "ok3\n" if !warnings::enabled("io") ;
572 use warnings 'syntax' ;
575 sub fred { abc::check() }
586 use warnings::register ;
588 print "ok1\n" if ! warnings::enabled ;
592 use warnings 'syntax' ;
594 sub fred { no warnings ; abc::check() }
602 use warnings 'misc' ;
603 use warnings::register;
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") ;
612 use warnings 'syntax' ;
615 sub fred { use warnings 'io' ; abc::check() }
626 use warnings 'misc' ;
627 use warnings::register;
628 sub check { warnings::warn("hello") }
640 use warnings::register;
641 sub check { warnings::warn("hello") }
652 use warnings::register ;
653 sub check { warnings::warn("hello") }
657 use warnings qw( FATAL deprecated ) ;
658 eval { abc::check() ; } ;
662 eval {...} called at - line 3
668 use warnings::register ;
669 sub check { warnings::warn("hello") }
673 use warnings qw( FATAL abc ) ;
674 eval { abc::check() ; } ;
678 eval {...} called at - line 3
685 use warnings::register ;
687 print "ok1\n" if warnings::enabled() ;
688 print "ok2\n" if warnings::enabled("io") ;
689 print "ok3\n" if warnings::enabled("all") ;
705 use warnings::register ;
707 print "ok1\n" if !warnings::enabled() ;
708 print "ok2\n" if !warnings::enabled("io") ;
709 print "ok3\n" if !warnings::enabled("all") ;
725 use warnings::register ;
727 print "ok1\n" if warnings::enabled() ;
728 print "ok2\n" if warnings::enabled("io") ;
729 print "ok3\n" if warnings::enabled("all") ;
745 use warnings::register ;
747 print "ok1\n" if !warnings::enabled() ;
748 print "ok2\n" if !warnings::enabled("io") ;
749 print "ok3\n" if !warnings::enabled("all") ;
765 use warnings::register ;
767 print "ok1\n" if !warnings::enabled() ;
768 print "ok2\n" if !warnings::enabled("io") ;
769 print "ok3\n" if !warnings::enabled("all") ;
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") ;
790 use warnings::register ;
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" ;
800 use warnings::register ;
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" ;
873 use warnings::register ;
875 print "ok1\n" if warnings::enabled() ;
876 print "ok2\n" if warnings::enabled("io") ;
877 print "ok3\n" if warnings::enabled("all") ;
892 use warnings::register ;
894 print "ok1\n" if !warnings::enabled() ;
895 print "ok2\n" if !warnings::enabled("io") ;
896 print "ok3\n" if !warnings::enabled("all") ;
913 use warnings::register ;
915 print "ok1\n" if !warnings::enabled() ;
916 print "ok2\n" if !warnings::enabled("io") ;
917 print "ok3\n" if !warnings::enabled("all") ;
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") ;
939 use warnings::register ;
941 print "ok1\n" if !warnings::enabled() ;
942 print "ok2\n" if !warnings::enabled("io") ;
943 print "ok3\n" if !warnings::enabled("all") ;
962 use warnings::register ;
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") ;
974 sub in2 { no warnings ; check() }
975 sub in1 { no warnings ; in2() }
986 my message 1 at - line 3
987 my message 2 at - line 3
988 my message 3 at - line 3
994 use warnings::register ;
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") ;
1006 sub in2 { no warnings ; check() }
1007 sub in1 { no warnings ; in2() }
1014 sub in1 { def::in1() ; }
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
1037 use warnings::register ;
1039 @ISA = qw( Exporter ) ;
1040 @EXPORT = qw( in1 ) ;
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") ;
1054 sub in2 { no warnings ; check() }
1055 sub in1 { no warnings ; in2() }
1059 use warnings::register ;
1073 my message 1 at - line 4
1074 my message 3 at - line 4
1080 use warnings::register ;
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) ;
1098 warnings::warn("my message 1") ;
1099 warnings::warn($self, "my message 2") ;
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") ;
1124 use warnings::register ;
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
1160 my message 1 at - line 8
1161 my message 2 at - line 8
1162 my message 4 at - line 8