diff options
author | Ricardo Signes <rjbs@cpan.org> | 2009-12-29 08:16:24 -0500 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2010-01-03 15:45:40 +0100 |
commit | 252143cdf7e8cbc8993bacb85f05a8b3df8685d6 (patch) | |
tree | 12ca7c37a3144cdddfef3fba03d4a5ce9cd47528 | |
parent | ac1cbfb08dc1370fbe2937f6bdd95a86fa70bce4 (diff) | |
download | perl-252143cdf7e8cbc8993bacb85f05a8b3df8685d6.tar.gz |
dial back warnings on UNIVERSAL->import
still warn on UNIVERSAL->import(@args)
do not warn on UNIVERSAL->import; this means "use UNIVERSAL;" is
still accepted without warning (for better or worse)
-rw-r--r-- | lib/UNIVERSAL.pm | 1 | ||||
-rw-r--r-- | t/op/universal.t | 11 |
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/UNIVERSAL.pm b/lib/UNIVERSAL.pm index 5e3c8c833c..64224e5122 100644 --- a/lib/UNIVERSAL.pm +++ b/lib/UNIVERSAL.pm @@ -15,6 +15,7 @@ require Exporter; # anything unless called on UNIVERSAL. sub import { return unless $_[0] eq __PACKAGE__; + return unless @_ > 1; require warnings; warnings::warnif( 'deprecated', diff --git a/t/op/universal.t b/t/op/universal.t index a24d7aabb9..d74686f97d 100644 --- a/t/op/universal.t +++ b/t/op/universal.t @@ -10,7 +10,7 @@ BEGIN { require "./test.pl"; } -plan tests => 123; +plan tests => 124; $a = {}; bless $a, "Bob"; @@ -249,9 +249,14 @@ use warnings "deprecated"; { my $m; local $SIG{__WARN__} = sub { $m = $_[0] }; - eval "use UNIVERSAL"; + eval "use UNIVERSAL 'can'"; like($m, qr/^UNIVERSAL->import is deprecated/, - "deprecation warning for UNIVERSAL->import"); + "deprecation warning for UNIVERSAL->import('can')"); + + undef $m; + eval "use UNIVERSAL"; + is($m, undef, + "no deprecation warning for UNIVERSAL->import"); } # Test: [perl #66112]: change @ISA inside sub isa |