]> git.vpit.fr Git - perl/modules/Scope-Upper.git/blobdiff - t/62-uplevel-return.t
Inline Perl_cv_clone() and Perl_new_pad()
[perl/modules/Scope-Upper.git] / t / 62-uplevel-return.t
index ccf763bd1528a47ccd3e8ed6a90c0b6ffd15c025..1271de334e85c5bd922f2db8cb6a6152b9b57403 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => (13 + 5 + 4) * 2 + 1 + 3 + 11;
+use Test::More tests => (13 + 5 + 4) * 2 + 1 + (3 + 3 + 1) + 11;
 
 use Scope::Upper qw<uplevel HERE UP>;
 
@@ -78,6 +78,20 @@ for my $run (1 .. 3) {
  is $cb->(), 124, "near closure returned by uplevel still works";
 }
 
+{
+ my $id = 456;
+ for my $run (1 .. 3) {
+  my ($cb) = sub {
+   uplevel {
+    my $step = 2;
+    sub { $id += $step };
+   };
+  }->('dummy');
+  is $cb->(), 456 + 2 * $run, "far closure returned by uplevel still works";
+ }
+ is $id, 456 + 2 * 3, 'captured lexical has the right value at the end';
+}
+
 # Mark
 
 {