]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - t/33-code.t
Importing Variable-Magic-0.16.tar.gz
[perl/modules/Variable-Magic.git] / t / 33-code.t
index 40c32a4b00fff8e0cd40bf1ac1afbdbb884f64e4..4b9cd207ee1c801feb41e28b766057fdc2f1964d 100644 (file)
@@ -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');