From: Vincent Pit Date: Fri, 15 May 2009 17:10:10 +0000 (+0200) Subject: Test repeated method calls on stashes X-Git-Tag: v0.35~3 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=d28cecdc3dfdb6efa07bde117ee3e69bba34f4f9;p=perl%2Fmodules%2FVariable-Magic.git Test repeated method calls on stashes When an inherited method is called several times, method cache kicks in and magic isn't triggered anymore. --- diff --git a/t/35-stash.t b/t/35-stash.t index 43155eb..93bd62c 100644 --- a/t/35-stash.t +++ b/t/35-stash.t @@ -9,7 +9,7 @@ use Variable::Magic qw/wizard cast dispell VMG_UVAR VMG_OP_INFO_NAME VMG_OP_INFO my $run; if (VMG_UVAR) { - plan tests => 33; + plan tests => 41; $run = 1; } else { plan skip_all => 'uvar magic is required to test symbol table hooks'; @@ -106,6 +106,17 @@ cast %Hlagh::, $wiz; }, 'stash: valid method call'; } +{ + local %mg; + + eval q{ Hlagh->shoot() }; + + is $@, '', 'stash: second valid method call ran fine'; + is_deeply \%mg, { + fetch => [ qw/shoot/ ], + }, 'stash: second valid method call'; +} + { local %mg; @@ -124,15 +135,44 @@ cast %Hlagh::, $wiz; package Hlagher; our @ISA; BEGIN { @ISA = 'Hlagh' } - Hlagher->shoot() + Hlagher->leave() ]; is $@, '', 'inherited valid method call ran fine'; is_deeply \%mg, { - fetch => [ qw/ISA shoot/ ], + fetch => [ qw/ISA leave/ ], }, 'stash: inherited valid method call'; } +{ + local %mg; + + eval q{ Hlagher->leave() }; + + is $@, '', 'second inherited valid method call ran fine'; + is_deeply \%mg, { }, 'stash: second inherited valid method call doesn\'t call magic'; +} + +{ + local %mg; + + eval q{ Hlagher->shoot() }; + + is $@, '', 'inherited previously called valid method call ran fine'; + is_deeply \%mg, { + fetch => [ qw/shoot/ ], + }, 'stash: inherited previously called valid method call'; +} + +{ + local %mg; + + eval q{ Hlagher->shoot() }; + + is $@, '', 'second inherited previously called valid method call ran fine'; + is_deeply \%mg, { }, 'stash: second inherited previously called valid method call doesn\'t call magic'; +} + { local %mg;