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:
parent
32825107de
commit
c20669328d
2 changed files with 47 additions and 0 deletions
|
@ -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();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue