diff options
author | Father Chrysostomos <sprout@cpan.org> | 2010-10-12 10:13:58 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2010-10-12 12:52:12 -0700 |
commit | d056e33c1ea02abb0c031adb18b181624282ba3c (patch) | |
tree | be509216d46bd9a97ddb6013ce278f4f104d5f68 /t | |
parent | 11f9f0eda0026b9120e2ceb1b15c72667d1c91ac (diff) | |
download | perl-d056e33c1ea02abb0c031adb18b181624282ba3c.tar.gz |
Reset isa caches on nonexistent substashes when stash trees are moved
This fixes the problem of isa cache linearisations’ and method caches’
not being reset on nonexistent packages when they are replaced with
real packages as a result of parent stashes’ being moved. This can
happen in cases like this:
@left::ISA = 'outer::inner';
@right::ISA = 'clone::inner';
{package outer::inner}
*clone:: = \%outer::;
print "ok 1", "\n" if left->isa("clone::inner");
print "ok 2", "\n" if right->isa("outer::inner");
This changes mro_package_moved’s parameter list as documented in the
diff for mro.c. See also the new comments in that function.
Diffstat (limited to 't')
-rw-r--r-- | t/mro/package_aliases.t | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/t/mro/package_aliases.t b/t/mro/package_aliases.t index c06013d0f6..3f13a7650d 100644 --- a/t/mro/package_aliases.t +++ b/t/mro/package_aliases.t @@ -10,7 +10,7 @@ BEGIN { use strict; use warnings; -plan(tests => 12); +plan(tests => 15); { package New; @@ -127,6 +127,49 @@ for( "replacing nested packages by $$_{name} updates isa caches"; } +# Another nested package test, in which the isa cache needs to be reset on +# the subclass of a package that does not exist. +# +# Parenthesized packages do not exist. +# +# outer::inner ( clone::inner ) +# | | +# left right +# +# outer -> clone +# +# This test assigns outer:: to clone::, making clone::inner an alias to +# outer::inner. +for( + { + name => 'assigning a glob to a glob', + code => '*clone:: = *outer::', + }, + { + name => 'assigning a string to a glob', + code => '*clone:: = "outer::"', + }, + { + name => 'assigning a stashref to a glob', + code => '*clone:: = \%outer::', + }, +) { + fresh_perl_is + q~ + @left::ISA = 'outer::inner'; + @right::ISA = 'clone::inner'; + {package outer::inner} + + __code__; + + print "ok 1", "\n" if left->isa("clone::inner"); + print "ok 2", "\n" if right->isa("outer::inner"); + ~ =~ s\__code__\$$_{code}\r, + "ok 1\nok 2\n", + {}, + "replacing nonexistent nested packages by $$_{name} updates isa caches"; +} + # Test that deleting stash elements containing # subpackages also invalidates the isa cache. # Maybe this does not belong in package_aliases.t, but it is closely |