Commit 08707024 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Harmony: fix spec violation in Math.cosh.

R=jarin@chromium.org
BUG=v8:3141
LOG=N

Review URL: https://codereview.chromium.org/159353003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19272 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ab2aaac1
......@@ -59,8 +59,7 @@ function MathSinh(x) {
// ES6 draft 09-27-13, section 20.2.2.12.
function MathCosh(x) {
if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
// Idempotent for NaN and +/-Infinity.
if (!NUMBER_IS_FINITE(x)) return x;
if (!NUMBER_IS_FINITE(x)) return MathAbs(x);
return (MathExp(x) + MathExp(-x)) / 2;
}
......
......@@ -60,7 +60,7 @@ function test_id(fun, rev, value) {
});
[Math.sinh, Math.asinh, Math.cosh].forEach(function(fun) {
[Math.sinh, Math.asinh].forEach(function(fun) {
assertEquals("-Infinity", String(fun(-Infinity)));
assertEquals("Infinity", String(fun(Infinity)));
assertEquals("-Infinity", String(fun("-Infinity")));
......@@ -68,6 +68,12 @@ function test_id(fun, rev, value) {
});
assertEquals("Infinity", String(Math.cosh(-Infinity)));
assertEquals("Infinity", String(Math.cosh(Infinity)));
assertEquals("Infinity", String(Math.cosh("-Infinity")));
assertEquals("Infinity", String(Math.cosh("Infinity")));
assertEquals("-Infinity", String(Math.atanh(-1)));
assertEquals("Infinity", String(Math.atanh(1)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment