6 use Test::More tests => 17;
10 my $sn = Sub::Nary->new();
35 sub ret1l { $x ? 1 : @_ }
43 return @h{qw/a b c/}, $y
56 if (do { return 2, 3 if $x }) {
62 [ \&ret12, { 1 => 0.5, 2 => 0.5 } ],
63 [ \&ret12b, { 1 => 0.5, 2 => 0.5 } ],
64 [ \&ret12c, { 1 => 0.5, 2 => 0.5 } ],
65 [ sub { 1, ret12 }, { 2 => 0.5, 3 => 0.5 } ],
66 [ sub { 1, do { ret12, 3 } }, { 3 => 0.5, 4 => 0.5 } ],
67 [ sub { @_[ret12()] }, { 1 => 0.5, 2 => 0.5 } ],
69 [ sub { ret12, ret12 }, { 2 => 0.25, 3 => 0.5, 4 => 0.25 } ],
70 [ sub { ret12, 0, ret12 }, { 3 => 0.25, 4 => 0.5, 5 => 0.25 } ],
71 [ sub { ret12, @a }, { list => 1 } ],
72 [ sub { %h, ret12 }, { list => 1 } ],
74 [ sub { if ($y) { ret12 } else { ret12 } }, { 1 => 0.5, 2 => 0.5 } ],
76 [ \&ret1l, { 1 => 0.5, list => 0.5 } ],
77 [ sub { $_[0], ret1l }, { 2 => 0.5, list => 0.5 } ],
78 [ sub { ret1l, ret1l, ret1l }, { 3 => 0.125, list => 0.875 } ],
80 [ \&ret1234, { 2 => 0.5, 3 => 0.25, 4 => 0.125, 1 => 0.125 } ],
82 [ \&retinif1, { 2 => 1 } ],
83 [ \&retinif2, { 2 => 0.5, 3 => 0.25, 1 => 0.25 } ],
88 my $r = $sn->nary($_->[0]);
89 my $exp = ref $_->[1] ? $_->[1] : { $_->[1] => 1 };
90 is_deeply($r, $exp, 'branch test ' . $i);