X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F27-local.t;h=650e115e70647969e6dfba78b56742bc16cce2bb;hb=ed45fb4404201c2e17ffa5c26a2320ceeb132e61;hp=7d5f88bab4b9685d63ec0045d490aebcca055beb;hpb=183e73e0590b46550dfa6fdd4b6cf3280c1a5877;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/27-local.t b/t/27-local.t index 7d5f88b..650e115 100644 --- a/t/27-local.t +++ b/t/27-local.t @@ -5,34 +5,22 @@ use warnings; use Test::More; -use Variable::Magic qw/wizard cast dispell MGf_LOCAL/; +use Variable::Magic qw/cast MGf_LOCAL/; -if (!MGf_LOCAL) { - plan skip_all => "this perl doesn't handle local magic"; +if (MGf_LOCAL) { + plan tests => 2 * 3 + 1 + 1; } else { - plan tests => 5; + plan skip_all => 'No local magic for this perl'; } -my $c = 0; -my $wiz = wizard 'local' => sub { ++$c }; -ok($c == 0, 'local : create wizard'); +use lib 't/lib'; +use Variable::Magic::TestWatcher; -my $n = int rand 1000; -local $a = $n; +my $wiz = init 'local', 'local'; -cast $a, $wiz; -ok($c == 0, 'local : cast'); +our $a = int rand 1000; -{ - local $a; - ok($c == 1, 'local : localize casted variable'); -} - -dispell $a, $wiz; -ok($c == 1, 'local : dispell'); - -{ - local $a; - ok($c == 1, 'local : localize dispelled variable'); -} +my $res = check { cast $a, $wiz } { }, 'cast'; +ok $res, 'local: cast succeeded'; +check { local $a } { local => 1 }, 'localized';