summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorRicardo Signes <rjbs@cpan.org>2010-09-08 16:40:26 -0400
committerRicardo Signes <rjbs@cpan.org>2010-09-10 11:06:27 -0400
commit572bfd364a342a66f375085e1dff02253f3de103 (patch)
tree7ca1c0e3b11092e921e8f02976913e8ca6106720 /t
parent3167abe51b640d3c3589b1f66145bedb05d9405f (diff)
downloadperl-572bfd364a342a66f375085e1dff02253f3de103.tar.gz
improve registration of warning categories
1. &warnings::register is added as the public mechanism for adding new warning categories, rather than warnings::register::import knowing about warnings's internals 2. warnings::register::import is updated to use &warnings::register 3. warnings::register::import can take a list of subcategories The upshot is that you can now write: package MyTool; use warnings::register qw(io typos); warnings::warnif('MyTool::io', $message); ...and tools that register new warnings categories do not need to cargo cult code from warnings/register.pm
Diffstat (limited to 't')
-rw-r--r--t/lib/warnings/9enabled18
1 files changed, 18 insertions, 0 deletions
diff --git a/t/lib/warnings/9enabled b/t/lib/warnings/9enabled
index a535689bad..68b0a27da3 100644
--- a/t/lib/warnings/9enabled
+++ b/t/lib/warnings/9enabled
@@ -1181,6 +1181,24 @@ my message 2 at - line 8
my message 4 at - line 8
########
+--FILE-- abc52.pm
+package abc52 ;
+use warnings::register ('foo', 'bar');
+sub check {
+ warnings::warnif('abc52', "hello");
+ warnings::warnif('abc52::foo', "hello foo");
+ warnings::warnif('abc52::bar', "hello bar");
+}
+1;
+--FILE--
+use abc52;
+use warnings("abc52", "abc52::bar");
+abc52::check() ;
+EXPECT
+hello at - line 3
+hello bar at - line 3
+########
+
--FILE--
# test for bug [perl #15395]
my ( $warn_cat, # warning category we'll try to control