]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blob - t/27-local.t
Importing Variable-Magic-0.08.tar.gz
[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 MGf_LOCAL/;
9
10 if (MGf_LOCAL) {
11  plan tests => 5;
12 } else {
13  plan skip_all => 'No local magic for this perl';
14 }
15
16 my $c = 0;
17 my $wiz = wizard 'local' => sub { ++$c };
18 ok($c == 0, 'local : create wizard');
19
20 local $a = int rand 1000;
21 my $res = cast $a, $wiz;
22 ok($res,    'local : cast succeeded');
23 ok($c == 0, 'local : cast didn\'t triggered the callback');
24
25 {
26  local $a;
27  ok($c == 1, 'local : localized');
28 }
29 ok($c == 1, 'local : end of local scope');