Archived
1
0
Fork 0

Zero values are now treated as valid computation

This commit is contained in:
Mercier Pierre-Olivier 2013-09-21 22:26:39 +02:00
commit d709297002
2 changed files with 9 additions and 7 deletions

View file

@ -238,9 +238,10 @@ sub compute ($$$;$$)
$parent->appendChild( $grade );
}
for my $node (@{ $self->{tree} }) {
for my $node (@{ $self->{tree} })
{
my $t = $node->compute($operators, $ids, $doc, $grade);
push @current, $t if $t;
push @current, $t if (defined $t);
}
my $res;
@ -249,11 +250,11 @@ sub compute ($$$;$$)
my $operator = $self->{operator};
my $cpt = new Safe;
$cpt->permit_only(qw(:base_core :base_mem :base_loop padany));
$cpt->permit_only(qw(:base_core :base_mem :base_loop padany rv2gv));
$res = reduce {
$cpt->share('$a');
$cpt->share('$b');
$cpt->reval($operators->{ $operator }) or die "Safe alert: $@";
$cpt->reval($operators->{ $operator }) // die "Safe alert: $@";
}
@current;
}
@ -333,7 +334,7 @@ sub compute ($$$;$$)
my $ids = shift;
my $ret = undef;
if ((not $self->{ref}) || $self->{ref} ~~ $ids) {
if ((not $self->{ref}) || grep { $self->{ref} eq $_ } keys %$ids) {
$ret = $self->getValue( $ids );
}