Fix 1: Original code tests for less than but not =. I think that if these values are the same, the test should pass. I don't know the code well enough to be 100% sure. D
Fix 2: convert ok() to cmp_ok() for better diagnostic messages from smoke tests when they happen.
Fix 3: convert print to diag() so it will properly print through harness.
{
my $difference = $in_onesec - $estimate;
my $actual = abs ($difference / $in_onesec);
- ok ($actual < $delta, "is $in_onesec within $delta of estimate ($estimate)");
- print "# $in_onesec is between " . ($delta / 2) .
- " and $delta of estimate. Not that safe.\n" if $actual > $delta/2;
+ cmp_ok($actual, '<=', $delta, "is $in_onesec within $delta of estimate ($estimate)")
+ or diag("# $in_onesec is between " . ($delta / 2) . " and $delta of estimate. Not that safe.");
}
# I found that the eval'ed version was 3 times faster than the coderef.