From: Ricardo Signes Date: Tue, 29 Dec 2009 13:16:24 +0000 (-0500) Subject: dial back warnings on UNIVERSAL->import X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=252143cdf7e8cbc8993bacb85f05a8b3df8685d6;p=p5sagit%2Fp5-mst-13.2.git 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) --- diff --git a/lib/UNIVERSAL.pm b/lib/UNIVERSAL.pm index 5e3c8c8..64224e5 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 a24d7aa..d74686f 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