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