]> git.vpit.fr Git - perl/modules/Variable-Temp.git/blobdiff - t/10-base.t
Merge t/10-lexical.t and t/11-global.t into t/10-base.t
[perl/modules/Variable-Temp.git] / t / 10-base.t
diff --git a/t/10-base.t b/t/10-base.t
new file mode 100644 (file)
index 0000000..57ea47f
--- /dev/null
@@ -0,0 +1,59 @@
+#!perl -T
+
+use strict;
+use warnings;
+
+use Variable::Temp 'set_temp';
+
+use Test::More tests => 7 + 13;
+
+my $x = 1;
+is $x, 1;
+{
+ set_temp $x => 2;
+ is $x, 2;
+ $x = 3;
+ is $x, 3;
+ {
+  set_temp $x => 4;
+  is $x, 4;
+  set_temp $x => 5;
+  is $x, 5;
+ }
+ is $x, 3;
+}
+is $x, 1;
+
+our $y = 1;
+is $y, 1;
+{
+ set_temp $y => 2;
+ is $y, 2;
+ $y = 3;
+ is $y, 3;
+ {
+  set_temp $y => 4;
+  is $y, 4;
+  set_temp $y => 5;
+  is $y, 5;
+ }
+ is $y, 3;
+ {
+  local $y = 6;
+  is $y, 6;
+ }
+ is $y, 3;
+ {
+  local $y = 7;
+  set_temp $y => 8;
+  is $y, 8;
+ }
+ is $y, 3;
+ {
+  set_temp $y => 9;
+  local $y = 10;
+  is $y, 10;
+ }
+ is $y, 3;
+}
+is $y, 1;