]> git.vpit.fr Git - perl/modules/Sub-Nary.git/blobdiff - t/23-branch.t
Complete rewrite. Make the inspect process return both the ret state and the last...
[perl/modules/Sub-Nary.git] / t / 23-branch.t
index f806089a649ded05b90ba99687fa37822f5d3056..8aced0dca51e33f26e27fb8a9d98b5da2fd8735e 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 14;
+use Test::More tests => 16;
 
 use Sub::Nary;
 
@@ -19,6 +19,19 @@ sub ret12 {
  }
 }
 
+sub ret12b {
+ if ($x) {
+  return 1
+ }
+ return 1, 2
+}
+
+sub ret12c {
+ if (@a) {
+  return 1, 2
+ }
+}
+
 sub ret1l { $x ? 1 : @_ }
 
 sub ret1234 {
@@ -41,6 +54,8 @@ sub retinif {
 
 my @tests = (
  [ \&ret12,                    { 1 => 0.5, 2 => 0.5 } ],
+ [ \&ret12b,                   { 1 => 0.5, 2 => 0.5 } ],
+ [ \&ret12c,                   { 1 => 0.5, 2 => 0.5 } ],
  [ sub { 1, ret12 },           { 2 => 0.5, 3 => 0.5 } ],
  [ sub { 1, do { ret12, 3 } }, { 3 => 0.5, 4 => 0.5 } ],
  [ sub { @_[ret12()] },        { 1 => 0.5, 2 => 0.5 } ],
@@ -56,7 +71,7 @@ my @tests = (
  [ sub { $_[0], ret1l },        { 2 => 0.5, list => 0.5 } ],
  [ sub { ret1l, ret1l, ret1l }, { 3 => 0.125, list => 0.875 } ],
 
- [ \&ret1234, { map { $_ => 0.25 } 1 .. 4 } ],
+ [ \&ret1234, { 2 => 0.5, 3 => 0.25, 4 => 0.125, 1 => 0.125 } ],
 
  [ \&retinif, { 2 => 1 } ],
 );
@@ -64,7 +79,8 @@ my @tests = (
 my $i = 1;
 for (@tests) {
  my $r = $sn->nary($_->[0]);
- is_deeply($r, $_->[1], 'branch test ' . $i);
+ my $exp = ref $_->[1] ? $_->[1] : { $_->[1] => 1 };
+ is_deeply($r, $exp, 'branch test ' . $i);
  ++$i;
 }