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

LibJS: Throw RangeError on BigInt exponentiation with negative exponent

https://tc39.es/ecma262/#sec-numeric-types-bigint-exponentiate
This commit is contained in:
Linus Groh 2021-03-16 20:35:55 +01:00 committed by Andreas Kling
parent 11138f5c1f
commit fa6bce5087
3 changed files with 13 additions and 1 deletions

View file

@ -96,4 +96,10 @@ describe("errors", () => {
1n % 0n;
}).toThrowWithMessage(RangeError, "Division by zero");
});
test("negative exponent", () => {
expect(() => {
1n ** -1n;
}).toThrowWithMessage(RangeError, "Exponent must be positive");
});
});