ladybird/Userland/Libraries/LibJS/Tests/builtins/Math/Math.max.js
Linus Groh 0053816e9d 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.
2021-04-23 20:51:48 +02:00

12 lines
383 B
JavaScript

test("basic functionality", () => {
expect(Math.max).toHaveLength(2);
expect(Math.max()).toBe(-Infinity);
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();
});