use Test::More;
-use Variable::Magic qw/wizard cast dispell MGf_LOCAL/;
+use Variable::Magic qw/wizard cast MGf_LOCAL/;
-if (!MGf_LOCAL) {
- plan skip_all => "this perl doesn't handle local magic";
-} else {
+if (MGf_LOCAL) {
plan tests => 5;
+} else {
+ plan skip_all => 'No local magic for this perl';
}
my $c = 0;
my $wiz = wizard 'local' => sub { ++$c };
-ok($c == 0, 'local : create wizard');
-
-my $n = int rand 1000;
-local $a = $n;
+is($c, 0, 'local : create wizard');
-cast $a, $wiz;
-ok($c == 0, 'local : cast');
+local $a = int rand 1000;
+my $res = cast $a, $wiz;
+ok($res, 'local : cast succeeded');
+is($c, 0, 'local : cast didn\'t triggered the callback');
{
local $a;
- ok($c == 1, 'local : localize casted variable');
+ is($c, 1, 'local : localized');
}
-
-dispell $a, $wiz;
-ok($c == 1, 'local : dispell');
-
-{
- local $a;
- ok($c == 1, 'local : localize dispelled variable');
-}
-
+is($c, 1, 'local : end of local scope');