1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:57:35 +00:00

LibJS: Correctly handle mixing +0 and -0 in Math.{min,max}()

The native C++ < and > operators won't handle this correctly, so the
result was different depending on the order of arguments. This is now
fixed by explicitly checking for positive and negative zero values.

Fixes #6589.
This commit is contained in:
Linus Groh 2021-04-23 20:47:53 +02:00
parent 883e8683b2
commit 0053816e9d
3 changed files with 8 additions and 2 deletions

View file

@ -5,6 +5,8 @@ test("basic functionality", () => {
expect(Math.max(1)).toBe(1);
expect(Math.max(2, 1)).toBe(2);
expect(Math.max(1, 2, 3)).toBe(3);
expect(Math.max(-0, 0)).toBe(0);
expect(Math.max(0, -0)).toBe(0);
expect(Math.max(NaN)).toBeNaN();
expect(Math.max("String", 1)).toBeNaN();
});