]> git.vpit.fr Git - perl/modules/Sub-Nary.git/blobdiff - t/23-branch.t
Fix a bug the handling of if (do { return if ; }) { ... }
[perl/modules/Sub-Nary.git] / t / 23-branch.t
index 8aced0dca51e33f26e27fb8a9d98b5da2fd8735e..2f97ea8d604eed9f7591975ba6e9cf62d9ef40e3 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 16;
+use Test::More tests => 17;
 
 use Sub::Nary;
 
@@ -44,7 +44,7 @@ sub ret1234 {
  }
 }
 
-sub retinif {
+sub retinif1 {
  if (return 1, 2) {
   return 1, 2, 3
  } else {
@@ -52,6 +52,12 @@ sub retinif {
  }
 }
 
+sub retinif2 {
+ if (do { return 2, 3 if $x }) {
+  return 4, 5, 6;
+ }
+}
+
 my @tests = (
  [ \&ret12,                    { 1 => 0.5, 2 => 0.5 } ],
  [ \&ret12b,                   { 1 => 0.5, 2 => 0.5 } ],
@@ -73,7 +79,8 @@ my @tests = (
 
  [ \&ret1234, { 2 => 0.5, 3 => 0.25, 4 => 0.125, 1 => 0.125 } ],
 
- [ \&retinif, { 2 => 1 } ],
+ [ \&retinif1, { 2 => 1 } ],
+ [ \&retinif2, { 2 => 0.5, 3 => 0.25, 1 => 0.25 } ],
 );
 
 my $i = 1;