]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - t/27-local.t
Importing Variable-Magic-0.07_01.tar.gz
[perl/modules/Variable-Magic.git] / t / 27-local.t
diff --git a/t/27-local.t b/t/27-local.t
new file mode 100644 (file)
index 0000000..7d5f88b
--- /dev/null
@@ -0,0 +1,38 @@
+#!perl -T
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use Variable::Magic qw/wizard cast dispell MGf_LOCAL/;
+
+if (!MGf_LOCAL) {
+ plan skip_all => "this perl doesn't handle local magic";
+} else {
+ plan tests => 5;
+}
+
+my $c = 0;
+my $wiz = wizard 'local' => sub { ++$c };
+ok($c == 0, 'local : create wizard');
+
+my $n = int rand 1000;
+local $a = $n;
+
+cast $a, $wiz;
+ok($c == 0, 'local : cast');
+
+{
+ 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');
+}
+