1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:47:44 +00:00

LibJS: Throw RangeError on BigInt division/modulo by zero

https://tc39.es/ecma262/#sec-numeric-types-bigint-divide
https://tc39.es/ecma262/#sec-numeric-types-bigint-remainder
This commit is contained in:
Linus Groh 2021-03-16 20:34:40 +01:00 committed by Andreas Kling
parent 1d8ab74cbf
commit 11138f5c1f
3 changed files with 30 additions and 8 deletions

View file

@ -87,4 +87,13 @@ describe("errors", () => {
+123n;
}).toThrowWithMessage(TypeError, "Cannot convert BigInt to number");
});
test("division by zero", () => {
expect(() => {
1n / 0n;
}).toThrowWithMessage(RangeError, "Division by zero");
expect(() => {
1n % 0n;
}).toThrowWithMessage(RangeError, "Division by zero");
});
});