6 use Test::More tests => 14;
10 my $sn = Sub::Nary->new();
22 sub ret1l { $x ? 1 : @_ }
30 return @h{qw/a b c/}, $y
43 [ \&ret12, { 1 => 0.5, 2 => 0.5 } ],
44 [ sub { 1, ret12 }, { 2 => 0.5, 3 => 0.5 } ],
45 [ sub { 1, do { ret12, 3 } }, { 3 => 0.5, 4 => 0.5 } ],
46 [ sub { @_[ret12()] }, { 1 => 0.5, 2 => 0.5 } ],
48 [ sub { ret12, ret12 }, { 2 => 0.25, 3 => 0.5, 4 => 0.25 } ],
49 [ sub { ret12, 0, ret12 }, { 3 => 0.25, 4 => 0.5, 5 => 0.25 } ],
50 [ sub { ret12, @a }, { list => 1 } ],
51 [ sub { %h, ret12 }, { list => 1 } ],
53 [ sub { if ($y) { ret12 } else { ret12 } }, { 1 => 0.5, 2 => 0.5 } ],
55 [ \&ret1l, { 1 => 0.5, list => 0.5 } ],
56 [ sub { $_[0], ret1l }, { 2 => 0.5, list => 0.5 } ],
57 [ sub { ret1l, ret1l, ret1l }, { 3 => 0.125, list => 0.875 } ],
59 [ \&ret1234, { map { $_ => 0.25 } 1 .. 4 } ],
61 [ \&retinif, { 2 => 1 } ],
66 my $r = $sn->nary($_->[0]);
67 is_deeply($r, $_->[1], 'branch test ' . $i);