]> git.vpit.fr Git - perl/modules/Scope-Upper.git/blobdiff - t/60-uplevel-target.t
Activate the correct pad when calling the uplevel'd code
[perl/modules/Scope-Upper.git] / t / 60-uplevel-target.t
index 6b3a444742fe6a057e2930389e9a3790cc5d26e9..246af7b351913f70ac67a1fb4a74cdc1e5b1ca1f 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => (1 * 3 + 2 * 4 + 3 * 5) * 2 + 7 + 5 + 6 + 5;
+use Test::More tests => (1 * 3 + 2 * 4 + 3 * 5) * 2 + 7 + 5 + 6 + 5 + 6;
 
 use Scope::Upper qw<uplevel HERE UP TOP>;
 
@@ -225,4 +225,32 @@ sub four {
 
   is $destroyed, 1, "$desc: target is detroyed";
  }
+
+ {
+  local $@;
+  local $destroyed = 0;
+  my $desc = 'code destruction';
+
+  {
+   my $lexical;
+   my $code = sub {
+    ++$lexical;
+    is $destroyed, 0, "$desc: not yet 1";
+   };
+
+   eval {
+    sub {
+     sub {
+      &uplevel($code, UP);
+      is $destroyed, 0, "$desc: not yet 2";
+     }->();
+     is $destroyed, 0, "$desc: not yet 2";
+    }->();
+   };
+   is $@,         '', "$desc: no error";
+   is $destroyed, 0,  "$desc: not yet 3";
+  };
+
+  is $destroyed, 0,  "$desc: code is destroyed";
+ }
 }