Package: libjavascript-perl / 1.16-3

fix-longdouble-comparison.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Description: Replace equality test between doubles with "<epsilon" test
 Thing is, doubles are not exact and errors are possible in the least
 significant digit.
 This patch replaces the equality tests with a test if the difference is smaller than a very small number
Bug-Debian: http://bugs.debian.org/578548
Forwarded: https://rt.cpan.org/Public/Bug/Display.html?id=56830
Author: Damyan Ivanov <dmn@debian.org>
Last-Update: 2010-04-22

--- a/t/01-types-from-js.t
+++ b/t/01-types-from-js.t
@@ -21,9 +21,9 @@
 is($cx1->eval("5000000000;"), 5_000_000_000, "Really big integers");
 
 # Doubles
-is($cx1->eval("-1.1;"), -1.1, "Negative doubles");
+ok(abs($cx1->eval("-1.1;") - -1.1) < 1e-14, "Negative doubles");
 is($cx1->eval("0.0;"), 0.0, "Zero doubles");
-is($cx1->eval("1.1;"), 1.1, "Positive doubles");
+ok(abs($cx1->eval("1.1;")- 1.1) < 1e-14, "Positive doubles");
 is($cx1->eval("5000000000.5;"), 5000000000.5, "Really big doubles");
 
 # Strings