ladybird/Userland/Libraries/LibJS/Tests/builtins/Math/Math.min.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

11 lines
345 B
JavaScript

test("basic functionality", () => {
expect(Math.min).toHaveLength(2);
expect(Math.min(1)).toBe(1);
expect(Math.min(2, 1)).toBe(1);
expect(Math.min(1, 2, 3)).toBe(1);
expect(Math.min(-0, 0)).toBe(-0);
expect(Math.min(0, -0)).toBe(-0);
expect(Math.min(NaN)).toBeNaN();
expect(Math.min("String", 1)).toBeNaN();
});