X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F27-local.t;h=d15ba198b1e96b6413bfdab3a68ef64bbcb69f57;hb=9dce2bfe18bcd7d9914310c81b8832d40fb04fbb;hp=7d5f88bab4b9685d63ec0045d490aebcca055beb;hpb=183e73e0590b46550dfa6fdd4b6cf3280c1a5877;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/27-local.t b/t/27-local.t index 7d5f88b..d15ba19 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_watcher '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 = watch { cast $a, $wiz } { }, 'cast'; +ok $res, 'local: cast succeeded'; +watch { local $a } { local => 1 }, 'localized';