Diagnostic improvements to better understand why lib/Benchark.t test 13 has been...
authorTodd Rinaldo <toddr@cpanel.net>
Tue, 2 Feb 2010 17:27:37 +0000 (09:27 -0800)
committerJesse Vincent <jesse@bestpractical.com>
Tue, 2 Feb 2010 17:27:37 +0000 (09:27 -0800)
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.

lib/Benchmark.t

index 3a7a1de..9b8e2af 100644 (file)
@@ -77,9 +77,8 @@ ok ($in_onesec > 0, "iters returned positive iterations");
 {
   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.