X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F23-branch.t;h=fef709dc1da61c42bddf566e42d0ca974b4c924e;hb=790ba71f0305951a6d7bb04ca02a1dad7563f439;hp=8aced0dca51e33f26e27fb8a9d98b5da2fd8735e;hpb=3271ef4bff5871bc6aa2d90537f97f177cbacc2a;p=perl%2Fmodules%2FSub-Nary.git diff --git a/t/23-branch.t b/t/23-branch.t index 8aced0d..fef709d 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 + ("$]" >= 5.010 ? 1 : 0); use Sub::Nary; @@ -40,11 +40,11 @@ sub ret1234 { } elsif ($h{foo}) { return 3, @a[4, 5]; } elsif (@a) { - return @h{qw/a b c/}, $y + return @h{qw}, $y } } -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 ("$]" >= 5.010)), ); my $i = 1;