This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In t/op/arith.t, tryeq_sloppy() wasn't correctly handling negative values.
authorNicholas Clark <nick@ccl4.org>
Mon, 18 Jun 2012 19:49:39 +0000 (21:49 +0200)
committerNicholas Clark <nick@ccl4.org>
Tue, 19 Jun 2012 08:13:06 +0000 (10:13 +0200)
The code was treating any negative value as "ok", rather than only those
within 1e-9 of the expected value. This bug has been present since
tryeq_sloppy() was added by commit 800e6488b45c59f1 in Oct 2001.

t/op/arith.t

index 2906402..01df2c8 100644 (file)
@@ -21,7 +21,7 @@ sub tryeq_sloppy ($$$) {
   if ($_[1] == $_[2]) {
     print "ok $_[0]\n";
   } else {
-    my $error = abs ($_[1] - $_[2]) / $_[1];
+    my $error = abs (($_[1] - $_[2]) / $_[1]);
     if ($error < 1e-9) {
       print "ok $_[0] # $_[1] is close to $_[2], \$^O eq $^O\n";
     } else {