This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
missing file in change#5170
[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" ;
8print "ok1\n" if ! warnings::enabled() ;
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 ;
22print "ok1\n" if warnings::enabled() ;
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' ;
36print "ok1\n" if warnings::enabled() ;
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 ;
49print "ok1\n" if warnings::enabled() ;
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' ;
62print "ok1\n" if warnings::enabled ;
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 {
79 print "ok1\n" if warnings::enabled ;
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 {
96 print "ok1\n" if warnings::enabled ;
97 print "ok2\n" if warnings::enabled("syntax") ;
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 {
115 print "ok1\n" if warnings::enabled ;
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 {
132 print "ok1\n" if warnings::enabled ;
133 print "ok2\n" if warnings::enabled("syntax") ;
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" ;
150print "ok1\n" if ! warnings::enabled() ;
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 ;
168print "ok1\n" if warnings::enabled() ;
169print "ok2\n" if warnings::enabled("syntax") ;
170print "ok3\n" if !warnings::enabled("io") ;
1711;
172--FILE-- def.pm
173use warnings 'syntax' ;
174print "ok4\n" if warnings::enabled() ;
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 {
193 print "ok1\n" if warnings::enabled ;
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 {
211 print "ok1\n" if warnings::enabled ;
212 print "ok2\n" if warnings::enabled("syntax") ;
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 {
231 print "ok1\n" if warnings::enabled ;
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 {
249 print "ok1\n" if warnings::enabled ;
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 {
272 print "ok1\n" if warnings::enabled ;
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 {
292 print "ok1\n" if ! warnings::enabled ;
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 {
308 print "ok1\n" if warnings::enabled ;
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 $@ ;
330eval { warnings::warn("fred") } ;
331print $@ ;
332EXPECT
333Usage: warnings::warn('category', 'message') at - line 4
334Usage: warnings::warn('category', 'message') at - line 6
335########
336
337--FILE-- abc.pm
338package abc ;
339use warnings 'misc' ;
340sub check { warnings::warn("io", "hello") }
3411;
342--FILE--
343use warnings "io" ;
344use abc;
345abc::check() ;
346EXPECT
347hello at - line 3
348########
349
350--FILE-- abc.pm
351package abc ;
352use warnings 'misc' ;
353sub check { warnings::warn("misc", "hello") }
3541;
355--FILE--
356use warnings "io" ;
357use abc;
358abc::check() ;
359EXPECT
360hello at - line 3
361########
362
363--FILE-- abc.pm
364package abc ;
365use warnings 'misc' ;
366sub check { warnings::warn("io", "hello") }
3671;
368--FILE--
369use warnings qw( FATAL deprecated ) ;
370use abc;
371eval { abc::check() ; } ;
372print "[[$@]]\n";
373EXPECT
374hello at - line 3
375[[]]
376########
377
378--FILE-- abc.pm
379package abc ;
380use warnings 'misc' ;
381sub check { warnings::warn("io", "hello") }
3821;
383--FILE--
384use warnings qw( FATAL io ) ;
385use abc;
386eval { abc::check() ; } ;
387print "[[$@]]\n";
388EXPECT
389[[hello at - line 3
390]]