diff options
Diffstat (limited to 't')
-rw-r--r-- | t/op/method.t | 18 |
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"; } +} |