This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
caller() wasn't returning the right number of elements for
[perl5.git] / t / pragma / warn / 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
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
GS
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
GS
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
GS
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
GS
211 print "ok1\n" if ! warnings::enabled('all') ;
212 print "ok2\n" if warnings::enabled("syntax") ;
8d93267c
GS
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
GS
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
GS
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
GS
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
GS
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
GS
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
GS
331print $@ ;
332EXPECT
d3a7d8c7
GS
333Usage: warnings::warn([category,] 'message') at - line 4
334unknown warnings category 'fred' at - line 6
811a4de9 335 eval {...} called at - line 6
8d93267c
GS
336########
337
338--FILE-- abc.pm
339package abc ;
340use warnings 'misc' ;
341sub check { warnings::warn("io", "hello") }
3421;
343--FILE--
344use warnings "io" ;
345use abc;
346abc::check() ;
347EXPECT
348hello at - line 3
349########
350
351--FILE-- abc.pm
352package abc ;
353use warnings 'misc' ;
354sub check { warnings::warn("misc", "hello") }
3551;
356--FILE--
357use warnings "io" ;
358use abc;
359abc::check() ;
360EXPECT
361hello at - line 3
362########
363
364--FILE-- abc.pm
365package abc ;
366use warnings 'misc' ;
367sub check { warnings::warn("io", "hello") }
3681;
369--FILE--
370use warnings qw( FATAL deprecated ) ;
371use abc;
372eval { abc::check() ; } ;
373print "[[$@]]\n";
374EXPECT
375hello at - line 3
376[[]]
377########
378
379--FILE-- abc.pm
380package abc ;
381use warnings 'misc' ;
382sub check { warnings::warn("io", "hello") }
3831;
384--FILE--
385use warnings qw( FATAL io ) ;
386use abc;
387eval { abc::check() ; } ;
388print "[[$@]]\n";
389EXPECT
390[[hello at - line 3
391]]
d3a7d8c7
GS
392########
393-W
394--FILE-- abc.pm
395package abc ;
396use warnings "io" ;
397print "ok1\n" if warnings::enabled("io") ;
398print "ok2\n" if warnings::enabled("all") ;
3991;
400--FILE--
401no warnings;
402use abc ;
403EXPECT
404ok1
405ok2
406########
407-X
408--FILE-- abc.pm
409package abc ;
410use warnings "io" ;
411print "ok1\n" if !warnings::enabled("io") ;
412print "ok2\n" if !warnings::enabled("all") ;
4131;
414--FILE--
415use warnings;
416use abc ;
417EXPECT
418ok1
419ok2
420########
421
422--FILE-- abc.pm
423package abc ;
424no warnings ;
425sub check {
426 print "ok\n" if ! warnings::enabled() ;
427}
4281;
429--FILE--
430use warnings 'syntax' ;
431use abc ;
432abc::check() ;
433EXPECT
434package 'abc' not registered for warnings at - line 3
435########
436
437--FILE-- abc.pm
438package abc ;
439use warnings 'io' ;
440use warnings::register ;
441sub check {
442 print "ok1\n" if warnings::enabled ;
443 print "ok2\n" if warnings::enabled("syntax") ;
444 print "ok3\n" if !warnings::enabled("io") ;
445}
4461;
447--FILE--
448use warnings 'syntax' ;
449use abc ;
450use warnings 'abc' ;
451abc::check() ;
452EXPECT
453ok1
454ok2
455ok3
456########
457
458--FILE-- abc.pm
459package abc ;
460use warnings 'io' ;
461use warnings::register ;
462sub check {
463 print "ok1\n" if !warnings::enabled ;
464 print "ok2\n" if warnings::enabled("syntax") ;
465 print "ok3\n" if !warnings::enabled("io") ;
466}
4671;
468--FILE--
469use warnings 'syntax' ;
470use abc ;
471abc::check() ;
472EXPECT
473ok1
474ok2
475ok3
476########
477
478--FILE-- abc.pm
479package abc ;
480no warnings ;
481use warnings::register ;
482sub check {
483 print "ok1\n" if warnings::enabled ;
484 print "ok2\n" if warnings::enabled("syntax") ;
485}
4861;
487--FILE--
488use warnings 'syntax' ;
489use abc ;
490use warnings 'abc' ;
491eval { abc::check() ; };
492print $@ ;
493EXPECT
494ok1
495ok2
496########
497
498--FILE-- abc.pm
499package abc ;
500use warnings 'io' ;
501use warnings::register ;
502sub check {
503 print "ok1\n" if !warnings::enabled ;
504 print "ok2\n" if warnings::enabled("syntax") ;
505 print "ok3\n" if !warnings::enabled("io") ;
506}
5071;
508--FILE--
509use warnings 'syntax' ;
510use abc ;
511eval { abc::check() ; } ;
512print $@ ;
513EXPECT
514ok1
515ok2
516ok3
517########
518
519--FILE-- abc.pm
520package abc ;
521use warnings 'io' ;
522use warnings::register ;
523sub check {
524 print "ok1\n" if warnings::enabled ;
525 print "ok2\n" if warnings::enabled("syntax") ;
526 print "ok3\n" if !warnings::enabled("io") ;
527}
5281;
529--FILE--
530use warnings 'syntax' ;
531use abc ;
532use warnings 'abc' ;
533sub fred { abc::check() }
534fred() ;
535EXPECT
536ok1
537ok2
538ok3
539########
540
541--FILE-- abc.pm
542package abc ;
543use warnings 'io' ;
544use warnings::register ;
545sub check {
546 print "ok1\n" if ! warnings::enabled ;
547}
5481;
549--FILE--
550use warnings 'syntax' ;
551use abc ;
552sub fred { no warnings ; abc::check() }
553fred() ;
554EXPECT
555ok1
556########
557
558--FILE-- abc.pm
559package abc ;
560use warnings 'misc' ;
561use warnings::register;
562sub check {
563 print "ok1\n" if warnings::enabled ;
564 print "ok2\n" if warnings::enabled("syntax") ;
565 print "ok3\n" if warnings::enabled("io") ;
566 print "ok4\n" if ! warnings::enabled("misc") ;
567}
5681;
569--FILE--
570use warnings 'syntax' ;
571use abc ;
572use warnings 'abc' ;
573sub fred { use warnings 'io' ; abc::check() }
574fred() ;
575EXPECT
576ok1
577ok2
578ok3
579ok4
580########
581
582--FILE-- abc.pm
583package abc ;
584use warnings 'misc' ;
585use warnings::register;
586sub check { warnings::warn("hello") }
5871;
588--FILE--
589use abc;
590use warnings "abc" ;
591abc::check() ;
592EXPECT
593hello at - line 3
594########
595
596--FILE-- abc.pm
597package abc ;
598use warnings::register;
599sub check { warnings::warn("hello") }
6001;
601--FILE--
602use abc;
603abc::check() ;
604EXPECT
605hello at - line 2
606########
607
608--FILE-- abc.pm
609package abc ;
610use warnings::register ;
611sub check { warnings::warn("hello") }
6121;
613--FILE--
614use abc;
615use warnings qw( FATAL deprecated ) ;
616eval { abc::check() ; } ;
617print "[[$@]]\n";
618EXPECT
619hello at - line 3
620[[]]
621########
622
623--FILE-- abc.pm
624package abc ;
625use warnings::register ;
626sub check { warnings::warn("hello") }
6271;
628--FILE--
629use abc;
630use warnings qw( FATAL abc ) ;
631eval { abc::check() ; } ;
632print "[[$@]]\n";
633EXPECT
634[[hello at - line 3
635]]
636########
637-W
638--FILE-- abc.pm
639package abc ;
640use warnings "io" ;
641use warnings::register ;
642sub check {
643 print "ok1\n" if warnings::enabled() ;
644 print "ok2\n" if warnings::enabled("io") ;
645 print "ok3\n" if warnings::enabled("all") ;
646}
6471;
648--FILE--
649no warnings;
650use abc ;
651abc::check() ;
652EXPECT
653ok1
654ok2
655ok3
656########
657-X
658--FILE-- abc.pm
659package abc ;
660use warnings "io" ;
661use warnings::register ;
662sub check {
663 print "ok1\n" if !warnings::enabled() ;
664 print "ok2\n" if !warnings::enabled("io") ;
665 print "ok3\n" if !warnings::enabled("all") ;
666}
6671;
668--FILE--
669no warnings;
670use abc ;
671abc::check() ;
672EXPECT
673ok1
674ok2
675ok3
676########
677
678--FILE-- abc.pm
679package abc ;
680use warnings "io" ;
681use warnings::register ;
682sub check {
683 print "ok1\n" if warnings::enabled() ;
684 print "ok2\n" if warnings::enabled("io") ;
685 print "ok3\n" if warnings::enabled("all") ;
686}
6871;
688--FILE--
689use warnings 'all';
690use abc ;
691abc::check() ;
692EXPECT
693ok1
694ok2
695ok3
696########
697
698--FILE-- abc.pm
699package abc ;
700use warnings "io" ;
701use warnings::register ;
702sub check {
703 print "ok1\n" if !warnings::enabled() ;
704 print "ok2\n" if !warnings::enabled("io") ;
705 print "ok3\n" if !warnings::enabled("all") ;
706}
7071;
708--FILE--
709use abc ;
710no warnings ;
711abc::check() ;
712EXPECT
713ok1
714ok2
715ok3
716########
717
718--FILE-- abc.pm
719package abc ;
720use warnings "io" ;
721use warnings::register ;
722sub check {
723 print "ok1\n" if !warnings::enabled() ;
724 print "ok2\n" if !warnings::enabled("io") ;
725 print "ok3\n" if !warnings::enabled("all") ;
726}
7271;
728--FILE--
729use abc ;
730use warnings 'abc';
731no warnings ;
732abc::check() ;
733EXPECT
734ok1
735ok2
736ok3
737########
738
739--FILE-- abc.pm
740package abc ;
741use warnings "io" ;
742use warnings::register ;
743sub check {
744 print "abc self" . (warnings::enabled() ? "" : " not") . " enabled\n" ;
745 print "abc def" . (warnings::enabled('def') ? "" : " not") . " enabled\n" ;
746 print "abc all" . (warnings::enabled('all') ? "" : " not") . " enabled\n" ;
747}
7481;
749--FILE-- def.pm
750package def ;
751use warnings "io" ;
752use warnings::register ;
753sub check {
754 print "def self" . (warnings::enabled() ? "" : " not") . " enabled\n" ;
755 print "def abc" . (warnings::enabled('abc') ? "" : " not") . " enabled\n" ;
756 print "def all" . (warnings::enabled('all') ? "" : " not") . " enabled\n" ;
757}
7581;
759--FILE--
760use abc ;
761use def ;
762use warnings 'abc';
763abc::check() ;
764def::check() ;
765no warnings 'abc' ;
766use warnings 'def' ;
767abc::check() ;
768def::check() ;
769use warnings 'abc' ;
770use warnings 'def' ;
771abc::check() ;
772def::check() ;
773no warnings 'abc' ;
774no warnings 'def' ;
775abc::check() ;
776def::check() ;
777use warnings;
778abc::check() ;
779def::check() ;
780no warnings 'abc' ;
781abc::check() ;
782def::check() ;
783EXPECT
784abc self enabled
785abc def not enabled
786abc all not enabled
787def self not enabled
788def abc enabled
789def all not enabled
790abc self not enabled
791abc def enabled
792abc all not enabled
793def self enabled
794def abc not enabled
795def all not enabled
796abc self enabled
797abc def enabled
798abc all not enabled
799def self enabled
800def abc enabled
801def all not enabled
802abc self not enabled
803abc def not enabled
804abc all not enabled
805def self not enabled
806def abc not enabled
807def all not enabled
808abc self enabled
809abc def enabled
810abc all enabled
811def self enabled
812def abc enabled
813def all enabled
814abc self not enabled
815abc def enabled
816abc all not enabled
817def self enabled
818def abc not enabled
819def all not enabled