Move the locale/strict/warnings helper files back
[p5sagit/p5-mst-13.2.git] / t / lib / warnings / 9enabled
CommitLineData
8d93267c 1Check warnings::enabled & warnings::warn
2
3__END__
4
5--FILE-- abc.pm
6package abc ;
7use warnings "io" ;
d3a7d8c7 8print "ok1\n" if ! warnings::enabled('all') ;
8d93267c 9print "ok2\n" if ! warnings::enabled("io") ;
101;
11--FILE--
12no warnings;
13use abc ;
14EXPECT
15ok1
16ok2
17########
18
19--FILE-- abc.pm
20package abc ;
21no warnings ;
d3a7d8c7 22print "ok1\n" if !warnings::enabled('all') ;
8d93267c 23print "ok2\n" if warnings::enabled("syntax") ;
241;
25--FILE--
26use warnings 'syntax' ;
27use abc ;
28EXPECT
29ok1
30ok2
31########
32
33--FILE-- abc.pm
34package abc ;
35use warnings 'syntax' ;
d3a7d8c7 36print "ok1\n" if warnings::enabled('io') ;
8d93267c 37print "ok2\n" if ! warnings::enabled("syntax") ;
381;
39--FILE--
40use warnings 'io' ;
41use abc ;
42EXPECT
43ok1
44ok2
45########
46
47--FILE-- abc
48no warnings ;
d3a7d8c7 49print "ok1\n" if !warnings::enabled('all') ;
8d93267c 50print "ok2\n" if warnings::enabled("syntax") ;
511;
52--FILE--
53use warnings 'syntax' ;
54require "abc" ;
55EXPECT
56ok1
57ok2
58########
59
60--FILE-- abc
61use warnings 'syntax' ;
d3a7d8c7 62print "ok1\n" if ! warnings::enabled('all') ;
8d93267c 63print "ok2\n" if ! warnings::enabled("syntax") ;
64print "ok3\n" if warnings::enabled("io") ;
651;
66--FILE--
67use warnings 'io' ;
68require "abc" ;
69EXPECT
70ok1
71ok2
72ok3
73########
74
75--FILE-- abc.pm
76package abc ;
77no warnings ;
78sub check {
d3a7d8c7 79 print "ok1\n" if !warnings::enabled('all') ;
8d93267c 80 print "ok2\n" if warnings::enabled("syntax") ;
81}
821;
83--FILE--
84use warnings 'syntax' ;
85use abc ;
86abc::check() ;
87EXPECT
88ok1
89ok2
90########
91
92--FILE-- abc.pm
93package abc ;
94use warnings 'io' ;
95sub 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}
1001;
101--FILE--
102use warnings 'syntax' ;
103use abc ;
104abc::check() ;
105EXPECT
106ok1
107ok2
108ok3
109########
110
111--FILE-- abc
112package abc ;
113no warnings ;
114sub check {
d3a7d8c7 115 print "ok1\n" if !warnings::enabled('all') ;
8d93267c 116 print "ok2\n" if warnings::enabled("syntax") ;
117}
1181;
119--FILE--
120use warnings 'syntax' ;
121require "abc" ;
122abc::check() ;
123EXPECT
124ok1
125ok2
126########
127
128--FILE-- abc
129package abc ;
130use warnings 'io' ;
131sub 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}
1361;
137--FILE--
138use warnings 'syntax' ;
139require "abc" ;
140abc::check() ;
141EXPECT
142ok1
143ok2
144ok3
145########
146
147--FILE-- abc.pm
148package abc ;
149use warnings "io" ;
d3a7d8c7 150print "ok1\n" if ! warnings::enabled('all') ;
8d93267c 151print "ok2\n" if ! warnings::enabled("io") ;
1521;
153--FILE-- def.pm
154no warnings;
155use abc ;
1561;
157--FILE--
158use warnings;
159use def ;
160EXPECT
161ok1
162ok2
163########
164
165--FILE-- abc.pm
166package abc ;
167no warnings ;
d3a7d8c7 168print "ok1\n" if ! warnings::enabled('all') ;
8d93267c 169print "ok2\n" if warnings::enabled("syntax") ;
170print "ok3\n" if !warnings::enabled("io") ;
1711;
172--FILE-- def.pm
173use warnings 'syntax' ;
d3a7d8c7 174print "ok4\n" if !warnings::enabled('all') ;
8d93267c 175print "ok5\n" if warnings::enabled("io") ;
176use abc ;
1771;
178--FILE--
179use warnings 'io' ;
180use def ;
181EXPECT
182ok1
183ok2
184ok3
185ok4
186ok5
187########
188
189--FILE-- abc.pm
190package abc ;
191no warnings ;
192sub check {
d3a7d8c7 193 print "ok1\n" if !warnings::enabled('all') ;
8d93267c 194 print "ok2\n" if warnings::enabled("syntax") ;
195}
1961;
197--FILE--
198use warnings 'syntax' ;
199use abc ;
200eval { abc::check() ; };
201print $@ ;
202EXPECT
203ok1
204ok2
205########
206
207--FILE-- abc.pm
208package abc ;
209use warnings 'io' ;
210sub 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}
2151;
216--FILE--
217use warnings 'syntax' ;
218use abc ;
219eval { abc::check() ; } ;
220print $@ ;
221EXPECT
222ok1
223ok2
224ok3
225########
226
227--FILE-- abc
228package abc ;
229no warnings ;
230sub check {
d3a7d8c7 231 print "ok1\n" if !warnings::enabled('all') ;
8d93267c 232 print "ok2\n" if warnings::enabled("syntax") ;
233}
2341;
235--FILE--
236use warnings 'syntax' ;
237require "abc" ;
238eval { abc::check() ; } ;
239print $@ ;
240EXPECT
241ok1
242ok2
243########
244
245--FILE-- abc
246package abc ;
247use warnings 'io' ;
248sub 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}
2531;
254--FILE--
255use warnings 'syntax' ;
256require "abc" ;
257eval { use warnings 'io' ; abc::check() ; };
258abc::check() ;
259print $@ ;
260EXPECT
261ok1
262ok2
263ok3
264ok1
265ok2
266########
267
268--FILE-- abc.pm
269package abc ;
270use warnings 'io' ;
271sub 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}
2761;
277--FILE--
278use warnings 'syntax' ;
279use abc ;
280sub fred { abc::check() }
281fred() ;
282EXPECT
283ok1
284ok2
285ok3
286########
287
288--FILE-- abc.pm
289package abc ;
290use warnings 'io' ;
291sub check {
d3a7d8c7 292 print "ok1\n" if ! warnings::enabled('all') ;
8d93267c 293}
2941;
295--FILE--
296use warnings 'syntax' ;
297use abc ;
298sub fred { no warnings ; abc::check() }
299fred() ;
300EXPECT
301ok1
302########
303
304--FILE-- abc.pm
305package abc ;
306use warnings 'misc' ;
307sub 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}
3131;
314--FILE--
315use warnings 'syntax' ;
316use abc ;
317sub fred { use warnings 'io' ; abc::check() }
318fred() ;
319EXPECT
320ok1
321ok2
322ok3
323ok4
324########
325
326# check warnings::warn
327use warnings ;
328eval { warnings::warn() } ;
329print $@ ;
d3a7d8c7 330eval { warnings::warn("fred", "joe") } ;
8d93267c 331print $@ ;
332EXPECT
d3a7d8c7 333Usage: warnings::warn([category,] 'message') at - line 4
334unknown warnings category 'fred' at - line 6
7e6d00f8 335########
336
337# check warnings::warnif
338use warnings ;
339eval { warnings::warnif() } ;
340print $@ ;
341eval { warnings::warnif("fred", "joe") } ;
342print $@ ;
343EXPECT
344Usage: warnings::warnif([category,] 'message') at - line 4
345unknown warnings category 'fred' at - line 6
8d93267c 346########
347
348--FILE-- abc.pm
349package abc ;
350use warnings 'misc' ;
351sub check { warnings::warn("io", "hello") }
3521;
353--FILE--
354use warnings "io" ;
355use abc;
356abc::check() ;
357EXPECT
358hello at - line 3
359########
360
361--FILE-- abc.pm
362package abc ;
363use warnings 'misc' ;
364sub check { warnings::warn("misc", "hello") }
3651;
366--FILE--
367use warnings "io" ;
368use abc;
369abc::check() ;
370EXPECT
371hello at - line 3
372########
373
374--FILE-- abc.pm
375package abc ;
376use warnings 'misc' ;
377sub check { warnings::warn("io", "hello") }
3781;
379--FILE--
380use warnings qw( FATAL deprecated ) ;
381use abc;
382eval { abc::check() ; } ;
383print "[[$@]]\n";
384EXPECT
385hello at - line 3
7e6d00f8 386 eval {...} called at - line 3
8d93267c 387[[]]
388########
389
390--FILE-- abc.pm
391package abc ;
392use warnings 'misc' ;
393sub check { warnings::warn("io", "hello") }
3941;
395--FILE--
396use warnings qw( FATAL io ) ;
397use abc;
398eval { abc::check() ; } ;
399print "[[$@]]\n";
400EXPECT
401[[hello at - line 3
7e6d00f8 402 eval {...} called at - line 3
8d93267c 403]]
d3a7d8c7 404########
405-W
406--FILE-- abc.pm
407package abc ;
408use warnings "io" ;
409print "ok1\n" if warnings::enabled("io") ;
410print "ok2\n" if warnings::enabled("all") ;
4111;
412--FILE--
413no warnings;
414use abc ;
415EXPECT
416ok1
417ok2
418########
419-X
420--FILE-- abc.pm
421package abc ;
422use warnings "io" ;
423print "ok1\n" if !warnings::enabled("io") ;
424print "ok2\n" if !warnings::enabled("all") ;
4251;
426--FILE--
427use warnings;
428use abc ;
429EXPECT
430ok1
431ok2
432########
433
434--FILE-- abc.pm
435package abc ;
436no warnings ;
437sub check {
438 print "ok\n" if ! warnings::enabled() ;
439}
4401;
441--FILE--
442use warnings 'syntax' ;
443use abc ;
444abc::check() ;
445EXPECT
7e6d00f8 446package 'abc' not registered for warnings at abc.pm line 4
447########
448
449--FILE-- abc.pm
450package abc ;
451no warnings ;
452sub check {
453 warnings::warn("fred") ;
454}
4551;
456--FILE--
457use warnings 'syntax' ;
458use abc ;
459abc::check() ;
460EXPECT
461package 'abc' not registered for warnings at abc.pm line 4
462########
463
464--FILE-- abc.pm
465package abc ;
466no warnings ;
467sub check {
468 warnings::warnif("fred") ;
469}
4701;
471--FILE--
472use warnings 'syntax' ;
473use abc ;
474abc::check() ;
475EXPECT
476package 'abc' not registered for warnings at abc.pm line 4
d3a7d8c7 477########
478
479--FILE-- abc.pm
480package abc ;
481use warnings 'io' ;
482use warnings::register ;
483sub 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}
4881;
489--FILE--
490use warnings 'syntax' ;
491use abc ;
492use warnings 'abc' ;
493abc::check() ;
494EXPECT
495ok1
496ok2
497ok3
498########
499
500--FILE-- abc.pm
501package abc ;
502use warnings 'io' ;
503use warnings::register ;
504sub 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}
5091;
510--FILE--
511use warnings 'syntax' ;
512use abc ;
513abc::check() ;
514EXPECT
515ok1
516ok2
517ok3
518########
519
520--FILE-- abc.pm
521package abc ;
522no warnings ;
523use warnings::register ;
524sub check {
525 print "ok1\n" if warnings::enabled ;
526 print "ok2\n" if warnings::enabled("syntax") ;
527}
5281;
529--FILE--
530use warnings 'syntax' ;
531use abc ;
532use warnings 'abc' ;
533eval { abc::check() ; };
534print $@ ;
535EXPECT
536ok1
537ok2
538########
539
540--FILE-- abc.pm
541package abc ;
542use warnings 'io' ;
543use warnings::register ;
544sub 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}
5491;
550--FILE--
551use warnings 'syntax' ;
552use abc ;
553eval { abc::check() ; } ;
554print $@ ;
555EXPECT
556ok1
557ok2
558ok3
559########
560
561--FILE-- abc.pm
562package abc ;
563use warnings 'io' ;
564use warnings::register ;
565sub 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}
5701;
571--FILE--
572use warnings 'syntax' ;
573use abc ;
574use warnings 'abc' ;
575sub fred { abc::check() }
576fred() ;
577EXPECT
578ok1
579ok2
580ok3
581########
582
583--FILE-- abc.pm
584package abc ;
585use warnings 'io' ;
586use warnings::register ;
587sub check {
588 print "ok1\n" if ! warnings::enabled ;
589}
5901;
591--FILE--
592use warnings 'syntax' ;
593use abc ;
594sub fred { no warnings ; abc::check() }
595fred() ;
596EXPECT
597ok1
598########
599
600--FILE-- abc.pm
601package abc ;
602use warnings 'misc' ;
603use warnings::register;
604sub 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}
6101;
611--FILE--
612use warnings 'syntax' ;
613use abc ;
614use warnings 'abc' ;
615sub fred { use warnings 'io' ; abc::check() }
616fred() ;
617EXPECT
618ok1
619ok2
620ok3
621ok4
622########
623
624--FILE-- abc.pm
625package abc ;
626use warnings 'misc' ;
627use warnings::register;
628sub check { warnings::warn("hello") }
6291;
630--FILE--
631use abc;
632use warnings "abc" ;
633abc::check() ;
634EXPECT
635hello at - line 3
636########
637
638--FILE-- abc.pm
639package abc ;
640use warnings::register;
641sub check { warnings::warn("hello") }
6421;
643--FILE--
644use abc;
645abc::check() ;
646EXPECT
647hello at - line 2
648########
649
650--FILE-- abc.pm
651package abc ;
652use warnings::register ;
653sub check { warnings::warn("hello") }
6541;
655--FILE--
656use abc;
657use warnings qw( FATAL deprecated ) ;
658eval { abc::check() ; } ;
659print "[[$@]]\n";
660EXPECT
661hello at - line 3
7e6d00f8 662 eval {...} called at - line 3
d3a7d8c7 663[[]]
664########
665
666--FILE-- abc.pm
667package abc ;
668use warnings::register ;
669sub check { warnings::warn("hello") }
6701;
671--FILE--
672use abc;
673use warnings qw( FATAL abc ) ;
674eval { abc::check() ; } ;
675print "[[$@]]\n";
676EXPECT
677[[hello at - line 3
7e6d00f8 678 eval {...} called at - line 3
d3a7d8c7 679]]
680########
681-W
682--FILE-- abc.pm
683package abc ;
684use warnings "io" ;
685use warnings::register ;
686sub 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}
6911;
692--FILE--
693no warnings;
694use abc ;
695abc::check() ;
696EXPECT
697ok1
698ok2
699ok3
700########
701-X
702--FILE-- abc.pm
703package abc ;
704use warnings "io" ;
705use warnings::register ;
706sub 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}
7111;
712--FILE--
713no warnings;
714use abc ;
715abc::check() ;
716EXPECT
717ok1
718ok2
719ok3
720########
721
722--FILE-- abc.pm
723package abc ;
724use warnings "io" ;
725use warnings::register ;
726sub 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}
7311;
732--FILE--
733use warnings 'all';
734use abc ;
735abc::check() ;
736EXPECT
737ok1
738ok2
739ok3
740########
741
742--FILE-- abc.pm
743package abc ;
744use warnings "io" ;
745use warnings::register ;
746sub 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}
7511;
752--FILE--
753use abc ;
754no warnings ;
755abc::check() ;
756EXPECT
757ok1
758ok2
759ok3
760########
761
762--FILE-- abc.pm
763package abc ;
764use warnings "io" ;
765use warnings::register ;
766sub 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}
7751;
776--FILE--
777use abc ;
778use warnings 'abc';
779no warnings ;
780abc::check() ;
781EXPECT
782ok1
783ok2
784ok3
785########
786
787--FILE-- abc.pm
788package abc ;
789use warnings "io" ;
790use warnings::register ;
791sub 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}
7961;
797--FILE-- def.pm
798package def ;
799use warnings "io" ;
800use warnings::register ;
801sub 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}
8061;
807--FILE--
808use abc ;
809use def ;
810use warnings 'abc';
811abc::check() ;
812def::check() ;
813no warnings 'abc' ;
814use warnings 'def' ;
815abc::check() ;
816def::check() ;
817use warnings 'abc' ;
818use warnings 'def' ;
819abc::check() ;
820def::check() ;
821no warnings 'abc' ;
822no warnings 'def' ;
823abc::check() ;
824def::check() ;
825use warnings;
826abc::check() ;
827def::check() ;
828no warnings 'abc' ;
829abc::check() ;
830def::check() ;
831EXPECT
832abc self enabled
833abc def not enabled
834abc all not enabled
835def self not enabled
836def abc enabled
837def all not enabled
838abc self not enabled
839abc def enabled
840abc all not enabled
841def self enabled
842def abc not enabled
843def all not enabled
844abc self enabled
845abc def enabled
846abc all not enabled
847def self enabled
848def abc enabled
849def all not enabled
850abc self not enabled
851abc def not enabled
852abc all not enabled
853def self not enabled
854def abc not enabled
855def all not enabled
856abc self enabled
857abc def enabled
858abc all enabled
859def self enabled
860def abc enabled
861def all enabled
862abc self not enabled
863abc def enabled
864abc all not enabled
865def self enabled
866def abc not enabled
867def all not enabled
114bafba 868########
869-w
870--FILE-- abc.pm
871package abc ;
872no warnings ;
873use warnings::register ;
874sub 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}
8791;
880--FILE--
881use abc ;
882abc::check() ;
883EXPECT
884ok1
885ok2
886ok3
887########
888-w
889--FILE-- abc.pm
890package abc ;
891no warnings ;
892use warnings::register ;
893sub 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}
8981;
899--FILE--
900use abc ;
901use warnings 'abc';
902no warnings ;
903abc::check() ;
904EXPECT
905ok1
906ok2
907ok3
908########
909
910--FILE-- abc.pm
911package abc ;
912no warnings ;
913use warnings::register ;
914sub 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}
9231;
924--FILE--
925use abc ;
926use warnings 'abc';
927no warnings ;
928BEGIN { $^W = 1 ; }
929abc::check() ;
930EXPECT
931ok1
932ok2
933ok3
934########
935
936--FILE-- abc.pm
937package abc ;
938no warnings ;
939use warnings::register ;
940sub 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}
9451;
946--FILE--
947use abc ;
948use warnings 'abc';
949no warnings ;
950$^W = 1 ;
951abc::check() ;
952EXPECT
953ok1
954ok2
955ok3
7e6d00f8 956########
957
958--FILE-- abc.pm
a781f7c3 959$| = 1;
7e6d00f8 960package abc ;
961no warnings ;
962use warnings::register ;
963sub 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}
974sub in2 { no warnings ; check() }
975sub in1 { no warnings ; in2() }
9761;
977--FILE--
978use abc ;
979use warnings 'abc';
980abc::in1() ;
981EXPECT
7e6d00f8 982ok1
983ok2
984ok3
985ok4
a781f7c3 986my message 1 at - line 3
987my message 2 at - line 3
988my message 3 at - line 3
7e6d00f8 989########
990
991--FILE-- def.pm
992package def ;
993no warnings ;
994use warnings::register ;
995sub 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}
1006sub in2 { no warnings ; check() }
1007sub in1 { no warnings ; in2() }
10081;
1009--FILE-- abc.pm
a781f7c3 1010$| = 1;
7e6d00f8 1011package abc ;
1012use def ;
1013use warnings 'def';
1014sub in1 { def::in1() ; }
10151;
1016--FILE--
1017use abc ;
1018no warnings;
1019abc::in1() ;
1020EXPECT
7e6d00f8 1021ok1
1022ok2
1023ok3
1024ok4
a781f7c3 1025my message 1 at abc.pm line 5
1026 abc::in1() called at - line 3
1027my message 2 at abc.pm line 5
1028 abc::in1() called at - line 3
1029my 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 1035package def ;
1036no warnings ;
1037use warnings::register ;
1038require Exporter;
1039@ISA = qw( Exporter ) ;
1040@EXPORT = qw( in1 ) ;
1041sub 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}
1054sub in2 { no warnings ; check() }
1055sub in1 { no warnings ; in2() }
10561;
1057--FILE-- abc.pm
1058package abc ;
1059use warnings::register ;
1060use def ;
1061#@ISA = qw(def) ;
10621;
1063--FILE--
1064use abc ;
1065no warnings;
1066use warnings 'abc';
1067abc::in1() ;
1068EXPECT
7e6d00f8 1069ok2
1070ok3
1071ok4
1072ok5
a781f7c3 1073my message 1 at - line 4
1074my message 3 at - line 4
7e6d00f8 1075########
1076
1077--FILE-- def.pm
1078package def ;
1079no warnings ;
1080use warnings::register ;
1081
1082sub new
1083{
1084 my $class = shift ;
1085 bless [], $class ;
1086}
1087
1088sub 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}
1108sub in2
1109{
1110 no warnings ;
1111 my $self = shift ;
1112 $self->check() ;
1113}
1114sub in1
1115{
1116 no warnings ;
1117 my $self = shift ;
1118 $self->in2();
1119}
11201;
1121--FILE-- abc.pm
a781f7c3 1122$| = 1;
7e6d00f8 1123package abc ;
1124use warnings::register ;
1125use def ;
1126@ISA = qw(def) ;
1127sub new
1128{
1129 my $class = shift ;
1130 bless [], $class ;
1131}
1132
11331;
1134--FILE--
1135use abc ;
1136no warnings;
1137use warnings 'abc';
1138$a = new abc ;
1139$a->in1() ;
1140print "**\n";
1141$b = new def ;
1142$b->in1() ;
1143EXPECT
7e6d00f8 1144ok1
1145ok2
1146ok3
1147ok4
1148ok5
1149ok6
a781f7c3 1150my message 1 at - line 5
1151my message 2 at - line 5
1152my message 4 at - line 5
1153my message 8 at - line 5
7e6d00f8 1154**
1155ok1
1156ok2
1157ok3
1158ok4
1159ok5
a781f7c3 1160my message 1 at - line 8
1161my message 2 at - line 8
1162my message 4 at - line 8