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

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

Issue 1407213002: Implement Math.tanh using fdlibm port. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: delete the actual old implementation Created 5 years, 2 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
« src/third_party/fdlibm/fdlibm.js ('K') | « src/third_party/fdlibm/fdlibm.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/math-hyperbolic.js
diff --git a/test/mjsunit/es6/math-hyperbolic.js b/test/mjsunit/es6/math-hyperbolic.js
index 8970f6ef65ca44d0154b7bb6afbd7674cfefe287..29a419d1bdd1eb1a95b434c700a39a7ebc657955 100644
--- a/test/mjsunit/es6/math-hyperbolic.js
+++ b/test/mjsunit/es6/math-hyperbolic.js
@@ -186,3 +186,21 @@ assertEquals(1.7976931348621744e308, Math.cosh(-710.4758600739439));
// Overflow.
assertEquals(Infinity, Math.cosh(710.475860073944));
assertEquals(Infinity, Math.cosh(-710.475860073944));
+
+// Implementation-specific tests for tanh.
+// Case |x| < 2^-55
+var two_56 = Math.pow(2, -56);
+assertEquals(two_56, Math.tanh(two_56));
+assertEquals(-two_56, Math.tanh(-two_56));
+// Case |x| < 1
+assertEquals(0.6, Math.tanh(Math.LN2));
+assertEquals(-0.6, Math.tanh(-Math.LN2));
+// Case 1 < |x| < 22
+assertEquals(15/17, Math.tanh(2 * Math.LN2));
+assertEquals(-15/17, Math.tanh(-2 * Math.LN2));
+// Case |x| > 22
+assertEquals(1, Math.tanh(100));
+assertEquals(-1, Math.tanh(-100));
+// Test against overflow
+assertEquals(1, Math.tanh(1e300));
+assertEquals(-1, Math.tanh(-1e300));
« src/third_party/fdlibm/fdlibm.js ('K') | « src/third_party/fdlibm/fdlibm.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698