X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F27-local.t;h=27dfd8bc2a9556451ac6f001aff0f1e2a76a2d1e;hb=d8122850f4c201c5b849cebb1f9b7f2630ae4c15;hp=7d5f88bab4b9685d63ec0045d490aebcca055beb;hpb=183e73e0590b46550dfa6fdd4b6cf3280c1a5877;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/27-local.t b/t/27-local.t index 7d5f88b..27dfd8b 100644 --- a/t/27-local.t +++ b/t/27-local.t @@ -5,34 +5,25 @@ use warnings; 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');