X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F27-local.t;h=d15ba198b1e96b6413bfdab3a68ef64bbcb69f57;hb=579f1710492a3864774affb698358c8b3aa4bd80;hp=27dfd8bc2a9556451ac6f001aff0f1e2a76a2d1e;hpb=a86e3e47a167afadf7de1231d6401a1139330ad0;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/27-local.t b/t/27-local.t index 27dfd8b..d15ba19 100644 --- a/t/27-local.t +++ b/t/27-local.t @@ -5,25 +5,22 @@ use warnings; use Test::More; -use Variable::Magic qw/wizard cast MGf_LOCAL/; +use Variable::Magic qw/cast MGf_LOCAL/; if (MGf_LOCAL) { - plan tests => 5; + plan tests => 2 * 3 + 1 + 1; } else { plan skip_all => 'No local magic for this perl'; } -my $c = 0; -my $wiz = wizard 'local' => sub { ++$c }; -is($c, 0, 'local : create wizard'); +use lib 't/lib'; +use Variable::Magic::TestWatcher; -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'); +my $wiz = init_watcher 'local', 'local'; -{ - local $a; - is($c, 1, 'local : localized'); -} -is($c, 1, 'local : end of local scope'); +our $a = int rand 1000; + +my $res = watch { cast $a, $wiz } { }, 'cast'; +ok $res, 'local: cast succeeded'; + +watch { local $a } { local => 1 }, 'localized';