diff options
author | Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> | 2014-06-08 01:37:32 +0100 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2014-07-21 11:55:18 +1000 |
commit | 1178d2cf03fa59bca77887516dd7d996bb17357c (patch) | |
tree | acd04470a73c7b6ca353b0841a1e4565910a2abf /t | |
parent | e81c4bddb20ee382f91769de9a783a3a2a3b0489 (diff) | |
download | perl-1178d2cf03fa59bca77887516dd7d996bb17357c.tar.gz |
Disallow importing functions from UNIVERSAL
It's been deprecated since v5.12.
Diffstat (limited to 't')
-rw-r--r-- | t/op/universal.t | 26 | ||||
-rw-r--r-- | t/uni/universal.t | 12 |
2 files changed, 10 insertions, 28 deletions
diff --git a/t/op/universal.t b/t/op/universal.t index 50d1782384..494bc99de7 100644 --- a/t/op/universal.t +++ b/t/op/universal.t @@ -10,7 +10,7 @@ BEGIN { require "./test.pl"; } -plan tests => 144; +plan tests => 143; $a = {}; bless $a, "Bob"; @@ -137,12 +137,10 @@ ok ! (eval { aversion->VERSION(2.719) }); like $@, qr/^Invalid version format/; my $subs = join ' ', sort grep { defined &{"UNIVERSAL::$_"} } keys %UNIVERSAL::; -## The test for import here is *not* because we want to ensure that UNIVERSAL -## can always import; it is an historical accident that UNIVERSAL can import. if ('a' lt 'A') { - is $subs, "can import isa DOES VERSION"; + is $subs, "can isa DOES VERSION"; } else { - is $subs, "DOES VERSION can import isa"; + is $subs, "DOES VERSION can isa"; } ok $a->isa("UNIVERSAL"); @@ -178,16 +176,6 @@ ok ! $a->can("export_tags"); # a method in Exporter ok ! UNIVERSAL::isa("\xff\xff\xff\0", 'HASH'); { - package Pickup; - no warnings "deprecated"; - use UNIVERSAL qw( isa can VERSION ); - - ::ok isa "Pickup", UNIVERSAL; - ::cmp_ok can( "Pickup", "can" ), '==', \&UNIVERSAL::can; - ::ok VERSION "UNIVERSAL" ; -} - -{ # test isa() and can() on magic variables "Human" =~ /(.*)/; ok $1->isa("Human"); @@ -274,11 +262,15 @@ use warnings "deprecated"; my $m; local $SIG{__WARN__} = sub { $m = $_[0] }; eval "use UNIVERSAL 'can'"; - like($m, qr/^UNIVERSAL->import is deprecated/, - "deprecation warning for UNIVERSAL->import('can')"); + like($@, qr/^UNIVERSAL does not export anything\b/, + "error for UNIVERSAL->import('can')"); + is($m, undef, + "no deprecation warning for UNIVERSAL->import('can')"); undef $m; eval "use UNIVERSAL"; + is($@, "", + "no error for UNIVERSAL->import"); is($m, undef, "no deprecation warning for UNIVERSAL->import"); } diff --git a/t/uni/universal.t b/t/uni/universal.t index 626c30f857..c999dd812b 100644 --- a/t/uni/universal.t +++ b/t/uni/universal.t @@ -13,7 +13,7 @@ BEGIN { use utf8; use open qw( :utf8 :std ); -plan tests => 93; +plan tests => 90; $a = {}; bless $a, "Bòb"; @@ -117,16 +117,6 @@ cmp_ok UNIVERSAL::can(Àlìcè => "can"), '==', \&UNIVERSAL::can; eval 'sub UNIVERSAL::slèèp {}'; ok $a->can("slèèp"); -{ - package Pìckùp; - no warnings "deprecated"; - use UNIVERSAL qw( isa can VERSION ); - - ::ok isa "Pìckùp", UNIVERSAL; - ::cmp_ok can( "Pìckùp", "can" ), '==', \&UNIVERSAL::can; - ::ok VERSION "UNIVERSAL" ; -} - package Fòò; sub DOES { 1 } |