mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:58:11 +00:00
test-js: Use prettier and format all files
This commit is contained in:
parent
e532888242
commit
6d58c48c2f
248 changed files with 8291 additions and 7725 deletions
|
@ -1,62 +1,78 @@
|
|||
load("test-common.js");
|
||||
|
||||
try {
|
||||
assert(BigInt.length === 1);
|
||||
assert(BigInt.name === "BigInt");
|
||||
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);
|
||||
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();
|
||||
}, {
|
||||
assertThrowsError(
|
||||
() => {
|
||||
new BigInt();
|
||||
},
|
||||
{
|
||||
error: TypeError,
|
||||
message: "BigInt is not a constructor",
|
||||
}
|
||||
);
|
||||
|
||||
[null, undefined, Symbol()].forEach(value => {
|
||||
assertThrowsError(
|
||||
() => {
|
||||
BigInt(value);
|
||||
},
|
||||
{
|
||||
error: TypeError,
|
||||
message: "BigInt is not a constructor"
|
||||
});
|
||||
message:
|
||||
typeof value === "symbol"
|
||||
? "Cannot convert symbol to BigInt"
|
||||
: `Cannot convert ${value} to BigInt`,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
[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}`,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
["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",
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
[1.23, Infinity, -Infinity, NaN].forEach(value => {
|
||||
assertThrowsError(() => {
|
||||
BigInt(value);
|
||||
}, {
|
||||
error: RangeError,
|
||||
message: "BigInt argument must be an integer"
|
||||
});
|
||||
});
|
||||
|
||||
console.log("PASS");
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
console.log("FAIL: " + e);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue