my $r;
my $c = 1;
for (; not null $op->sibling; $op = $op->sibling) {
- my $n = name($op);
- next if $n eq 'nextstate';
my ($rc, $lc) = $self->inspect($op);
- $r = add $r, scale $c, $rc if defined $rc;
- if (zero $lc) {
- $c = 1 - count $r;
- return $r, $c ? { 0 => $c } : undef
- }
+ return $rc, $lc if defined $rc and not defined $lc;
+ $r = add $r, scale $c, $rc;
$c *= count $lc;
}
use strict;
use warnings;
-use Test::More tests => 42;
+use Test::More tests => 43;
use Sub::Nary;
my $sn = Sub::Nary->new();
+my $x;
+
sub CORE::GLOBAL::reset {
return 1, 2, 3
}
[ sub { do { one, do { two } } }, 3 ],
[ sub { do { lots, do { one } } }, 'list' ],
- [ sub { 1, return two, do { 4 } }, 3 ],
- [ sub { two 1, return 2 }, 1 ],
+ [ sub { 1, return two, do { 4 } }, 3 ],
+ [ sub { two 1, return 2 }, 1 ],
+ [ sub { two 1, do { return 5 if $x; 3 } }, { 1 => 0.5, 2 => 0.5 } ],
[ sub { 1, one(), 2 }, 3 ],
[ sub { 1, one(), @_ }, 'list' ],