summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorBrian Fraser <fraserbn@gmail.com>2012-02-02 01:10:52 -0300
committerFather Chrysostomos <sprout@cpan.org>2012-02-01 22:48:12 -0800
commit544b72e211918ad31f28016f717b20ba90b96f69 (patch)
treeb5e327dc8f772542aa31b0532f48ab88c7fe6f59 /t
parent3979f7aef8d6d86eeeeb9a45397a2f561e3508ab (diff)
downloadperl-544b72e211918ad31f28016f717b20ba90b96f69.tar.gz
t/op/method.t: Add tests for subless AUTOLOAD and DESTROY
Diffstat (limited to 't')
-rw-r--r--t/op/method.t18
1 files changed, 17 insertions, 1 deletions
diff --git a/t/op/method.t b/t/op/method.t
index 13547bc993..3339ddedcf 100644
--- a/t/op/method.t
+++ b/t/op/method.t
@@ -13,7 +13,7 @@ BEGIN {
use strict;
no warnings 'once';
-plan(tests => 91);
+plan(tests => 95);
@A::ISA = 'B';
@B::ISA = 'C';
@@ -388,3 +388,19 @@ is $kalled, 1, 'calling a class method via a magic variable';
ok eval { () = main->lbiggles(local($foo,$bar)); 1 },
'foo->lv(local($foo,$bar)) is not called in lvalue context';
}
+
+{
+ # AUTOLOAD and DESTROY can be declared without a leading sub,
+ # like BEGIN and friends.
+ package NoSub;
+
+ eval 'AUTOLOAD { our $AUTOLOAD; return $AUTOLOAD }';
+ ::ok( !$@, "AUTOLOAD without a leading sub is legal" );
+
+ eval "DESTROY { ::pass( q!DESTROY without a leading sub is legal and gets called! ) }";
+ {
+ ::ok( NoSub->can("AUTOLOAD"), "...and sets up an AUTOLOAD normally" );
+ ::is( eval { NoSub->bluh }, "NoSub::bluh", "...which works as expected" );
+ }
+ { bless {}, "NoSub"; }
+}