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

LibJS: Handle +Infinity, -Infinity, +0 and -0 in modulo operator

Fixes 11 test262 cases.
This commit is contained in:
Luke Wilde 2021-09-01 16:50:56 +01:00 committed by Linus Groh
parent 32825107de
commit c20669328d
2 changed files with 47 additions and 0 deletions

View file

@ -13,4 +13,26 @@ test("basic functionality", () => {
expect(-4 % 2).toBe(-0);
expect(5.5 % 2).toBe(1.5);
expect(NaN % 2).toBeNaN();
expect(2 % NaN).toBeNaN();
expect(NaN % NaN).toBeNaN();
expect(Infinity % 1).toBeNaN();
expect(-Infinity % 1).toBeNaN();
expect(1 % Infinity).toBe(1);
expect(1 % -Infinity).toBe(1);
expect(1 % 0).toBeNaN();
expect(1 % -0).toBeNaN();
expect(0 % 5).toBe(0);
expect(-0 % 5).toBe(-0);
// test262 examples
expect(1 % null).toBeNaN();
expect(null % 1).toBe(0);
expect(true % null).toBeNaN();
expect(null % true).toBe(0);
expect("1" % null).toBeNaN();
expect(null % "1").toBe(0);
expect(null % undefined).toBeNaN();
expect(undefined % null).toBeNaN();
expect(undefined % undefined).toBeNaN();
expect(null % null).toBeNaN();
});