mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 08:48:57 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
79
Libraries/LibJS/Tests/builtins/BigInt/BigInt.asIntN.js
Normal file
79
Libraries/LibJS/Tests/builtins/BigInt/BigInt.asIntN.js
Normal file
|
@ -0,0 +1,79 @@
|
|||
describe("errors", () => {
|
||||
test("invalid index", () => {
|
||||
expect(() => {
|
||||
BigInt.asIntN(-1, 0n);
|
||||
}).toThrowWithMessage(RangeError, "Index must be a positive integer");
|
||||
|
||||
expect(() => {
|
||||
BigInt.asIntN(Symbol(), 0n);
|
||||
}).toThrowWithMessage(TypeError, "Cannot convert symbol to number");
|
||||
});
|
||||
|
||||
test("invalid BigInt", () => {
|
||||
expect(() => {
|
||||
BigInt.asIntN(1, 1);
|
||||
}).toThrowWithMessage(TypeError, "Cannot convert number to BigInt");
|
||||
|
||||
expect(() => {
|
||||
BigInt.asIntN(1, Symbol());
|
||||
}).toThrowWithMessage(TypeError, "Cannot convert symbol to BigInt");
|
||||
|
||||
expect(() => {
|
||||
BigInt.asIntN(1, "foo");
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid value for BigInt: foo");
|
||||
});
|
||||
});
|
||||
|
||||
describe("correct behavior", () => {
|
||||
test("length is 2", () => {
|
||||
expect(BigInt.asIntN).toHaveLength(2);
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
expect(BigInt.asIntN(0, -2n)).toBe(0n);
|
||||
expect(BigInt.asIntN(0, -1n)).toBe(0n);
|
||||
expect(BigInt.asIntN(0, 0n)).toBe(0n);
|
||||
expect(BigInt.asIntN(0, 1n)).toBe(0n);
|
||||
expect(BigInt.asIntN(0, 2n)).toBe(0n);
|
||||
|
||||
expect(BigInt.asIntN(1, -3n)).toBe(-1n);
|
||||
expect(BigInt.asIntN(1, -2n)).toBe(0n);
|
||||
expect(BigInt.asIntN(1, -1n)).toBe(-1n);
|
||||
expect(BigInt.asIntN(1, 0n)).toBe(0n);
|
||||
expect(BigInt.asIntN(1, 1n)).toBe(-1n);
|
||||
expect(BigInt.asIntN(1, 2n)).toBe(0n);
|
||||
expect(BigInt.asIntN(1, 3n)).toBe(-1n);
|
||||
|
||||
expect(BigInt.asIntN(2, -3n)).toBe(1n);
|
||||
expect(BigInt.asIntN(2, -2n)).toBe(-2n);
|
||||
expect(BigInt.asIntN(2, -1n)).toBe(-1n);
|
||||
expect(BigInt.asIntN(2, 0n)).toBe(0n);
|
||||
expect(BigInt.asIntN(2, 1n)).toBe(1n);
|
||||
expect(BigInt.asIntN(2, 2n)).toBe(-2n);
|
||||
expect(BigInt.asIntN(2, 3n)).toBe(-1n);
|
||||
|
||||
expect(BigInt.asIntN(4, -3n)).toBe(-3n);
|
||||
expect(BigInt.asIntN(4, -2n)).toBe(-2n);
|
||||
expect(BigInt.asIntN(4, -1n)).toBe(-1n);
|
||||
expect(BigInt.asIntN(4, 0n)).toBe(0n);
|
||||
expect(BigInt.asIntN(4, 1n)).toBe(1n);
|
||||
expect(BigInt.asIntN(4, 2n)).toBe(2n);
|
||||
expect(BigInt.asIntN(4, 3n)).toBe(3n);
|
||||
|
||||
const extremelyBigInt = 123456789123456789123456789123456789123456789123456789n;
|
||||
|
||||
expect(BigInt.asIntN(0, extremelyBigInt)).toBe(0n);
|
||||
expect(BigInt.asIntN(1, extremelyBigInt)).toBe(-1n);
|
||||
expect(BigInt.asIntN(2, extremelyBigInt)).toBe(1n);
|
||||
expect(BigInt.asIntN(4, extremelyBigInt)).toBe(5n);
|
||||
expect(BigInt.asIntN(128, extremelyBigInt)).toBe(-99061374399389259395070030194384019691n);
|
||||
expect(BigInt.asIntN(256, extremelyBigInt)).toBe(extremelyBigInt);
|
||||
|
||||
expect(BigInt.asIntN(0, -extremelyBigInt)).toBe(0n);
|
||||
expect(BigInt.asIntN(1, -extremelyBigInt)).toBe(-1n);
|
||||
expect(BigInt.asIntN(2, -extremelyBigInt)).toBe(-1n);
|
||||
expect(BigInt.asIntN(4, -extremelyBigInt)).toBe(-5n);
|
||||
expect(BigInt.asIntN(128, -extremelyBigInt)).toBe(99061374399389259395070030194384019691n);
|
||||
expect(BigInt.asIntN(256, -extremelyBigInt)).toBe(-extremelyBigInt);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue