This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #127351] TODO tests for arrayref assigned to *Foo::ISA issues
authorTony Cook <tony@develop-help.com>
Tue, 26 Jan 2016 04:22:46 +0000 (15:22 +1100)
committerTony Cook <tony@develop-help.com>
Tue, 2 Feb 2016 05:16:53 +0000 (16:16 +1100)
t/mro/basic.t

index d5663f4..f68637a 100644 (file)
@@ -9,7 +9,7 @@ BEGIN {
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
-plan(tests => 64);
+plan(tests => 66);
 
 require mro;
 
 
 require mro;
 
@@ -433,3 +433,37 @@ delete $Bar::{ISA};
 print "ok\n";
 PROG
 }
 print "ok\n";
 PROG
 }
+
+{
+    # [perl #127351]
+    local $::TODO = "assignment to *Foo::ISA doesn't magicalize elements";
+    # *Foo::ISA = \@some_array
+    # didn't magicalize the elements of @some_array, causing two
+    # problems:
+
+    #  a) assignment to those elements didn't update the cache
+
+    fresh_perl_is(<<'PROG', "foo\nother", {}, "magical *ISA = arrayref elements");
+*My::Parent::foo = sub { "foo" };
+*My::OtherParent::foo = sub { "other" };
+my $x = [ "My::Parent" ];
+*Fake::ISA = $x;
+print Fake->foo, "\n";
+$x->[0] = "My::OtherParent";
+print Fake->foo, "\n";
+PROG
+
+    #  b) code that attempted to remove the magic when @some_array
+    #     was no longer an @ISA asserted/crashed
+
+    fresh_perl_is(<<'PROG', "foo", {}, "unmagicalize *ISA elements");
+{
+    local *My::Parent::foo = sub { "foo" };
+    my $x = [ "My::Parent" ];
+    *Fake::ISA = $x;
+    print Fake->foo, "\n";
+    my $s = \%Fake::;
+    delete $s->{ISA};
+}
+PROG
+}