diff options
-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 |