Refactored Survey test suite diagnostics etc..

This commit is contained in:
Patrick Donelan 2009-05-17 08:15:59 +00:00
parent de47c22eff
commit 9cbd30c3d8
4 changed files with 355 additions and 78 deletions

View file

@ -349,6 +349,18 @@ sub avg {
return sum(@vals) / @vals;
}
=head2 round
Utility sub shared with Safe compartment to allows expressions to easily round numbers
=cut
sub round {
my ($number, $precision) = @_;
$precision ||= 0;
return sprintf("%.${precision}f", $number);
}
=head2 run ( $session, $expression, $opts )
Class method.
@ -451,6 +463,7 @@ sub run {
$compartment->share('&exitUrl');
$compartment->share('&restart');
$compartment->share('&avg');
$compartment->share('&round');
# Give them all of List::Util too
$compartment->share_from( 'List::Util',