Commit | Line | Data |
---|---|---|
44626bc9 FC |
1 | Check warnings::enabled, warnings::warn and other functionality of |
2 | warnings.pm. | |
8d93267c GS |
3 | |
4 | __END__ | |
5 | ||
a95b6808 JH |
6 | --FILE-- abc0.pm |
7 | package abc0 ; | |
8d93267c | 8 | use warnings "io" ; |
d3a7d8c7 | 9 | print "ok1\n" if ! warnings::enabled('all') ; |
8d93267c GS |
10 | print "ok2\n" if ! warnings::enabled("io") ; |
11 | 1; | |
a95b6808 | 12 | --FILE-- |
8d93267c | 13 | no warnings; |
a95b6808 | 14 | use abc0 ; |
8d93267c GS |
15 | EXPECT |
16 | ok1 | |
17 | ok2 | |
18 | ######## | |
19 | ||
a95b6808 JH |
20 | --FILE-- abc1.pm |
21 | package abc1 ; | |
8d93267c | 22 | no warnings ; |
d3a7d8c7 | 23 | print "ok1\n" if !warnings::enabled('all') ; |
8d93267c GS |
24 | print "ok2\n" if warnings::enabled("syntax") ; |
25 | 1; | |
a95b6808 | 26 | --FILE-- |
8d93267c | 27 | use warnings 'syntax' ; |
a95b6808 | 28 | use abc1 ; |
8d93267c GS |
29 | EXPECT |
30 | ok1 | |
31 | ok2 | |
32 | ######## | |
33 | ||
a95b6808 JH |
34 | --FILE-- abc2.pm |
35 | package abc2 ; | |
8d93267c | 36 | use warnings 'syntax' ; |
d3a7d8c7 | 37 | print "ok1\n" if warnings::enabled('io') ; |
8d93267c GS |
38 | print "ok2\n" if ! warnings::enabled("syntax") ; |
39 | 1; | |
a95b6808 | 40 | --FILE-- |
8d93267c | 41 | use warnings 'io' ; |
a95b6808 | 42 | use abc2 ; |
8d93267c GS |
43 | EXPECT |
44 | ok1 | |
45 | ok2 | |
46 | ######## | |
47 | ||
a95b6808 | 48 | --FILE-- abc3 |
8d93267c | 49 | no warnings ; |
d3a7d8c7 | 50 | print "ok1\n" if !warnings::enabled('all') ; |
4f527b71 | 51 | print "ok2\n" if !warnings::enabled("syntax") ; |
8d93267c | 52 | 1; |
a95b6808 | 53 | --FILE-- |
8d93267c | 54 | use warnings 'syntax' ; |
a95b6808 | 55 | require "abc3" ; |
8d93267c GS |
56 | EXPECT |
57 | ok1 | |
58 | ok2 | |
59 | ######## | |
60 | ||
a95b6808 | 61 | --FILE-- abc4 |
8d93267c | 62 | use warnings 'syntax' ; |
d3a7d8c7 | 63 | print "ok1\n" if ! warnings::enabled('all') ; |
8d93267c | 64 | print "ok2\n" if ! warnings::enabled("syntax") ; |
4f527b71 | 65 | print "ok3\n" if ! warnings::enabled("io") ; |
8d93267c | 66 | 1; |
a95b6808 | 67 | --FILE-- |
8d93267c | 68 | use warnings 'io' ; |
a95b6808 | 69 | require "abc4" ; |
8d93267c GS |
70 | EXPECT |
71 | ok1 | |
72 | ok2 | |
73 | ok3 | |
74 | ######## | |
75 | ||
a95b6808 JH |
76 | --FILE-- abc5.pm |
77 | package abc5 ; | |
8d93267c GS |
78 | no warnings ; |
79 | sub check { | |
d3a7d8c7 | 80 | print "ok1\n" if !warnings::enabled('all') ; |
8d93267c GS |
81 | print "ok2\n" if warnings::enabled("syntax") ; |
82 | } | |
83 | 1; | |
a95b6808 | 84 | --FILE-- |
8d93267c | 85 | use warnings 'syntax' ; |
a95b6808 JH |
86 | use abc5 ; |
87 | abc5::check() ; | |
8d93267c GS |
88 | EXPECT |
89 | ok1 | |
90 | ok2 | |
91 | ######## | |
92 | ||
a95b6808 JH |
93 | --FILE-- abc6.pm |
94 | package abc6 ; | |
8d93267c GS |
95 | use warnings 'io' ; |
96 | sub check { | |
d3a7d8c7 GS |
97 | print "ok1\n" if ! warnings::enabled('all') ; |
98 | print "ok2\n" if warnings::enabled("syntax") ; | |
8d93267c GS |
99 | print "ok3\n" if ! warnings::enabled("io") ; |
100 | } | |
101 | 1; | |
a95b6808 | 102 | --FILE-- |
8d93267c | 103 | use warnings 'syntax' ; |
a95b6808 JH |
104 | use abc6 ; |
105 | abc6::check() ; | |
8d93267c GS |
106 | EXPECT |
107 | ok1 | |
108 | ok2 | |
109 | ok3 | |
110 | ######## | |
111 | ||
a95b6808 JH |
112 | --FILE-- abc7 |
113 | package abc7 ; | |
8d93267c GS |
114 | no warnings ; |
115 | sub check { | |
d3a7d8c7 | 116 | print "ok1\n" if !warnings::enabled('all') ; |
8d93267c GS |
117 | print "ok2\n" if warnings::enabled("syntax") ; |
118 | } | |
119 | 1; | |
a95b6808 | 120 | --FILE-- |
8d93267c | 121 | use warnings 'syntax' ; |
a95b6808 JH |
122 | require "abc7" ; |
123 | abc7::check() ; | |
8d93267c GS |
124 | EXPECT |
125 | ok1 | |
126 | ok2 | |
127 | ######## | |
128 | ||
a95b6808 JH |
129 | --FILE-- abc8 |
130 | package abc8 ; | |
8d93267c GS |
131 | use warnings 'io' ; |
132 | sub check { | |
d3a7d8c7 GS |
133 | print "ok1\n" if ! warnings::enabled('all') ; |
134 | print "ok2\n" if warnings::enabled("syntax") ; | |
8d93267c GS |
135 | print "ok3\n" if ! warnings::enabled("io") ; |
136 | } | |
137 | 1; | |
a95b6808 | 138 | --FILE-- |
8d93267c | 139 | use warnings 'syntax' ; |
a95b6808 JH |
140 | require "abc8" ; |
141 | abc8::check() ; | |
8d93267c GS |
142 | EXPECT |
143 | ok1 | |
144 | ok2 | |
145 | ok3 | |
146 | ######## | |
147 | ||
a95b6808 JH |
148 | --FILE-- abc9.pm |
149 | package abc9 ; | |
8d93267c | 150 | use warnings "io" ; |
d3a7d8c7 | 151 | print "ok1\n" if ! warnings::enabled('all') ; |
8d93267c GS |
152 | print "ok2\n" if ! warnings::enabled("io") ; |
153 | 1; | |
154 | --FILE-- def.pm | |
f89e79d6 | 155 | package def; |
8d93267c | 156 | no warnings; |
a95b6808 | 157 | use abc9 ; |
8d93267c | 158 | 1; |
a95b6808 | 159 | --FILE-- |
8d93267c GS |
160 | use warnings; |
161 | use def ; | |
162 | EXPECT | |
163 | ok1 | |
164 | ok2 | |
165 | ######## | |
166 | ||
a95b6808 JH |
167 | --FILE-- abc10.pm |
168 | package abc10 ; | |
8d93267c | 169 | no warnings ; |
d3a7d8c7 | 170 | print "ok1\n" if ! warnings::enabled('all') ; |
8d93267c GS |
171 | print "ok2\n" if warnings::enabled("syntax") ; |
172 | print "ok3\n" if !warnings::enabled("io") ; | |
173 | 1; | |
174 | --FILE-- def.pm | |
175 | use warnings 'syntax' ; | |
d3a7d8c7 | 176 | print "ok4\n" if !warnings::enabled('all') ; |
4f527b71 | 177 | print "ok5\n" if !warnings::enabled("io") ; |
a95b6808 | 178 | use abc10 ; |
8d93267c GS |
179 | 1; |
180 | --FILE-- | |
181 | use warnings 'io' ; | |
182 | use def ; | |
183 | EXPECT | |
184 | ok1 | |
185 | ok2 | |
186 | ok3 | |
187 | ok4 | |
188 | ok5 | |
189 | ######## | |
190 | ||
a95b6808 JH |
191 | --FILE-- abc11.pm |
192 | package abc11 ; | |
8d93267c GS |
193 | no warnings ; |
194 | sub check { | |
d3a7d8c7 | 195 | print "ok1\n" if !warnings::enabled('all') ; |
8d93267c GS |
196 | print "ok2\n" if warnings::enabled("syntax") ; |
197 | } | |
198 | 1; | |
a95b6808 | 199 | --FILE-- |
8d93267c | 200 | use warnings 'syntax' ; |
a95b6808 JH |
201 | use abc11 ; |
202 | eval { | |
203 | abc11::check() ; | |
c3186b65 | 204 | }; |
8d93267c GS |
205 | print $@ ; |
206 | EXPECT | |
207 | ok1 | |
208 | ok2 | |
209 | ######## | |
210 | ||
a95b6808 JH |
211 | --FILE-- abc12.pm |
212 | package abc12 ; | |
8d93267c GS |
213 | use warnings 'io' ; |
214 | sub check { | |
d3a7d8c7 GS |
215 | print "ok1\n" if ! warnings::enabled('all') ; |
216 | print "ok2\n" if warnings::enabled("syntax") ; | |
8d93267c GS |
217 | print "ok3\n" if ! warnings::enabled("io") ; |
218 | } | |
219 | 1; | |
a95b6808 | 220 | --FILE-- |
8d93267c | 221 | use warnings 'syntax' ; |
a95b6808 JH |
222 | use abc12 ; |
223 | eval { | |
224 | abc12::check() ; | |
c3186b65 | 225 | } ; |
8d93267c GS |
226 | print $@ ; |
227 | EXPECT | |
228 | ok1 | |
229 | ok2 | |
230 | ok3 | |
231 | ######## | |
232 | ||
a95b6808 JH |
233 | --FILE-- abc13 |
234 | package abc13 ; | |
8d93267c GS |
235 | no warnings ; |
236 | sub check { | |
d3a7d8c7 | 237 | print "ok1\n" if !warnings::enabled('all') ; |
8d93267c GS |
238 | print "ok2\n" if warnings::enabled("syntax") ; |
239 | } | |
240 | 1; | |
a95b6808 | 241 | --FILE-- |
8d93267c | 242 | use warnings 'syntax' ; |
a95b6808 JH |
243 | require "abc13" ; |
244 | eval { | |
245 | abc13::check() ; | |
c3186b65 | 246 | } ; |
8d93267c GS |
247 | print $@ ; |
248 | EXPECT | |
249 | ok1 | |
250 | ok2 | |
251 | ######## | |
252 | ||
a95b6808 JH |
253 | --FILE-- abc14 |
254 | package abc14 ; | |
8d93267c GS |
255 | use warnings 'io' ; |
256 | sub check { | |
d3a7d8c7 | 257 | print "ok1\n" if !warnings::enabled('all') ; |
8d93267c GS |
258 | print "ok2\n" if warnings::enabled("syntax") ; |
259 | print "ok3\n" if warnings::enabled("io") ; | |
260 | } | |
261 | 1; | |
a95b6808 | 262 | --FILE-- |
8d93267c | 263 | use warnings 'syntax' ; |
a95b6808 JH |
264 | require "abc14" ; |
265 | eval { | |
266 | use warnings 'io' ; | |
267 | abc14::check() ; | |
c3186b65 | 268 | }; |
a95b6808 | 269 | abc14::check() ; |
8d93267c GS |
270 | print $@ ; |
271 | EXPECT | |
272 | ok1 | |
273 | ok2 | |
274 | ok3 | |
275 | ok1 | |
276 | ok2 | |
277 | ######## | |
278 | ||
a95b6808 JH |
279 | --FILE-- abc15.pm |
280 | package abc15 ; | |
8d93267c GS |
281 | use warnings 'io' ; |
282 | sub check { | |
d3a7d8c7 | 283 | print "ok1\n" if ! warnings::enabled('all') ; |
8d93267c GS |
284 | print "ok2\n" if warnings::enabled("syntax") ; |
285 | print "ok3\n" if ! warnings::enabled("io") ; | |
286 | } | |
287 | 1; | |
a95b6808 | 288 | --FILE-- |
8d93267c | 289 | use warnings 'syntax' ; |
a95b6808 JH |
290 | use abc15 ; |
291 | sub fred { abc15::check() } | |
8d93267c GS |
292 | fred() ; |
293 | EXPECT | |
294 | ok1 | |
295 | ok2 | |
296 | ok3 | |
297 | ######## | |
298 | ||
a95b6808 JH |
299 | --FILE-- abc16.pm |
300 | package abc16 ; | |
8d93267c GS |
301 | use warnings 'io' ; |
302 | sub check { | |
d3a7d8c7 | 303 | print "ok1\n" if ! warnings::enabled('all') ; |
8d93267c GS |
304 | } |
305 | 1; | |
a95b6808 | 306 | --FILE-- |
8d93267c | 307 | use warnings 'syntax' ; |
a95b6808 JH |
308 | use abc16 ; |
309 | sub fred { no warnings ; abc16::check() } | |
8d93267c GS |
310 | fred() ; |
311 | EXPECT | |
312 | ok1 | |
313 | ######## | |
314 | ||
a95b6808 JH |
315 | --FILE-- abc17.pm |
316 | package abc17 ; | |
8d93267c GS |
317 | use warnings 'misc' ; |
318 | sub check { | |
d3a7d8c7 | 319 | print "ok1\n" if ! warnings::enabled('all') ; |
8d93267c GS |
320 | print "ok2\n" if warnings::enabled("syntax") ; |
321 | print "ok3\n" if warnings::enabled("io") ; | |
322 | print "ok4\n" if ! warnings::enabled("misc") ; | |
323 | } | |
324 | 1; | |
a95b6808 | 325 | --FILE-- |
8d93267c | 326 | use warnings 'syntax' ; |
a95b6808 JH |
327 | use abc17 ; |
328 | sub fred { use warnings 'io' ; abc17::check() } | |
8d93267c GS |
329 | fred() ; |
330 | EXPECT | |
331 | ok1 | |
332 | ok2 | |
333 | ok3 | |
334 | ok4 | |
335 | ######## | |
336 | ||
337 | # check warnings::warn | |
338 | use warnings ; | |
a95b6808 JH |
339 | eval { |
340 | warnings::warn() | |
c3186b65 | 341 | } ; |
8d93267c | 342 | print $@ ; |
a95b6808 JH |
343 | eval { |
344 | warnings::warn("fred", "joe") | |
c3186b65 | 345 | } ; |
8d93267c GS |
346 | print $@ ; |
347 | EXPECT | |
879b0cab Z |
348 | Usage: warnings::warn([category,] 'message') at - line 5. |
349 | Unknown warnings category 'fred' at - line 9. | |
7e6d00f8 PM |
350 | ######## |
351 | ||
352 | # check warnings::warnif | |
353 | use warnings ; | |
a95b6808 JH |
354 | eval { |
355 | warnings::warnif() | |
c3186b65 | 356 | } ; |
7e6d00f8 | 357 | print $@ ; |
a95b6808 JH |
358 | eval { |
359 | warnings::warnif("fred", "joe") | |
c3186b65 | 360 | } ; |
7e6d00f8 PM |
361 | print $@ ; |
362 | EXPECT | |
879b0cab Z |
363 | Usage: warnings::warnif([category,] 'message') at - line 5. |
364 | Unknown warnings category 'fred' at - line 9. | |
8d93267c GS |
365 | ######## |
366 | ||
a95b6808 JH |
367 | --FILE-- abc18.pm |
368 | package abc18 ; | |
8d93267c GS |
369 | use warnings 'misc' ; |
370 | sub check { warnings::warn("io", "hello") } | |
371 | 1; | |
372 | --FILE-- | |
373 | use warnings "io" ; | |
a95b6808 JH |
374 | use abc18; |
375 | abc18::check() ; | |
8d93267c | 376 | EXPECT |
879b0cab | 377 | hello at - line 3. |
8d93267c GS |
378 | ######## |
379 | ||
a95b6808 JH |
380 | --FILE-- abc19.pm |
381 | package abc19 ; | |
8d93267c GS |
382 | use warnings 'misc' ; |
383 | sub check { warnings::warn("misc", "hello") } | |
384 | 1; | |
385 | --FILE-- | |
386 | use warnings "io" ; | |
a95b6808 JH |
387 | use abc19; |
388 | abc19::check() ; | |
8d93267c | 389 | EXPECT |
879b0cab | 390 | hello at - line 3. |
8d93267c GS |
391 | ######## |
392 | ||
a95b6808 JH |
393 | --FILE-- abc20.pm |
394 | package abc20 ; | |
8d93267c GS |
395 | use warnings 'misc' ; |
396 | sub check { warnings::warn("io", "hello") } | |
397 | 1; | |
398 | --FILE-- | |
399 | use warnings qw( FATAL deprecated ) ; | |
a95b6808 JH |
400 | use abc20; |
401 | eval { | |
402 | abc20::check() ; | |
c3186b65 | 403 | } ; |
8d93267c GS |
404 | print "[[$@]]\n"; |
405 | EXPECT | |
879b0cab | 406 | hello at - line 4. |
8d93267c GS |
407 | [[]] |
408 | ######## | |
409 | ||
a95b6808 JH |
410 | --FILE-- abc21.pm |
411 | package abc21 ; | |
8d93267c GS |
412 | use warnings 'misc' ; |
413 | sub check { warnings::warn("io", "hello") } | |
414 | 1; | |
415 | --FILE-- | |
416 | use warnings qw( FATAL io ) ; | |
a95b6808 JH |
417 | use abc21; |
418 | eval { | |
419 | abc21::check() ; | |
c3186b65 | 420 | } ; |
8d93267c GS |
421 | print "[[$@]]\n"; |
422 | EXPECT | |
879b0cab | 423 | [[hello at - line 4. |
8d93267c | 424 | ]] |
d3a7d8c7 GS |
425 | ######## |
426 | -W | |
a95b6808 JH |
427 | --FILE-- abc22.pm |
428 | package abc22 ; | |
d3a7d8c7 GS |
429 | use warnings "io" ; |
430 | print "ok1\n" if warnings::enabled("io") ; | |
431 | print "ok2\n" if warnings::enabled("all") ; | |
432 | 1; | |
a95b6808 | 433 | --FILE-- |
d3a7d8c7 | 434 | no warnings; |
a95b6808 | 435 | use abc22 ; |
d3a7d8c7 GS |
436 | EXPECT |
437 | ok1 | |
438 | ok2 | |
439 | ######## | |
440 | -X | |
a95b6808 JH |
441 | --FILE-- abc23.pm |
442 | package abc23 ; | |
d3a7d8c7 GS |
443 | use warnings "io" ; |
444 | print "ok1\n" if !warnings::enabled("io") ; | |
445 | print "ok2\n" if !warnings::enabled("all") ; | |
446 | 1; | |
a95b6808 | 447 | --FILE-- |
d3a7d8c7 | 448 | use warnings; |
a95b6808 | 449 | use abc23 ; |
d3a7d8c7 GS |
450 | EXPECT |
451 | ok1 | |
452 | ok2 | |
453 | ######## | |
454 | ||
a95b6808 JH |
455 | --FILE-- abc24.pm |
456 | package abc24 ; | |
d3a7d8c7 GS |
457 | no warnings ; |
458 | sub check { | |
459 | print "ok\n" if ! warnings::enabled() ; | |
460 | } | |
461 | 1; | |
a95b6808 | 462 | --FILE-- |
d3a7d8c7 | 463 | use warnings 'syntax' ; |
a95b6808 JH |
464 | use abc24 ; |
465 | abc24::check() ; | |
d3a7d8c7 | 466 | EXPECT |
879b0cab | 467 | package 'abc24' not registered for warnings at abc24.pm line 4. |
7e6d00f8 PM |
468 | ######## |
469 | ||
a95b6808 JH |
470 | --FILE-- abc25.pm |
471 | package abc25 ; | |
7e6d00f8 PM |
472 | no warnings ; |
473 | sub check { | |
474 | warnings::warn("fred") ; | |
475 | } | |
476 | 1; | |
a95b6808 | 477 | --FILE-- |
7e6d00f8 | 478 | use warnings 'syntax' ; |
a95b6808 JH |
479 | use abc25 ; |
480 | abc25::check() ; | |
7e6d00f8 | 481 | EXPECT |
879b0cab | 482 | package 'abc25' not registered for warnings at abc25.pm line 4. |
7e6d00f8 PM |
483 | ######## |
484 | ||
a95b6808 JH |
485 | --FILE-- abc26.pm |
486 | package abc26 ; | |
7e6d00f8 PM |
487 | no warnings ; |
488 | sub check { | |
489 | warnings::warnif("fred") ; | |
490 | } | |
491 | 1; | |
a95b6808 | 492 | --FILE-- |
7e6d00f8 | 493 | use warnings 'syntax' ; |
a95b6808 JH |
494 | use abc26 ; |
495 | abc26::check() ; | |
7e6d00f8 | 496 | EXPECT |
879b0cab | 497 | package 'abc26' not registered for warnings at abc26.pm line 4. |
d3a7d8c7 GS |
498 | ######## |
499 | ||
a95b6808 JH |
500 | --FILE-- abc27.pm |
501 | package abc27 ; | |
d3a7d8c7 GS |
502 | use warnings 'io' ; |
503 | use warnings::register ; | |
504 | sub 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 | } | |
509 | 1; | |
a95b6808 | 510 | --FILE-- |
d3a7d8c7 | 511 | use warnings 'syntax' ; |
a95b6808 JH |
512 | use abc27 ; |
513 | use warnings 'abc27' ; | |
514 | abc27::check() ; | |
d3a7d8c7 GS |
515 | EXPECT |
516 | ok1 | |
517 | ok2 | |
518 | ok3 | |
519 | ######## | |
520 | ||
a95b6808 JH |
521 | --FILE-- abc28.pm |
522 | package abc28 ; | |
d3a7d8c7 GS |
523 | use warnings 'io' ; |
524 | use warnings::register ; | |
525 | sub check { | |
526 | print "ok1\n" if !warnings::enabled ; | |
527 | print "ok2\n" if warnings::enabled("syntax") ; | |
528 | print "ok3\n" if !warnings::enabled("io") ; | |
529 | } | |
530 | 1; | |
a95b6808 | 531 | --FILE-- |
d3a7d8c7 | 532 | use warnings 'syntax' ; |
a95b6808 JH |
533 | use abc28 ; |
534 | abc28::check() ; | |
d3a7d8c7 GS |
535 | EXPECT |
536 | ok1 | |
537 | ok2 | |
538 | ok3 | |
539 | ######## | |
540 | ||
a95b6808 JH |
541 | --FILE-- abc29.pm |
542 | package abc29 ; | |
d3a7d8c7 GS |
543 | no warnings ; |
544 | use warnings::register ; | |
545 | sub check { | |
546 | print "ok1\n" if warnings::enabled ; | |
547 | print "ok2\n" if warnings::enabled("syntax") ; | |
548 | } | |
549 | 1; | |
a95b6808 | 550 | --FILE-- |
d3a7d8c7 | 551 | use warnings 'syntax' ; |
a95b6808 JH |
552 | use abc29 ; |
553 | use warnings 'abc29' ; | |
554 | eval { abc29::check() ; }; | |
d3a7d8c7 GS |
555 | print $@ ; |
556 | EXPECT | |
557 | ok1 | |
558 | ok2 | |
559 | ######## | |
560 | ||
a95b6808 JH |
561 | --FILE-- abc30.pm |
562 | package abc30 ; | |
d3a7d8c7 GS |
563 | use warnings 'io' ; |
564 | use warnings::register ; | |
565 | sub 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 | } | |
570 | 1; | |
a95b6808 | 571 | --FILE-- |
d3a7d8c7 | 572 | use warnings 'syntax' ; |
a95b6808 JH |
573 | use abc30 ; |
574 | eval { abc30::check() ; } ; | |
d3a7d8c7 GS |
575 | print $@ ; |
576 | EXPECT | |
577 | ok1 | |
578 | ok2 | |
579 | ok3 | |
580 | ######## | |
581 | ||
a95b6808 JH |
582 | --FILE-- abc31.pm |
583 | package abc31 ; | |
d3a7d8c7 GS |
584 | use warnings 'io' ; |
585 | use warnings::register ; | |
586 | sub check { | |
587 | print "ok1\n" if warnings::enabled ; | |
588 | print "ok2\n" if warnings::enabled("syntax") ; | |
589 | print "ok3\n" if !warnings::enabled("io") ; | |
590 | } | |
591 | 1; | |
a95b6808 | 592 | --FILE-- |
d3a7d8c7 | 593 | use warnings 'syntax' ; |
a95b6808 JH |
594 | use abc31 ; |
595 | use warnings 'abc31' ; | |
596 | sub fred { abc31::check() } | |
d3a7d8c7 GS |
597 | fred() ; |
598 | EXPECT | |
599 | ok1 | |
600 | ok2 | |
601 | ok3 | |
602 | ######## | |
603 | ||
a95b6808 JH |
604 | --FILE-- abc32.pm |
605 | package abc32 ; | |
d3a7d8c7 GS |
606 | use warnings 'io' ; |
607 | use warnings::register ; | |
608 | sub check { | |
609 | print "ok1\n" if ! warnings::enabled ; | |
610 | } | |
611 | 1; | |
a95b6808 | 612 | --FILE-- |
d3a7d8c7 | 613 | use warnings 'syntax' ; |
a95b6808 JH |
614 | use abc32 ; |
615 | sub fred { no warnings ; abc32::check() } | |
d3a7d8c7 GS |
616 | fred() ; |
617 | EXPECT | |
618 | ok1 | |
619 | ######## | |
620 | ||
a95b6808 JH |
621 | --FILE-- abc33.pm |
622 | package abc33 ; | |
d3a7d8c7 GS |
623 | use warnings 'misc' ; |
624 | use warnings::register; | |
625 | sub check { | |
626 | print "ok1\n" if warnings::enabled ; | |
627 | print "ok2\n" if warnings::enabled("syntax") ; | |
628 | print "ok3\n" if warnings::enabled("io") ; | |
629 | print "ok4\n" if ! warnings::enabled("misc") ; | |
630 | } | |
631 | 1; | |
a95b6808 | 632 | --FILE-- |
d3a7d8c7 | 633 | use warnings 'syntax' ; |
a95b6808 JH |
634 | use abc33 ; |
635 | use warnings 'abc33' ; | |
636 | sub fred { use warnings 'io' ; abc33::check() } | |
d3a7d8c7 GS |
637 | fred() ; |
638 | EXPECT | |
639 | ok1 | |
640 | ok2 | |
641 | ok3 | |
642 | ok4 | |
643 | ######## | |
644 | ||
a95b6808 JH |
645 | --FILE-- abc34.pm |
646 | package abc34 ; | |
d3a7d8c7 GS |
647 | use warnings 'misc' ; |
648 | use warnings::register; | |
649 | sub check { warnings::warn("hello") } | |
650 | 1; | |
651 | --FILE-- | |
a95b6808 JH |
652 | use abc34; |
653 | use warnings "abc34" ; | |
654 | abc34::check() ; | |
d3a7d8c7 | 655 | EXPECT |
879b0cab | 656 | hello at - line 3. |
d3a7d8c7 GS |
657 | ######## |
658 | ||
a95b6808 JH |
659 | --FILE-- abc35.pm |
660 | package abc35 ; | |
d3a7d8c7 GS |
661 | use warnings::register; |
662 | sub check { warnings::warn("hello") } | |
663 | 1; | |
664 | --FILE-- | |
a95b6808 JH |
665 | use abc35; |
666 | abc35::check() ; | |
d3a7d8c7 | 667 | EXPECT |
879b0cab | 668 | hello at - line 2. |
d3a7d8c7 GS |
669 | ######## |
670 | ||
a95b6808 JH |
671 | --FILE-- abc36.pm |
672 | package abc36 ; | |
d3a7d8c7 GS |
673 | use warnings::register ; |
674 | sub check { warnings::warn("hello") } | |
675 | 1; | |
676 | --FILE-- | |
a95b6808 | 677 | use abc36; |
d3a7d8c7 | 678 | use warnings qw( FATAL deprecated ) ; |
c3186b65 | 679 | eval { |
a95b6808 | 680 | abc36::check() ; |
c3186b65 | 681 | } ; |
d3a7d8c7 GS |
682 | print "[[$@]]\n"; |
683 | EXPECT | |
879b0cab | 684 | hello at - line 4. |
d3a7d8c7 GS |
685 | [[]] |
686 | ######## | |
687 | ||
a95b6808 JH |
688 | --FILE-- abc37.pm |
689 | package abc37 ; | |
d3a7d8c7 GS |
690 | use warnings::register ; |
691 | sub check { warnings::warn("hello") } | |
692 | 1; | |
693 | --FILE-- | |
a95b6808 JH |
694 | use abc37; |
695 | use warnings qw( FATAL abc37 ) ; | |
696 | eval { | |
697 | abc37::check() ; | |
c3186b65 | 698 | } ; |
d3a7d8c7 GS |
699 | print "[[$@]]\n"; |
700 | EXPECT | |
879b0cab | 701 | [[hello at - line 4. |
d3a7d8c7 GS |
702 | ]] |
703 | ######## | |
704 | -W | |
a95b6808 JH |
705 | --FILE-- abc38.pm |
706 | package abc38 ; | |
d3a7d8c7 GS |
707 | use warnings "io" ; |
708 | use warnings::register ; | |
a95b6808 | 709 | sub check { |
d3a7d8c7 GS |
710 | print "ok1\n" if warnings::enabled() ; |
711 | print "ok2\n" if warnings::enabled("io") ; | |
712 | print "ok3\n" if warnings::enabled("all") ; | |
713 | } | |
714 | 1; | |
a95b6808 | 715 | --FILE-- |
d3a7d8c7 | 716 | no warnings; |
a95b6808 JH |
717 | use abc38 ; |
718 | abc38::check() ; | |
d3a7d8c7 GS |
719 | EXPECT |
720 | ok1 | |
721 | ok2 | |
722 | ok3 | |
723 | ######## | |
724 | -X | |
a95b6808 JH |
725 | --FILE-- abc39.pm |
726 | package abc39 ; | |
d3a7d8c7 GS |
727 | use warnings "io" ; |
728 | use warnings::register ; | |
a95b6808 | 729 | sub check { |
d3a7d8c7 GS |
730 | print "ok1\n" if !warnings::enabled() ; |
731 | print "ok2\n" if !warnings::enabled("io") ; | |
732 | print "ok3\n" if !warnings::enabled("all") ; | |
733 | } | |
734 | 1; | |
a95b6808 | 735 | --FILE-- |
d3a7d8c7 | 736 | no warnings; |
a95b6808 JH |
737 | use abc39 ; |
738 | abc39::check() ; | |
d3a7d8c7 GS |
739 | EXPECT |
740 | ok1 | |
741 | ok2 | |
742 | ok3 | |
743 | ######## | |
744 | ||
a95b6808 JH |
745 | --FILE-- abc40.pm |
746 | package abc40 ; | |
d3a7d8c7 GS |
747 | use warnings "io" ; |
748 | use warnings::register ; | |
a95b6808 | 749 | sub check { |
d3a7d8c7 GS |
750 | print "ok1\n" if warnings::enabled() ; |
751 | print "ok2\n" if warnings::enabled("io") ; | |
752 | print "ok3\n" if warnings::enabled("all") ; | |
753 | } | |
754 | 1; | |
a95b6808 | 755 | --FILE-- |
d3a7d8c7 | 756 | use warnings 'all'; |
a95b6808 JH |
757 | use abc40 ; |
758 | abc40::check() ; | |
d3a7d8c7 GS |
759 | EXPECT |
760 | ok1 | |
761 | ok2 | |
762 | ok3 | |
763 | ######## | |
764 | ||
a95b6808 JH |
765 | --FILE-- abc41.pm |
766 | package abc41 ; | |
d3a7d8c7 GS |
767 | use warnings "io" ; |
768 | use warnings::register ; | |
a95b6808 | 769 | sub check { |
d3a7d8c7 GS |
770 | print "ok1\n" if !warnings::enabled() ; |
771 | print "ok2\n" if !warnings::enabled("io") ; | |
772 | print "ok3\n" if !warnings::enabled("all") ; | |
773 | } | |
774 | 1; | |
a95b6808 JH |
775 | --FILE-- |
776 | use abc41 ; | |
d3a7d8c7 | 777 | no warnings ; |
a95b6808 | 778 | abc41::check() ; |
d3a7d8c7 GS |
779 | EXPECT |
780 | ok1 | |
781 | ok2 | |
782 | ok3 | |
783 | ######## | |
784 | ||
a95b6808 JH |
785 | --FILE-- abc42.pm |
786 | package abc42 ; | |
d3a7d8c7 GS |
787 | use warnings "io" ; |
788 | use warnings::register ; | |
a95b6808 | 789 | sub check { |
d3a7d8c7 GS |
790 | print "ok1\n" if !warnings::enabled() ; |
791 | print "ok2\n" if !warnings::enabled("io") ; | |
792 | print "ok3\n" if !warnings::enabled("all") ; | |
7e6d00f8 | 793 | warnings::warnif("my message 1") ; |
a95b6808 | 794 | warnings::warnif('abc42', "my message 2") ; |
7e6d00f8 PM |
795 | warnings::warnif('io', "my message 3") ; |
796 | warnings::warnif('all', "my message 4") ; | |
d3a7d8c7 GS |
797 | } |
798 | 1; | |
a95b6808 JH |
799 | --FILE-- |
800 | use abc42 ; | |
801 | use warnings 'abc42'; | |
d3a7d8c7 | 802 | no warnings ; |
a95b6808 | 803 | abc42::check() ; |
d3a7d8c7 GS |
804 | EXPECT |
805 | ok1 | |
806 | ok2 | |
807 | ok3 | |
808 | ######## | |
809 | ||
a95b6808 JH |
810 | --FILE-- abc43.pm |
811 | package abc43 ; | |
d3a7d8c7 GS |
812 | use warnings "io" ; |
813 | use warnings::register ; | |
a95b6808 JH |
814 | sub check { |
815 | print "abc43 self" . (warnings::enabled() ? "" : " not") . " enabled\n" ; | |
816 | print "abc43 def" . (warnings::enabled('def') ? "" : " not") . " enabled\n" ; | |
817 | print "abc43 all" . (warnings::enabled('all') ? "" : " not") . " enabled\n" ; | |
d3a7d8c7 GS |
818 | } |
819 | 1; | |
820 | --FILE-- def.pm | |
821 | package def ; | |
822 | use warnings "io" ; | |
823 | use warnings::register ; | |
a95b6808 | 824 | sub check { |
d3a7d8c7 | 825 | print "def self" . (warnings::enabled() ? "" : " not") . " enabled\n" ; |
a95b6808 | 826 | print "def abc43" . (warnings::enabled('abc43') ? "" : " not") . " enabled\n" ; |
d3a7d8c7 GS |
827 | print "def all" . (warnings::enabled('all') ? "" : " not") . " enabled\n" ; |
828 | } | |
829 | 1; | |
a95b6808 JH |
830 | --FILE-- |
831 | use abc43 ; | |
d3a7d8c7 | 832 | use def ; |
a95b6808 JH |
833 | use warnings 'abc43'; |
834 | abc43::check() ; | |
d3a7d8c7 | 835 | def::check() ; |
a95b6808 | 836 | no warnings 'abc43' ; |
d3a7d8c7 | 837 | use warnings 'def' ; |
a95b6808 | 838 | abc43::check() ; |
d3a7d8c7 | 839 | def::check() ; |
a95b6808 | 840 | use warnings 'abc43' ; |
d3a7d8c7 | 841 | use warnings 'def' ; |
a95b6808 | 842 | abc43::check() ; |
d3a7d8c7 | 843 | def::check() ; |
a95b6808 | 844 | no warnings 'abc43' ; |
d3a7d8c7 | 845 | no warnings 'def' ; |
a95b6808 | 846 | abc43::check() ; |
d3a7d8c7 GS |
847 | def::check() ; |
848 | use warnings; | |
a95b6808 | 849 | abc43::check() ; |
d3a7d8c7 | 850 | def::check() ; |
a95b6808 JH |
851 | no warnings 'abc43' ; |
852 | abc43::check() ; | |
d3a7d8c7 GS |
853 | def::check() ; |
854 | EXPECT | |
a95b6808 JH |
855 | abc43 self enabled |
856 | abc43 def not enabled | |
857 | abc43 all not enabled | |
d3a7d8c7 | 858 | def self not enabled |
a95b6808 | 859 | def abc43 enabled |
d3a7d8c7 | 860 | def all not enabled |
a95b6808 JH |
861 | abc43 self not enabled |
862 | abc43 def enabled | |
863 | abc43 all not enabled | |
d3a7d8c7 | 864 | def self enabled |
a95b6808 | 865 | def abc43 not enabled |
d3a7d8c7 | 866 | def all not enabled |
a95b6808 JH |
867 | abc43 self enabled |
868 | abc43 def enabled | |
869 | abc43 all not enabled | |
d3a7d8c7 | 870 | def self enabled |
a95b6808 | 871 | def abc43 enabled |
d3a7d8c7 | 872 | def all not enabled |
a95b6808 JH |
873 | abc43 self not enabled |
874 | abc43 def not enabled | |
875 | abc43 all not enabled | |
d3a7d8c7 | 876 | def self not enabled |
a95b6808 | 877 | def abc43 not enabled |
d3a7d8c7 | 878 | def all not enabled |
a95b6808 JH |
879 | abc43 self enabled |
880 | abc43 def enabled | |
881 | abc43 all enabled | |
d3a7d8c7 | 882 | def self enabled |
a95b6808 | 883 | def abc43 enabled |
d3a7d8c7 | 884 | def all enabled |
a95b6808 JH |
885 | abc43 self not enabled |
886 | abc43 def enabled | |
006c1a1d | 887 | abc43 all enabled |
d3a7d8c7 | 888 | def self enabled |
a95b6808 | 889 | def abc43 not enabled |
006c1a1d | 890 | def all enabled |
114bafba GS |
891 | ######## |
892 | -w | |
a95b6808 JH |
893 | --FILE-- abc44.pm |
894 | package abc44 ; | |
114bafba GS |
895 | no warnings ; |
896 | use warnings::register ; | |
a95b6808 | 897 | sub check { |
114bafba GS |
898 | print "ok1\n" if warnings::enabled() ; |
899 | print "ok2\n" if warnings::enabled("io") ; | |
900 | print "ok3\n" if warnings::enabled("all") ; | |
901 | } | |
902 | 1; | |
a95b6808 JH |
903 | --FILE-- |
904 | use abc44 ; | |
905 | abc44::check() ; | |
114bafba GS |
906 | EXPECT |
907 | ok1 | |
908 | ok2 | |
909 | ok3 | |
910 | ######## | |
911 | -w | |
a95b6808 JH |
912 | --FILE-- abc45.pm |
913 | package abc45 ; | |
114bafba GS |
914 | no warnings ; |
915 | use warnings::register ; | |
a95b6808 | 916 | sub check { |
114bafba GS |
917 | print "ok1\n" if !warnings::enabled() ; |
918 | print "ok2\n" if !warnings::enabled("io") ; | |
919 | print "ok3\n" if !warnings::enabled("all") ; | |
920 | } | |
921 | 1; | |
a95b6808 JH |
922 | --FILE-- |
923 | use abc45 ; | |
924 | use warnings 'abc45'; | |
114bafba | 925 | no warnings ; |
a95b6808 | 926 | abc45::check() ; |
114bafba GS |
927 | EXPECT |
928 | ok1 | |
929 | ok2 | |
930 | ok3 | |
931 | ######## | |
932 | ||
a95b6808 JH |
933 | --FILE-- abc46.pm |
934 | package abc46 ; | |
114bafba GS |
935 | no warnings ; |
936 | use warnings::register ; | |
a95b6808 | 937 | sub check { |
114bafba GS |
938 | print "ok1\n" if !warnings::enabled() ; |
939 | print "ok2\n" if !warnings::enabled("io") ; | |
940 | print "ok3\n" if !warnings::enabled("all") ; | |
7e6d00f8 | 941 | warnings::warnif("my message 1") ; |
a95b6808 | 942 | warnings::warnif('abc46', "my message 2") ; |
7e6d00f8 PM |
943 | warnings::warnif('io', "my message 3") ; |
944 | warnings::warnif('all', "my message 4") ; | |
114bafba GS |
945 | } |
946 | 1; | |
a95b6808 JH |
947 | --FILE-- |
948 | use abc46 ; | |
949 | use warnings 'abc46'; | |
114bafba GS |
950 | no warnings ; |
951 | BEGIN { $^W = 1 ; } | |
a95b6808 | 952 | abc46::check() ; |
114bafba GS |
953 | EXPECT |
954 | ok1 | |
955 | ok2 | |
956 | ok3 | |
957 | ######## | |
958 | ||
a95b6808 JH |
959 | --FILE-- abc47.pm |
960 | package abc47 ; | |
114bafba GS |
961 | no warnings ; |
962 | use warnings::register ; | |
a95b6808 | 963 | sub check { |
114bafba GS |
964 | print "ok1\n" if !warnings::enabled() ; |
965 | print "ok2\n" if !warnings::enabled("io") ; | |
966 | print "ok3\n" if !warnings::enabled("all") ; | |
967 | } | |
968 | 1; | |
a95b6808 JH |
969 | --FILE-- |
970 | use abc47 ; | |
971 | use warnings 'abc47'; | |
114bafba GS |
972 | no warnings ; |
973 | $^W = 1 ; | |
a95b6808 | 974 | abc47::check() ; |
114bafba GS |
975 | EXPECT |
976 | ok1 | |
977 | ok2 | |
978 | ok3 | |
7e6d00f8 PM |
979 | ######## |
980 | ||
a95b6808 | 981 | --FILE-- abc48.pm |
a781f7c3 | 982 | $| = 1; |
a95b6808 | 983 | package abc48 ; |
7e6d00f8 PM |
984 | no warnings ; |
985 | use warnings::register ; | |
a95b6808 | 986 | sub check { |
7e6d00f8 PM |
987 | print "ok1\n" if warnings::enabled() ; |
988 | print "ok2\n" if !warnings::enabled("io") ; | |
989 | print "ok3\n" if !warnings::enabled("all") ; | |
a95b6808 | 990 | print "ok4\n" if warnings::enabled("abc48") ; |
7e6d00f8 PM |
991 | warnings::warn("my message 1") ; |
992 | warnings::warnif("my message 2") ; | |
a95b6808 | 993 | warnings::warnif('abc48', "my message 3") ; |
7e6d00f8 PM |
994 | warnings::warnif('io', "my message 4") ; |
995 | warnings::warnif('all', "my message 5") ; | |
996 | } | |
997 | sub in2 { no warnings ; check() } | |
998 | sub in1 { no warnings ; in2() } | |
999 | 1; | |
a95b6808 JH |
1000 | --FILE-- |
1001 | use abc48 ; | |
1002 | use warnings 'abc48'; | |
1003 | abc48::in1() ; | |
7e6d00f8 | 1004 | EXPECT |
7e6d00f8 PM |
1005 | ok1 |
1006 | ok2 | |
1007 | ok3 | |
1008 | ok4 | |
879b0cab Z |
1009 | my message 1 at - line 3. |
1010 | my message 2 at - line 3. | |
1011 | my message 3 at - line 3. | |
7e6d00f8 PM |
1012 | ######## |
1013 | ||
1014 | --FILE-- def.pm | |
1015 | package def ; | |
1016 | no warnings ; | |
1017 | use warnings::register ; | |
a95b6808 | 1018 | sub check { |
7e6d00f8 PM |
1019 | print "ok1\n" if warnings::enabled() ; |
1020 | print "ok2\n" if !warnings::enabled("io") ; | |
1021 | print "ok3\n" if !warnings::enabled("all") ; | |
1022 | print "ok4\n" if warnings::enabled("def") ; | |
1023 | warnings::warn("my message 1") ; | |
1024 | warnings::warnif("my message 2") ; | |
1025 | warnings::warnif('def', "my message 3") ; | |
1026 | warnings::warnif('io', "my message 4") ; | |
1027 | warnings::warnif('all', "my message 5") ; | |
1028 | } | |
1029 | sub in2 { no warnings ; check() } | |
1030 | sub in1 { no warnings ; in2() } | |
1031 | 1; | |
a95b6808 | 1032 | --FILE-- abc49.pm |
a781f7c3 | 1033 | $| = 1; |
a95b6808 | 1034 | package abc49 ; |
7e6d00f8 PM |
1035 | use def ; |
1036 | use warnings 'def'; | |
1037 | sub in1 { def::in1() ; } | |
1038 | 1; | |
a95b6808 JH |
1039 | --FILE-- |
1040 | use abc49 ; | |
7e6d00f8 | 1041 | no warnings; |
a95b6808 | 1042 | abc49::in1() ; |
7e6d00f8 | 1043 | EXPECT |
7e6d00f8 PM |
1044 | ok1 |
1045 | ok2 | |
1046 | ok3 | |
1047 | ok4 | |
879b0cab Z |
1048 | my message 1 at abc49.pm line 5. |
1049 | my message 2 at abc49.pm line 5. | |
1050 | my message 3 at abc49.pm line 5. | |
7e6d00f8 PM |
1051 | ######## |
1052 | ||
1053 | --FILE-- def.pm | |
a781f7c3 | 1054 | $| = 1; |
7e6d00f8 PM |
1055 | package def ; |
1056 | no warnings ; | |
1057 | use warnings::register ; | |
1058 | require Exporter; | |
1059 | @ISA = qw( Exporter ) ; | |
1060 | @EXPORT = qw( in1 ) ; | |
a95b6808 | 1061 | sub check { |
7e6d00f8 PM |
1062 | print "ok1\n" if warnings::enabled() ; |
1063 | print "ok2\n" if !warnings::enabled("io") ; | |
1064 | print "ok3\n" if !warnings::enabled("all") ; | |
a95b6808 | 1065 | print "ok4\n" if warnings::enabled("abc50") ; |
7e6d00f8 PM |
1066 | print "ok5\n" if !warnings::enabled("def") ; |
1067 | warnings::warn("my message 1") ; | |
1068 | warnings::warnif("my message 2") ; | |
a95b6808 | 1069 | warnings::warnif('abc50', "my message 3") ; |
7e6d00f8 PM |
1070 | warnings::warnif('def', "my message 4") ; |
1071 | warnings::warnif('io', "my message 5") ; | |
1072 | warnings::warnif('all', "my message 6") ; | |
1073 | } | |
1074 | sub in2 { no warnings ; check() } | |
1075 | sub in1 { no warnings ; in2() } | |
1076 | 1; | |
a95b6808 JH |
1077 | --FILE-- abc50.pm |
1078 | package abc50 ; | |
7e6d00f8 PM |
1079 | use warnings::register ; |
1080 | use def ; | |
1081 | #@ISA = qw(def) ; | |
1082 | 1; | |
a95b6808 JH |
1083 | --FILE-- |
1084 | use abc50 ; | |
7e6d00f8 | 1085 | no warnings; |
a95b6808 JH |
1086 | use warnings 'abc50'; |
1087 | abc50::in1() ; | |
7e6d00f8 | 1088 | EXPECT |
7e6d00f8 PM |
1089 | ok2 |
1090 | ok3 | |
1091 | ok4 | |
1092 | ok5 | |
879b0cab Z |
1093 | my message 1 at - line 4. |
1094 | my message 3 at - line 4. | |
7e6d00f8 PM |
1095 | ######## |
1096 | ||
1097 | --FILE-- def.pm | |
1098 | package def ; | |
1099 | no warnings ; | |
1100 | use warnings::register ; | |
1101 | ||
1102 | sub new | |
1103 | { | |
1104 | my $class = shift ; | |
1105 | bless [], $class ; | |
1106 | } | |
1107 | ||
a95b6808 JH |
1108 | sub check |
1109 | { | |
7e6d00f8 PM |
1110 | my $self = shift ; |
1111 | print "ok1\n" if !warnings::enabled() ; | |
1112 | print "ok2\n" if !warnings::enabled("io") ; | |
1113 | print "ok3\n" if !warnings::enabled("all") ; | |
a95b6808 | 1114 | print "ok4\n" if warnings::enabled("abc51") ; |
7e6d00f8 PM |
1115 | print "ok5\n" if !warnings::enabled("def") ; |
1116 | print "ok6\n" if warnings::enabled($self) ; | |
1117 | ||
1118 | warnings::warn("my message 1") ; | |
1119 | warnings::warn($self, "my message 2") ; | |
1120 | ||
1121 | warnings::warnif("my message 3") ; | |
a95b6808 | 1122 | warnings::warnif('abc51', "my message 4") ; |
7e6d00f8 PM |
1123 | warnings::warnif('def', "my message 5") ; |
1124 | warnings::warnif('io', "my message 6") ; | |
1125 | warnings::warnif('all', "my message 7") ; | |
1126 | warnings::warnif($self, "my message 8") ; | |
1127 | } | |
a95b6808 | 1128 | sub in2 |
7e6d00f8 | 1129 | { |
a95b6808 | 1130 | no warnings ; |
7e6d00f8 PM |
1131 | my $self = shift ; |
1132 | $self->check() ; | |
1133 | } | |
a95b6808 JH |
1134 | sub in1 |
1135 | { | |
7e6d00f8 PM |
1136 | no warnings ; |
1137 | my $self = shift ; | |
1138 | $self->in2(); | |
1139 | } | |
1140 | 1; | |
a95b6808 | 1141 | --FILE-- abc51.pm |
a781f7c3 | 1142 | $| = 1; |
a95b6808 | 1143 | package abc51 ; |
7e6d00f8 PM |
1144 | use warnings::register ; |
1145 | use def ; | |
1146 | @ISA = qw(def) ; | |
1147 | sub new | |
1148 | { | |
1149 | my $class = shift ; | |
1150 | bless [], $class ; | |
1151 | } | |
1152 | ||
1153 | 1; | |
a95b6808 JH |
1154 | --FILE-- |
1155 | use abc51 ; | |
7e6d00f8 | 1156 | no warnings; |
a95b6808 JH |
1157 | use warnings 'abc51'; |
1158 | $a = new abc51 ; | |
7e6d00f8 PM |
1159 | $a->in1() ; |
1160 | print "**\n"; | |
1161 | $b = new def ; | |
1162 | $b->in1() ; | |
1163 | EXPECT | |
7e6d00f8 PM |
1164 | ok1 |
1165 | ok2 | |
1166 | ok3 | |
1167 | ok4 | |
1168 | ok5 | |
1169 | ok6 | |
879b0cab Z |
1170 | my message 1 at - line 5. |
1171 | my message 2 at - line 5. | |
1172 | my message 4 at - line 5. | |
1173 | my message 8 at - line 5. | |
7e6d00f8 PM |
1174 | ** |
1175 | ok1 | |
1176 | ok2 | |
1177 | ok3 | |
1178 | ok4 | |
1179 | ok5 | |
879b0cab Z |
1180 | my message 1 at - line 8. |
1181 | my message 2 at - line 8. | |
1182 | my message 4 at - line 8. | |
4f527b71 AS |
1183 | ######## |
1184 | ||
572bfd36 RS |
1185 | --FILE-- abc52.pm |
1186 | package abc52 ; | |
1187 | use warnings::register ('foo', 'bar'); | |
1188 | sub check { | |
1189 | warnings::warnif('abc52', "hello"); | |
1190 | warnings::warnif('abc52::foo', "hello foo"); | |
1191 | warnings::warnif('abc52::bar', "hello bar"); | |
1192 | } | |
1193 | 1; | |
1194 | --FILE-- | |
1195 | use abc52; | |
1196 | use warnings("abc52", "abc52::bar"); | |
1197 | abc52::check() ; | |
1198 | EXPECT | |
879b0cab Z |
1199 | hello at - line 3. |
1200 | hello bar at - line 3. | |
572bfd36 RS |
1201 | ######## |
1202 | ||
4f527b71 AS |
1203 | --FILE-- |
1204 | # test for bug [perl #15395] | |
1205 | my ( $warn_cat, # warning category we'll try to control | |
1206 | $warn_msg, # the error message to catch | |
1207 | ); | |
1208 | ||
1209 | package SomeModule; | |
1210 | use warnings::register; | |
1211 | ||
1212 | BEGIN { | |
1213 | $warn_cat = __PACKAGE__; | |
1214 | $warn_msg = 'from ' . __PACKAGE__; | |
1215 | } | |
1216 | ||
1217 | # a sub that generates a random warning | |
1218 | sub gen_warning { | |
1219 | warnings::warnif( $warn_msg ); | |
1220 | } | |
1221 | ||
1222 | package ClientModule; | |
1223 | # use SomeModule; (would go here) | |
1224 | our @CARP_NOT = ( $warn_cat ); # deliver warnings to *our* client | |
1225 | ||
1226 | # call_warner provokes a warning. It is delivered to its caller, | |
1227 | # who should also be able to control it | |
1228 | sub call_warner { | |
1229 | SomeModule::gen_warning(); | |
1230 | } | |
1231 | ||
1232 | # user | |
1233 | ||
1234 | package main; | |
1235 | my $warn_line = __LINE__ + 3; # this line should be in the error message | |
1236 | eval { | |
1237 | use warnings FATAL => $warn_cat; # we want to know if this works | |
1238 | ClientModule::call_warner(); | |
1239 | }; | |
1240 | ||
1241 | # have we caught an error, and is it the one we generated? | |
1242 | print "ok1\n" if $@ =~ /$warn_msg/; | |
1243 | ||
1244 | # does it indicate the right line? | |
a95b6808 | 1245 | print "ok2\n" if $@ =~ /line $warn_line/; |
4f527b71 AS |
1246 | EXPECT |
1247 | ok1 | |
1248 | ok2 | |
68a00014 AR |
1249 | ######## |
1250 | ||
1251 | --FILE-- fatal1.pm | |
1252 | package fatal1 ; | |
1253 | no warnings ; | |
1254 | print "ok1\n" if !warnings::fatal_enabled('all') ; | |
1255 | print "ok2\n" if !warnings::fatal_enabled("syntax") ; | |
1256 | 1; | |
1257 | --FILE-- | |
1258 | use fatal1 ; | |
1259 | EXPECT | |
1260 | ok1 | |
1261 | ok2 | |
1262 | ######## | |
1263 | ||
1264 | --FILE-- fatal2.pm | |
1265 | package fatal2; | |
1266 | no warnings ; | |
1267 | print "ok1\n" if !warnings::fatal_enabled('all') ; | |
1268 | print "ok2\n" if warnings::fatal_enabled("syntax") ; | |
1269 | 1; | |
1270 | --FILE-- | |
1271 | use warnings FATAL => 'syntax' ; | |
1272 | use fatal2 ; | |
1273 | EXPECT | |
1274 | ok1 | |
1275 | ok2 | |
1276 | ######## | |
1277 | ||
1278 | --FILE-- fatal3.pm | |
1279 | package fatal3 ; | |
1280 | no warnings ; | |
1281 | print "ok1\n" if warnings::fatal_enabled('all') ; | |
1282 | print "ok2\n" if warnings::fatal_enabled("syntax") ; | |
1283 | 1; | |
1284 | --FILE-- | |
1285 | use warnings FATAL => 'all' ; | |
1286 | use fatal3 ; | |
1287 | EXPECT | |
1288 | ok1 | |
1289 | ok2 | |
1290 | ######## | |
1291 | ||
1292 | --FILE-- fatal4.pm | |
1293 | package fatal4 ; | |
1294 | no warnings ; | |
006c1a1d | 1295 | print "ok1\n" if warnings::fatal_enabled('all') ; |
68a00014 AR |
1296 | print "ok2\n" if warnings::fatal_enabled("void") ; |
1297 | print "ok3\n" if !warnings::fatal_enabled("syntax") ; | |
1298 | 1; | |
1299 | --FILE-- | |
1300 | use warnings FATAL => 'all', NONFATAL => 'syntax' ; | |
1301 | use fatal4 ; | |
1302 | EXPECT | |
1303 | ok1 | |
1304 | ok2 | |
1305 | ok3 | |
006c1a1d Z |
1306 | ######## |
1307 | { Quux::quux(); } | |
1308 | { no warnings; Quux::quux(); } | |
1309 | { no warnings; use warnings "void"; Quux::quux(); } | |
1310 | { use warnings; Quux::quux(); } | |
1311 | { use warnings; no warnings "void"; Quux::quux(); } | |
1312 | use warnings (); | |
c9cfa0d2 | 1313 | BEGIN { warnings::register_categories(qw(wibble wobble wabble wubble webble)); } |
006c1a1d Z |
1314 | package Quux { |
1315 | sub quux { | |
1316 | warnings::warnif($_, "My $_ is flanged") | |
c9cfa0d2 | 1317 | foreach qw(wibble wobble wabble wubble webble); |
006c1a1d Z |
1318 | (); |
1319 | } | |
1320 | } | |
1321 | { Quux::quux(); } | |
1322 | { no warnings; Quux::quux(); } | |
1323 | { no warnings; use warnings "void"; Quux::quux(); } | |
1324 | { use warnings; Quux::quux(); } | |
1325 | { use warnings; no warnings "void"; Quux::quux(); } | |
c9cfa0d2 | 1326 | { no warnings; use warnings qw(wibble wabble webble); Quux::quux(); } |
006c1a1d | 1327 | { no warnings; use warnings qw(wobble wubble); Quux::quux(); } |
c9cfa0d2 | 1328 | { use warnings; no warnings qw(wibble wabble webble); Quux::quux(); } |
006c1a1d | 1329 | { use warnings; no warnings qw(wobble wubble); Quux::quux(); } |
c9cfa0d2 Z |
1330 | { use warnings qw(wubble NONFATAL void); Quux::quux(); } |
1331 | { use warnings qw(wubble); no warnings "void"; Quux::quux(); } | |
1332 | { no warnings "webble"; Quux::quux(); } | |
1333 | { use warnings qw(NONFATAL webble); Quux::quux(); } | |
1334 | print "done\n"; | |
006c1a1d Z |
1335 | EXPECT |
1336 | My wibble is flanged at - line 4. | |
1337 | My wobble is flanged at - line 4. | |
1338 | My wabble is flanged at - line 4. | |
1339 | My wubble is flanged at - line 4. | |
c9cfa0d2 | 1340 | My webble is flanged at - line 4. |
006c1a1d Z |
1341 | My wibble is flanged at - line 5. |
1342 | My wobble is flanged at - line 5. | |
1343 | My wabble is flanged at - line 5. | |
1344 | My wubble is flanged at - line 5. | |
c9cfa0d2 | 1345 | My webble is flanged at - line 5. |
006c1a1d Z |
1346 | My wibble is flanged at - line 18. |
1347 | My wobble is flanged at - line 18. | |
1348 | My wabble is flanged at - line 18. | |
1349 | My wubble is flanged at - line 18. | |
c9cfa0d2 | 1350 | My webble is flanged at - line 18. |
006c1a1d Z |
1351 | My wibble is flanged at - line 19. |
1352 | My wobble is flanged at - line 19. | |
1353 | My wabble is flanged at - line 19. | |
1354 | My wubble is flanged at - line 19. | |
c9cfa0d2 | 1355 | My webble is flanged at - line 19. |
006c1a1d Z |
1356 | My wibble is flanged at - line 20. |
1357 | My wabble is flanged at - line 20. | |
c9cfa0d2 | 1358 | My webble is flanged at - line 20. |
006c1a1d Z |
1359 | My wobble is flanged at - line 21. |
1360 | My wubble is flanged at - line 21. | |
1361 | My wobble is flanged at - line 22. | |
1362 | My wubble is flanged at - line 22. | |
1363 | My wibble is flanged at - line 23. | |
1364 | My wabble is flanged at - line 23. | |
c9cfa0d2 Z |
1365 | My webble is flanged at - line 23. |
1366 | My wubble is flanged at - line 24. | |
1367 | My wubble is flanged at - line 25. | |
1368 | My webble is flanged at - line 27. | |
1369 | done | |
c4583f59 FC |
1370 | ######## |
1371 | # NAME _at_level | |
1372 | select STDERR; | |
1373 | { use warnings "utf8"; foo() } | |
1374 | sub foo { use warnings "syntax"; bar() } | |
1375 | sub bar { | |
1376 | use warnings "unpack"; | |
1377 | local $\="\n"; | |
1378 | print "1. ", warnings::enabled_at_level("unpack", 0)||0; | |
1379 | print "2. ", warnings::enabled_at_level("unpack", 1)||0; | |
1380 | print "3. ", warnings::enabled_at_level("unpack", 2)||0; | |
1381 | print "4. ", warnings::enabled_at_level("syntax", 0)||0; | |
1382 | print "5. ", warnings::enabled_at_level("syntax", 1)||0; | |
1383 | print "6. ", warnings::enabled_at_level("syntax", 2)||0; | |
1384 | print "7. ", warnings::enabled_at_level("utf8", 0)||0; | |
1385 | print "8. ", warnings::enabled_at_level("utf8", 1)||0; | |
1386 | print "9. ", warnings::enabled_at_level("utf8", 2)||0; | |
1387 | warnings::warn_at_level ("misc",0,"A mandatory foo warning"); | |
1388 | warnings::warn_at_level ("misc",1,"A mandatory top-level warning"); | |
1389 | warnings::warnif_at_level("syntax",0,"A conditional syntax warning"); | |
1390 | warnings::warnif_at_level("syntax",1,"A conditional syntax warning"); | |
1391 | warnings::warnif_at_level("utf8",0,"A conditional utf8 warning"); | |
1392 | warnings::warnif_at_level("utf8",1,"A conditional utf8 warning"); | |
1393 | } | |
1394 | { use warnings "syntax"; use warnings FATAL => "utf8"; foo2() } | |
1395 | sub foo2 { | |
1396 | use warnings FATAL => "syntax"; use warnings "utf8"; bar2() | |
1397 | } | |
1398 | sub bar2 { | |
1399 | $\="\n"; | |
1400 | print "10. ", warnings::fatal_enabled_at_level("syntax", 0)||0; | |
1401 | print "11. ", warnings::fatal_enabled_at_level("syntax", 1)||0; | |
1402 | print "12. ", warnings::fatal_enabled_at_level("utf8", 0)||0; | |
1403 | print "13. ", warnings::fatal_enabled_at_level("utf8", 1)||0; | |
1404 | undef $\; | |
1405 | eval { warnings::warn_at_level ("syntax",1,"A fatal warning") }; | |
1406 | print "Died: $@" if $@; | |
1407 | eval { warnings::warnif_at_level("syntax",1,"A fatal syntax warning") }; | |
1408 | print "Died: $@" if $@; | |
1409 | eval { warnings::warnif_at_level("syntax",2,"A syntax warning") }; | |
1410 | print "Died: $@" if $@; | |
1411 | eval { warnings::warnif_at_level("utf8",1,"A utf8 warning") }; | |
1412 | print "Died: $@" if $@; | |
1413 | eval { warnings::warnif_at_level("utf8",2,"A fatal utf8 warning") }; | |
1414 | print "Died: $@" if $@; | |
1415 | } | |
1416 | EXPECT | |
1417 | 1. 0 | |
1418 | 2. 0 | |
1419 | 3. 0 | |
1420 | 4. 1 | |
1421 | 5. 0 | |
1422 | 6. 0 | |
1423 | 7. 0 | |
1424 | 8. 1 | |
1425 | 9. 0 | |
1426 | A mandatory foo warning at - line 3. | |
1427 | A mandatory top-level warning at - line 2. | |
1428 | A conditional syntax warning at - line 3. | |
1429 | A conditional utf8 warning at - line 2. | |
1430 | 10. 1 | |
1431 | 11. 0 | |
1432 | 12. 0 | |
1433 | 13. 1 | |
1434 | Died: A fatal warning at - line 25. | |
1435 | Died: A fatal syntax warning at - line 25. | |
1436 | A syntax warning at - line 23. | |
1437 | A utf8 warning at - line 25. | |
1438 | Died: A fatal utf8 warning at - line 23. | |
a7caeb5e FC |
1439 | ######## |
1440 | # NAME _at_level with filehandle | |
1441 | use warnings; | |
1442 | # Create temp file for testing handles. | |
1443 | open oUt, ">tmp" or die $!; | |
1444 | print oUt "foo\nbar\n"; | |
1445 | close oUt; | |
1446 | sub bimp { | |
1447 | open FH, "tmp"; | |
1448 | <FH>; <FH>; | |
1449 | warnings::warn_at_level("syntax", 0, "Foo warning"); | |
1450 | close FH; | |
1451 | warnings::warn_at_level("syntax", 0, "Bar warning"); | |
1452 | }; | |
1453 | bimp; | |
1454 | EXPECT | |
1455 | Foo warning at - line 13, <FH> line 2. | |
1456 | Bar warning at - line 13. | |
a0da1e16 FC |
1457 | ######## |
1458 | # NAME _at_level with chunky filehandle | |
1459 | use warnings; | |
1460 | # Create temp file for testing handles. | |
1461 | open oUt, ">tmp" or die $!; | |
1462 | print oUt "foo7bar7"; | |
1463 | close oUt; | |
1464 | sub bimp { | |
1465 | open FH, "tmp"; | |
1466 | $/ = 7; | |
1467 | <FH>; <FH>; | |
1468 | warnings::warn_at_level("syntax", 0, "Foo warning"); | |
1469 | close FH; | |
1470 | warnings::warn_at_level("syntax", 0, "Bar warning"); | |
1471 | }; | |
1472 | bimp; | |
1473 | EXPECT | |
1474 | Foo warning at - line 14, <FH> chunk 2. | |
1475 | Bar warning at - line 14. |