X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F23-branch.t;h=8aced0dca51e33f26e27fb8a9d98b5da2fd8735e;hb=3271ef4bff5871bc6aa2d90537f97f177cbacc2a;hp=72451e40e80c45ecdff391facdcce0902df62e73;hpb=08ec5acb4cc88d8cc10fec0520d8cd075c08fda1;p=perl%2Fmodules%2FSub-Nary.git diff --git a/t/23-branch.t b/t/23-branch.t index 72451e4..8aced0d 100644 --- a/t/23-branch.t +++ b/t/23-branch.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 17; +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,20 +71,16 @@ 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 } ], - - [ sub { each %h }, { 0 => 0.5, 2 => 0.5 } ], - [ sub { stat $0 }, { 0 => 0.5, 13 => 0.5 } ], - - [ sub { <*.*> }, { list => 1 / 3, 1 => 2 / 3 } ], ); 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; }