mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:57:35 +00:00
LibJS: Reorganize tests into subfolders
This commit is contained in:
parent
21064a1883
commit
4c48c9d69d
213 changed files with 10 additions and 2 deletions
|
@ -1,62 +0,0 @@
|
|||
load("test-common.js");
|
||||
|
||||
try {
|
||||
assert(BigInt.length === 1);
|
||||
assert(BigInt.name === "BigInt");
|
||||
|
||||
assert(BigInt(0) === 0n);
|
||||
assert(BigInt(1) === 1n);
|
||||
assert(BigInt(+1) === 1n);
|
||||
assert(BigInt(-1) === -1n);
|
||||
assert(BigInt("") === 0n);
|
||||
assert(BigInt("0") === 0n);
|
||||
assert(BigInt("1") === 1n);
|
||||
assert(BigInt("+1") === 1n);
|
||||
assert(BigInt("-1") === -1n);
|
||||
assert(BigInt("-1") === -1n);
|
||||
assert(BigInt([]) === 0n);
|
||||
assert(BigInt("42") === 42n);
|
||||
assert(BigInt(" \n 00100 \n ") === 100n);
|
||||
assert(BigInt(123n) === 123n);
|
||||
assert(BigInt("3323214327642987348732109829832143298746432437532197321") === 3323214327642987348732109829832143298746432437532197321n);
|
||||
|
||||
assertThrowsError(() => {
|
||||
new BigInt();
|
||||
}, {
|
||||
error: TypeError,
|
||||
message: "BigInt is not a constructor"
|
||||
});
|
||||
|
||||
[null, undefined, Symbol()].forEach(value => {
|
||||
assertThrowsError(() => {
|
||||
BigInt(value);
|
||||
}, {
|
||||
error: TypeError,
|
||||
message: typeof value === "symbol"
|
||||
? "Cannot convert symbol to BigInt"
|
||||
: `Cannot convert ${value} to BigInt`
|
||||
});
|
||||
});
|
||||
|
||||
["foo", "123n", "1+1", {}, function () { }].forEach(value => {
|
||||
assertThrowsError(() => {
|
||||
BigInt(value);
|
||||
}, {
|
||||
error: SyntaxError,
|
||||
message: `Invalid value for BigInt: ${value}`
|
||||
});
|
||||
});
|
||||
|
||||
[1.23, Infinity, -Infinity, NaN].forEach(value => {
|
||||
assertThrowsError(() => {
|
||||
BigInt(value);
|
||||
}, {
|
||||
error: RangeError,
|
||||
message: "BigInt argument must be an integer"
|
||||
});
|
||||
});
|
||||
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue