X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F33-code.t;h=4b9cd207ee1c801feb41e28b766057fdc2f1964d;hb=c471e8c9f86ad8817761816101358f8ae1035915;hp=40c32a4b00fff8e0cd40bf1ac1afbdbb884f64e4;hpb=91aec4cfae75e61ff8eeb79448501a8739b0d240;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/33-code.t b/t/33-code.t index 40c32a4..4b9cd20 100644 --- a/t/33-code.t +++ b/t/33-code.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 10; +use Test::More tests => 14; use Variable::Magic qw/wizard cast dispell/; @@ -32,40 +32,37 @@ my $wiz = wizard get => sub { ++$c[0] }, check('code : create wizard'); my $x = 0; -my $n = sub { ++$x }; -my $a = $n; +sub hlagh { ++$x }; -cast $a, $wiz; +cast &hlagh, $wiz; check('code : cast'); -my $b = $a; -++$x[0]; -check('code : assign to'); +hlagh(); +check('code : call without arguments'); +is($x, 1, 'code : call without arguments succeeded'); -$b = "X${a}Y"; -++$x[0]; -check('code : interpolate'); +hlagh(1, 2, 3); +check('code : call with arguments'); +is($x, 2, 'code : call with arguments succeeded'); -$b = \$a; -check('code : reference'); +undef *hlagh; +++$x[4]; +check('code : undef symbol table'); +is($x, 2, 'code : undef symbol table didn\'t call'); -$a = $n; -++$x[1]; -check('code : assign'); +my $y = 0; +*hlagh = sub { ++$y }; -$a->(); -check('code : call'); +cast &hlagh, $wiz; +check('code : re-cast'); -{ - my $b = $n; - cast $b, $wiz; -} -++$x[4]; -check('code : scope end'); +my $r = \&hlagh; +check('code : take reference'); -undef $a; -++$x[1]; -check('code : undef'); +$r->(); +check('code : call reference'); +is($y, 1, 'code : call reference succeeded'); +is($x, 2, 'code : call reference didn\'t triggered the previous code'); -dispell $a, $wiz; +dispell &hlagh, $wiz; check('code : dispell');