Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Unified Diff: test/mjsunit/es6/math-log1p.js

Issue 457643002: Implement Math.log1p using port from fdlibm. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/mjsunit/es6/math-log1p.js
diff --git a/test/mjsunit/es6/math-log1p.js b/test/mjsunit/es6/math-log1p.js
index 01f353368f774d40e61b603e326283f87fa489a4..066f947b33b01eb66ce5d46a4fae9145ab0a2cd3 100644
--- a/test/mjsunit/es6/math-log1p.js
+++ b/test/mjsunit/es6/math-log1p.js
@@ -6,10 +6,10 @@ assertTrue(isNaN(Math.log1p(NaN)));
assertTrue(isNaN(Math.log1p(function() {})));
assertTrue(isNaN(Math.log1p({ toString: function() { return NaN; } })));
assertTrue(isNaN(Math.log1p({ valueOf: function() { return "abc"; } })));
-assertEquals("Infinity", String(1/Math.log1p(0)));
-assertEquals("-Infinity", String(1/Math.log1p(-0)));
-assertEquals("Infinity", String(Math.log1p(Infinity)));
-assertEquals("-Infinity", String(Math.log1p(-1)));
+assertEquals(Infinity, 1/Math.log1p(0));
+assertEquals(-Infinity, 1/Math.log1p(-0));
+assertEquals(Infinity, Math.log1p(Infinity));
+assertEquals(-Infinity, Math.log1p(-1));
assertTrue(isNaN(Math.log1p(-2)));
assertTrue(isNaN(Math.log1p(-Infinity)));
@@ -37,3 +37,34 @@ for (var x = 1E-1; x > 1E-300; x *= 0.8) {
var expected = log1p(x);
assertEqualsDelta(expected, Math.log1p(x), expected * 1E-14);
Raymond Toy 2014/08/08 17:32:16 Shouldn't the threshold be closer to 1.1e-16 inste
Yang 2014/08/11 07:51:06 Done.
}
+
+// Issue 3481.
+assertEquals(6.9756137364252422e-03,
+ Math.log1p(8070450532247929/Math.pow(2,60)));
+
+// Tests related to the fdlibm implementation.
+// Test largest double value.
+assertEquals(709.782712893384, Math.log1p(1.7976931348623157e308));
+// Test small values.
+assertEquals(Math.pow(2, -55), Math.log1p(Math.pow(2, -55)));
+assertEquals(9.313225741817976e-10, Math.log1p(Math.pow(2, -30)));
+// Cover various code paths.
+// -.2929 < x < .41422, k = 0
+assertEquals(-0.2876820724517809, Math.log1p(-0.25));
+assertEquals(0.22314355131420976, Math.log1p(0.25));
+// 0.41422 < x < 9.007e15
+assertEquals(2.3978952727983707, Math.log1p(10));
+// x > 9.007e15
+assertEquals(36.841361487904734, Math.log1p(10e15));
+// Normalize u.
+assertEquals(37.08337388996168, Math.log1p(12738099905822720));
+// Normalize u/2.
+assertEquals(37.08336444902049, Math.log1p(12737979646738432));
+// |f| = 0, k != 0
+assertEquals(1.3862943611198906, Math.log1p(3));
+// |f| != 0, k != 0
+assertEquals(1.3862945995384413, Math.log1p(3 + Math.pow(2,-20)));
+// final if-clause: k = 0
+assertEquals(0.5596157879354227, Math.log1p(0.75));
+// final if-clause: k != 0
+assertEquals(0.8109302162163288, Math.log1p(1.25));
« no previous file with comments | « src/math.js ('k') | third_party/fdlibm/fdlibm.h » ('j') | third_party/fdlibm/fdlibm.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698