summaryrefslogtreecommitdiff
path: root/t/mro
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-08-17 23:58:47 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-08-17 23:58:47 -0700
commitc716b3beb77406159d18fd52251821fee641f9fc (patch)
treeb3304d82ae5b06d3fb56209a905aaf1554e33599 /t/mro
parentbe9260535f65befe9615312821574755a8d04344 (diff)
downloadperl-c716b3beb77406159d18fd52251821fee641f9fc.tar.gz
[perl #114864] Make UNIVERSAL::DESTROY changes invalidate caches
Commit 8c34e50d inadvertently caused DESTROY caches not to be reset when UNIVERSAL::DESTROY changes. Normally, a change to a method will cause mro_method_changed_in to be called on all subclasses, but mro.c cheats for UNIVERSAL and just does ++PL_sub_generation. So clearing the DESTROY cache explicitly in mro_method_changed_in is clearly not enough.
Diffstat (limited to 't/mro')
-rw-r--r--t/mro/basic.t16
1 files changed, 15 insertions, 1 deletions
diff --git a/t/mro/basic.t b/t/mro/basic.t
index ab34fc2567..be49f9ab1f 100644
--- a/t/mro/basic.t
+++ b/t/mro/basic.t
@@ -3,7 +3,7 @@
use strict;
use warnings;
-BEGIN { require q(./test.pl); } plan(tests => 59);
+BEGIN { require q(./test.pl); } plan(tests => 60);
require mro;
@@ -370,3 +370,17 @@ is(eval { MRO_N->testfunc() }, 123);
}
is "il"->can("tomatoes"), "puree", 'local *ISA=[] unwinding';
}
+
+# Changes to UNIVERSAL::DESTROY should not leave stale DESTROY caches
+# (part of #114864)
+our $destroy_output;
+sub UNIVERSAL::DESTROY { $destroy_output = "old" }
+my $x = bless[];
+undef $x; # cache the DESTROY method
+undef *UNIVERSAL::DESTROY;
+*UNIVERSAL::DESTROY = sub { $destroy_output = "new" };
+$x = bless[];
+undef $x; # should use the new DESTROY
+is $destroy_output, "new",
+ 'Changes to UNIVERSAL::DESTROY invalidate DESTROY caches';
+undef *UNIVERSAL::DESTROY;