X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/0cd52e23ae641a766983833dc8b37b743474be9e..958cdeac409681891afe77bf60db047296523465:/t/op/method.t diff --git a/t/op/method.t b/t/op/method.t index 0d7f254..b915306 100644 --- a/t/op/method.t +++ b/t/op/method.t @@ -13,7 +13,7 @@ BEGIN { use strict; no warnings 'once'; -plan(tests => 148); +plan(tests => 150); @A::ISA = 'B'; @B::ISA = 'C'; @@ -361,6 +361,7 @@ for my $meth (['Bar', 'Foo::Bar'], { fresh_perl_is(<$meth->[0](); EOT @@ -460,6 +461,35 @@ is $kalled, 1, 'calling a class method via a magic variable'; { bless {}, "NoSub"; } } +{ + # [perl #124387] + my $autoloaded; + package AutoloadDestroy; + sub AUTOLOAD { $autoloaded = 1 } + package main; + bless {}, "AutoloadDestroy"; + ok($autoloaded, "AUTOLOAD called for DESTROY"); + + # 127494 - AUTOLOAD for DESTROY was called without setting $AUTOLOAD + my %methods; + package AutoloadDestroy2; + sub AUTOLOAD { + our $AUTOLOAD; + (my $method = $AUTOLOAD) =~ s/.*:://; + ++$methods{$method}; + } + package main; + # this cached AUTOLOAD as the DESTROY method + bless {}, "AutoloadDestroy2"; + %methods = (); + my $o = bless {}, "AutoloadDestroy2"; + # this sets $AUTOLOAD to "AutoloadDestroy2::foo" + $o->foo; + # this would call AUTOLOAD without setting $AUTOLOAD + undef $o; + ok($methods{DESTROY}, "\$AUTOLOAD set correctly for DESTROY"); +} + eval { () = 3; new {} }; like $@, qr/^Can't call method "new" without a package or object reference/,