From: Vincent Pit Date: Sat, 28 Mar 2009 01:01:55 +0000 (+0100) Subject: Test (lack of) stash magic for dynamic method calls X-Git-Tag: v0.34~4 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FVariable-Magic.git;a=commitdiff_plain;h=9fc034651e3b744e316d0de98c5f9054ede59752 Test (lack of) stash magic for dynamic method calls --- diff --git a/t/35-stash.t b/t/35-stash.t index f52dd32..43155eb 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 => 29; + plan tests => 33; $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{ my $meth = 'shoot'; Hlagh->$meth() }; + + is $@, '', 'stash: valid dynamic method call ran fine'; + is_deeply \%mg, { + store => [ qw/shoot/ ], + }, 'stash: valid dynamic method call'; +} + { local %mg; @@ -119,7 +130,7 @@ cast %Hlagh::, $wiz; is $@, '', 'inherited valid method call ran fine'; is_deeply \%mg, { fetch => [ qw/ISA shoot/ ], - }, 'stash: direct method call'; + }, 'stash: inherited valid method call'; } { @@ -134,6 +145,17 @@ cast %Hlagh::, $wiz; }, 'stash: invalid method call'; } +{ + local %mg; + + eval q{ my $meth = 'unknown_too'; Hlagh->$meth() }; + + like $@, qr/^Can't locate object method "unknown_too" via package "Hlagh"/, 'stash: invalid dynamic method call croaked'; + is_deeply \%mg, { + store => [ qw/unknown_too AUTOLOAD/ ], + }, 'stash: invalid dynamic method call'; +} + { local %mg;