]> git.vpit.fr Git - perl/modules/Scope-Upper.git/blobdiff - t/15-reap-multi.t
fix unwind()
[perl/modules/Scope-Upper.git] / t / 15-reap-multi.t
index a3f7f3ce8d5c37db7d33b8bdd16aca13a931ed9a..3105bede64f394117b00ba79ae9fdcb356741180 100644 (file)
@@ -5,25 +5,25 @@ use warnings;
 
 use Test::More tests => 8 + 18 + 4 + 8 + 11 + 5 + 17;
 
-use Scope::Upper qw/reap/;
+use Scope::Upper qw<reap UP HERE>;
 
 my $x;
 
-sub add { local $_; my $y = $_[1]; reap sub { $x += $y }, $_[0] + 1 }
+sub add { local $_; my $y = $_[0]; reap sub { $x += $y } => $_[1] }
 
 $x = 0;
 {
  is($x, 0, 'start');
  {
-  add(0, 1);
+  add 1 => HERE;
   is($x, 0, '1 didn\'t run');
   {
-   add(0, 2);
+   add 2 => HERE;
    is($x, 0, '1 and 2 didn\'t run');
   }
   is($x, 2, '1 didn\'t run, 2 ran');
   {
-   add(0, 4);
+   add 4 => HERE;
    is($x, 2, '1 and 3 didn\'t run, 2 ran');
   }
   is($x, 6, '1 didn\'t run, 2 and 3 ran');
@@ -38,13 +38,13 @@ $x = 0;
  local $_ = 3;
  is($_, 3, '$_ has the right value');
  {
-  add(0, 1);
+  add 1 => HERE;
   is($_, 3, '$_ has the right value');
   local $_ = 5;
   is($x, 0, '1 didn\'t run');
   is($_, 5, '$_ has the right value');
   {
-   add(0, 2);
+   add 2 => HERE;
    is($_, 5, '$_ has the right value');
    local $_ = 7;
    is($_, 7, '$_ has the right value');
@@ -55,7 +55,7 @@ $x = 0;
   {
    local $_ = 9;
    is($_, 9, '$_ has the right value');
-   add(0, 4);
+   add 4 => HERE;
    local $_ = 11;
    is($_, 11, '$_ has the right value');
    is($x, 2, '1 and 3 didn\'t run, 2 ran');
@@ -72,8 +72,8 @@ $x = 0;
 {
  is($x, 0, 'start');
  {
-  add(0, 1);
-  add(0, 2);
+  add 1 => HERE;
+  add 2 => HERE;
   is($x, 0, '1 and 2 didn\'t run');
  }
  is($x, 3, '1 and 2 ran');
@@ -86,10 +86,10 @@ $x = 0;
  local $_ = 3;
  {
   local $_ = 5;
-  add(0, 1);
+  add 1 => HERE;
   is($_, 5, '$_ has the right value');
   local $_ = 7;
-  add(0, 2);
+  add 2 => HERE;
   is($_, 7, '$_ has the right value');
   is($x, 0, '1 and 2 didn\'t run');
   local $_ = 9;
@@ -105,21 +105,21 @@ $x = 0;
  is($x, 0, 'start');
  {
   {
-   add(1, 1);
+   add 1 => UP;
    is($x, 0, '1 didn\'t run');
   }
   is($x, 0, '1 didn\'t run');
  }
  is($x, 1, '1 ran');
- { 
+ {
   {
    {
-    add(2, 2);
+    add 2 => UP UP;
     is($x, 1, '2 didn\'t run');
    }
    is($x, 1, '2 didn\'t run');
    {
-    add(1, 4);
+    add 4 => UP;
     is($x, 1, '2 and 3 didn\'t run');
    }
    is($x, 1, '2 and 3 didn\'t run');
@@ -130,13 +130,13 @@ $x = 0;
 }
 is($x, 7, 'end');
 
-sub bleh { add(1, 2); }
+sub bleh { add 2 => UP; }
 
 $x = 0;
 {
  is($x, 0, 'start');
  {
-  add(0, 1);
+  add 1 => HERE;
   is($x, 0, '1 didn\'t run');
   bleh();
   is($x, 0, '1 didn\'t run');
@@ -148,21 +148,21 @@ is($x, 3, 'end');
 sub bar {
  is($_, 7, '$_ has the right value');
  local $_ = 9;
- add(2, 4);
+ add 4 => UP UP;
  is($_, 9, '$_ has the right value');
- add(3, 8);
+ add 8 => UP UP UP;
  is($_, 9, '$_ has the right value');
 }
 
 sub foo {
  local $_ = 7;
- add(0, 2);
+ add 2 => HERE;
  is($_, 7, '$_ has the right value');
  is($x, 0, '1, 2 didn\'t run');
  bar();
  is($x, 0, '1, 2, 3, 4 didn\'t run');
  is($_, 7, '$_ has the right value');
- add(1, 16);
+ add 16 => UP;
  is($_, 7, '$_ has the right value');
 }
 
@@ -170,7 +170,7 @@ $x = 0;
 {
  is($x, 0, 'start');
  local $_ = 3;
- add(0, 1);
+ add 1 => HERE;
  is($_, 3, '$_ has the right value');
  {
   local $_ = 5;