use strict;
use warnings;
-use Test::More tests => 10;
+use Test::More tests => 14;
use Variable::Magic qw/wizard cast dispell/;
my @x = (0) x 12;
sub check {
- for (0 .. 11) { return 0 unless $c[$_] == $x[$_]; }
- return 1;
+ is join(':', map { (defined) ? $_ : 'u' } @c[0 .. 11]),
+ join(':', map { (defined) ? $_ : 'u' } @x[0 .. 11]),
+ $_[0];
}
my $i = -1;
store => sub { ++$c[9] },
'exists' => sub { ++$c[10] },
'delete' => sub { ++$c[11] };
-ok(check(), 'code : create wizard');
+check('code : create wizard');
my $x = 0;
-my $n = sub { ++$x };
-my $a = $n;
+sub hlagh { ++$x };
-cast $a, $wiz;
-ok(check(), 'code : cast');
+cast &hlagh, $wiz;
+check('code : cast');
-my $b = $a;
-++$x[0];
-ok(check(), 'code : assign to');
+hlagh();
+check('code : call without arguments');
+is($x, 1, 'code : call without arguments succeeded');
-$b = "X${a}Y";
-++$x[0];
-ok(check(), 'code : interpolate');
+hlagh(1, 2, 3);
+check('code : call with arguments');
+is($x, 2, 'code : call with arguments succeeded');
-$b = \$a;
-ok(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];
-ok(check(), 'code : assign');
+my $y = 0;
+*hlagh = sub { ++$y };
-$a->();
-ok(check(), 'code : call');
+cast &hlagh, $wiz;
+check('code : re-cast');
-{
- my $b = $n;
- cast $b, $wiz;
-}
-++$x[4];
-ok(check(), 'code : scope end');
+my $r = \&hlagh;
+check('code : take reference');
-undef $a;
-++$x[1];
-ok(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;
-ok(check(), 'code : dispell');
+dispell &hlagh, $wiz;
+check('code : dispell');