]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blob - t/27-local.t
7d5f88bab4b9685d63ec0045d490aebcca055beb
[perl/modules/Variable-Magic.git] / t / 27-local.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 use Variable::Magic qw/wizard cast dispell MGf_LOCAL/;
9
10 if (!MGf_LOCAL) {
11  plan skip_all => "this perl doesn't handle local magic";
12 } else {
13  plan tests => 5;
14 }
15
16 my $c = 0;
17 my $wiz = wizard 'local' => sub { ++$c };
18 ok($c == 0, 'local : create wizard');
19
20 my $n = int rand 1000;
21 local $a = $n;
22
23 cast $a, $wiz;
24 ok($c == 0, 'local : cast');
25
26 {
27  local $a;
28  ok($c == 1, 'local : localize casted variable');
29 }
30
31 dispell $a, $wiz;
32 ok($c == 1, 'local : dispell');
33
34 {
35  local $a;
36  ok($c == 1, 'local : localize dispelled variable');
37 }
38