summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2016-02-10 11:46:48 +1100
committerTony Cook <tony@develop-help.com>2016-02-10 14:30:44 +1100
commit7db8c4f1f19e6f855107ec990507a1a9cb0f59a6 (patch)
treefae60e2a52bf4d148450e8709dd528bfa5b8b6c2 /t
parentf94c6c536844091ca6a005e3e0398db8e1cc212e (diff)
downloadperl-7db8c4f1f19e6f855107ec990507a1a9cb0f59a6.tar.gz
[perl #127494] TODO test for $AUTOLOAD being set for DESTROY
000814da allowed the cached DESTROY method to be an AUTOLOAD method, but didn't ensure that $AUTOLOAD (or the equivalent for XS AUTOLOADS) was set when AUTOLOAD was called. Add a TODO test for this behaviour.
Diffstat (limited to 't')
-rw-r--r--t/op/method.t22
1 files changed, 21 insertions, 1 deletions
diff --git a/t/op/method.t b/t/op/method.t
index d11a7038c3..2a6b3996cb 100644
--- a/t/op/method.t
+++ b/t/op/method.t
@@ -13,7 +13,7 @@ BEGIN {
use strict;
no warnings 'once';
-plan(tests => 149);
+plan(tests => 150);
@A::ISA = 'B';
@B::ISA = 'C';
@@ -469,6 +469,26 @@ is $kalled, 1, 'calling a class method via a magic variable';
package main;
bless {}, "AutoloadDestroy";
ok($autoloaded, "AUTOLOAD called for DESTROY");
+
+ # 127494 - AUTOLOAD for DESTROY was called without setting $AUTOLOAD
+ local $::TODO = "caching of AUTOLOAD for DESTROY didn't set \$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 {} };