Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Math.atanh #1438

Merged
merged 4 commits into from
Jan 24, 2024
Merged

Fix Math.atanh #1438

merged 4 commits into from
Jan 24, 2024

Conversation

andreabergia
Copy link
Contributor

See #1437

I have added also some tests for various "recent" math functions that seemed to be lacking them.

@@ -153,7 +153,7 @@ private static Object atanh(Context cx, Scriptable scope, Scriptable thisObj, Ob
}
return ScriptRuntime.negativeZeroObj;
}
return Double.valueOf(0.5 * Math.log((x + 1.0) / (x - 1.0)));
return Double.valueOf(0.5 * Math.log((x + 1.0) / (1.0 - x)));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe pedantic but to be in sync with MDN

return Double.valueOf(0.5 * Math.log((1.0 + x) / (1.0 - x)));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -54,4 +54,78 @@ assertEquals(Math.imul(-2, -2), 4);
assertEquals(Math.imul(0xffffffff, 5), -5);
assertEquals(Math.imul(0xfffffffe, 5), -10);

assertEqualsDelta(Math.atanh(1/2), 0.549306144334059, 0.0000000000001);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because the 262 tests suite seems to have no tests for this maybe you can add some more samples

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

assertEquals(Math.sign('foo'), NaN);
assertEquals(Math.sign(), NaN);

assertEquals(Math.clz32(0), 32);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a separate PR #1430 for clz32, maybe we have to merge the two different approaches of tests for the functions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed all the cases from this file - it seems the other PR will add complete coverage

@rbri rbri mentioned this pull request Jan 15, 2024
Copy link
Collaborator

@rbri rbri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the changes, this one is fine for me

@gbrail
Copy link
Collaborator

gbrail commented Jan 24, 2024

Looks good to me, and nice catch. Thanks!

@gbrail gbrail merged commit 6ec1085 into mozilla:master Jan 24, 2024
3 checks passed
@andreabergia andreabergia deleted the fix-atanh branch April 30, 2024 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants