]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - t/27-local.t
5.13.2 calls get magic on globs
[perl/modules/Variable-Magic.git] / t / 27-local.t
index 7d5f88bab4b9685d63ec0045d490aebcca055beb..d15ba198b1e96b6413bfdab3a68ef64bbcb69f57 100644 (file)
@@ -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';