X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F23-branch.t;h=e2638f76bc246b62d23623bc4177b6a54819ced9;hb=d380b792af6bad213061fccaf29a3630ce3ca2da;hp=8aced0dca51e33f26e27fb8a9d98b5da2fd8735e;hpb=3271ef4bff5871bc6aa2d90537f97f177cbacc2a;p=perl%2Fmodules%2FSub-Nary.git diff --git a/t/23-branch.t b/t/23-branch.t index 8aced0d..e2638f7 100644 --- a/t/23-branch.t +++ b/t/23-branch.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 16; +use Test::More tests => 21 + ($^V ge v5.10.0 ? 1 : 0); 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,14 @@ 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 } ], + + [ sub { $x || (3, 4) }, { 1 => 0.5, 2 => 0.5 } ], + [ sub { $x or (3, 4) }, { 1 => 0.5, 2 => 0.5 } ], + [ sub { $x && (3, 4) }, { 1 => 0.5, 2 => 0.5 } ], + [ sub { $x and (3, 4) }, { 1 => 0.5, 2 => 0.5 } ], + (([ eval 'sub { $x // (3, 4) }', { 1 => 0.5, 2 => 0.5 } ]) x ($^V ge v5.10.0)), ); my $i = 1;