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

test-js: Use prettier and format all files

This commit is contained in:
Matthew Olsson 2020-07-05 09:27:00 -07:00 committed by Andreas Kling
parent e532888242
commit 6d58c48c2f
248 changed files with 8291 additions and 7725 deletions

View file

@ -1,9 +1,9 @@
load("test-common.js");
try {
assert(BigInt.asIntN.length === 2);
assert(BigInt.asIntN.length === 2);
console.log("PASS");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
console.log("FAIL: " + e);
}

View file

@ -1,9 +1,9 @@
load("test-common.js");
try {
assert(BigInt.asUintN.length === 2);
assert(BigInt.asUintN.length === 2);
console.log("PASS");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
console.log("FAIL: " + e);
}

View file

@ -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);
}

View file

@ -1,18 +1,21 @@
load("test-common.js");
try {
assert(BigInt.prototype.toLocaleString.length === 0);
assert(BigInt.prototype.toLocaleString.length === 0);
assertThrowsError(() => {
BigInt.prototype.toLocaleString.call("foo");
}, {
error: TypeError,
message: "Not a BigInt object"
});
assert(BigInt(123).toLocaleString() === "123");
assertThrowsError(
() => {
BigInt.prototype.toLocaleString.call("foo");
},
{
error: TypeError,
message: "Not a BigInt object",
}
);
console.log("PASS");
assert(BigInt(123).toLocaleString() === "123");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
console.log("FAIL: " + e);
}

View file

@ -1,18 +1,21 @@
load("test-common.js");
try {
assert(BigInt.prototype.toString.length === 0);
assert(BigInt.prototype.toString.length === 0);
assertThrowsError(() => {
BigInt.prototype.toString.call("foo");
}, {
error: TypeError,
message: "Not a BigInt object"
});
assert(BigInt(123).toString() === "123");
assertThrowsError(
() => {
BigInt.prototype.toString.call("foo");
},
{
error: TypeError,
message: "Not a BigInt object",
}
);
console.log("PASS");
assert(BigInt(123).toString() === "123");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
console.log("FAIL: " + e);
}

View file

@ -1,20 +1,23 @@
load("test-common.js");
try {
assert(BigInt.prototype.valueOf.length === 0);
assert(BigInt.prototype.valueOf.length === 0);
assertThrowsError(() => {
BigInt.prototype.valueOf.call("foo");
}, {
error: TypeError,
message: "Not a BigInt object"
});
assertThrowsError(
() => {
BigInt.prototype.valueOf.call("foo");
},
{
error: TypeError,
message: "Not a BigInt object",
}
);
assert(typeof BigInt(123).valueOf() === "bigint");
// FIXME: Uncomment once we support Object() with argument
// assert(typeof Object(123n).valueOf() === "bigint");
assert(typeof BigInt(123).valueOf() === "bigint");
// FIXME: Uncomment once we support Object() with argument
// assert(typeof Object(123n).valueOf() === "bigint");
console.log("PASS");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
console.log("FAIL: " + e);
}

View file

@ -1,68 +1,74 @@
load("test-common.js");
try {
var bigint = 123n;
var bigint = 123n;
assert(typeof bigint === "bigint");
assert(-bigint === -123n);
assert("" + bigint === "123")
assert(typeof bigint === "bigint");
assert(-bigint === -123n);
assert("" + bigint === "123");
assertThrowsError(() => {
+bigint;
}, {
error: TypeError,
message: "Cannot convert BigInt to number"
});
assertThrowsError(
() => {
+bigint;
},
{
error: TypeError,
message: "Cannot convert BigInt to number",
}
);
assert(12n + 34n === 46n);
assert(12n - 34n === -22n);
assert(8n * 12n === 96n);
assert(123n / 10n === 12n);
assert(2n ** 3n === 8n);
assert(5n % 3n === 2n);
assert(45977665298704210987n + 714320987142450987412098743217984576n / 4598741987421098765327980n * 987498743n === 199365500239020623962n);
assert(12n + 34n === 46n);
assert(12n - 34n === -22n);
assert(8n * 12n === 96n);
assert(123n / 10n === 12n);
assert(2n ** 3n === 8n);
assert(5n % 3n === 2n);
assert(
45977665298704210987n +
(714320987142450987412098743217984576n / 4598741987421098765327980n) * 987498743n ===
199365500239020623962n
);
assert((12n & 5n) === 4n);
assert((1n | 2n) === 3n);
assert((5n ^ 3n) === 6n);
assert(~1n === -2n);
assert((12n & 5n) === 4n);
assert((1n | 2n) === 3n);
assert((5n ^ 3n) === 6n);
assert(~1n === -2n);
bigint = 1n;
assert(bigint++ === 1n);
assert(bigint === 2n);
assert(bigint-- === 2n);
assert(bigint === 1n);
assert(++bigint === 2n);
assert(bigint === 2n);
assert(--bigint === 1n);
assert(bigint === 1n);
bigint = 1n;
assert(bigint++ === 1n);
assert(bigint === 2n);
assert(bigint-- === 2n);
assert(bigint === 1n);
assert(++bigint === 2n);
assert(bigint === 2n);
assert(--bigint === 1n);
assert(bigint === 1n);
assert((1n == 1n) === true);
assert((1n == 1) === true);
assert((1 == 1n) === true);
assert((1n == 1.23) === false);
assert((1.23 == 1n) === false);
assert((1n == 1n) === true);
assert((1n == 1) === true);
assert((1 == 1n) === true);
assert((1n == 1.23) === false);
assert((1.23 == 1n) === false);
assert((1n != 1n) === false);
assert((1n != 1) === false);
assert((1 != 1n) === false);
assert((1n != 1.23) === true);
assert((1.23 != 1n) === true);
assert((1n != 1n) === false);
assert((1n != 1) === false);
assert((1 != 1n) === false);
assert((1n != 1.23) === true);
assert((1.23 != 1n) === true);
assert((1n === 1n) === true);
assert((1n === 1) == false);
assert((1 === 1n) === false);
assert((1n === 1.23) === false);
assert((1.23 === 1n) === false);
assert((1n === 1n) === true);
assert((1n === 1) == false);
assert((1 === 1n) === false);
assert((1n === 1.23) === false);
assert((1.23 === 1n) === false);
assert((1n !== 1n) === false);
assert((1n !== 1) === true);
assert((1 !== 1n) === true);
assert((1n !== 1.23) === true);
assert((1.23 !== 1n) === true);
assert((1n !== 1n) === false);
assert((1n !== 1) === true);
assert((1 !== 1n) === true);
assert((1n !== 1.23) === true);
assert((1.23 !== 1n) === true);
console.log("PASS");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
console.log("FAIL: " + e);
}

View file

@ -1,82 +1,118 @@
load("test-common.js");
try {
[1, null, undefined].forEach(value => {
assertThrowsError(() => {
1n + value;
}, {
error: TypeError,
message: "Cannot use addition operator with BigInt and other type"
});
assertThrowsError(() => {
1n - value;
}, {
error: TypeError,
message: "Cannot use subtraction operator with BigInt and other type"
});
assertThrowsError(() => {
1n * value;
}, {
error: TypeError,
message: "Cannot use multiplication operator with BigInt and other type"
});
assertThrowsError(() => {
1n / value;
}, {
error: TypeError,
message: "Cannot use division operator with BigInt and other type"
});
assertThrowsError(() => {
1n % value;
}, {
error: TypeError,
message: "Cannot use modulo operator with BigInt and other type"
});
assertThrowsError(() => {
1n ** value;
}, {
error: TypeError,
message: "Cannot use exponentiation operator with BigInt and other type"
});
assertThrowsError(() => {
1n | value;
}, {
error: TypeError,
message: "Cannot use bitwise OR operator with BigInt and other type"
});
assertThrowsError(() => {
1n & value;
}, {
error: TypeError,
message: "Cannot use bitwise AND operator with BigInt and other type"
});
assertThrowsError(() => {
1n ^ value;
}, {
error: TypeError,
message: "Cannot use bitwise XOR operator with BigInt and other type"
});
assertThrowsError(() => {
1n << value;
}, {
error: TypeError,
message: "Cannot use left-shift operator with BigInt and other type"
});
assertThrowsError(() => {
1n >> value;
}, {
error: TypeError,
message: "Cannot use right-shift operator with BigInt and other type"
});
assertThrowsError(() => {
1n >>> value;
}, {
error: TypeError,
message: "Cannot use unsigned right-shift operator with BigInt"
});
});
[1, null, undefined].forEach(value => {
assertThrowsError(
() => {
1n + value;
},
{
error: TypeError,
message: "Cannot use addition operator with BigInt and other type",
}
);
assertThrowsError(
() => {
1n - value;
},
{
error: TypeError,
message: "Cannot use subtraction operator with BigInt and other type",
}
);
assertThrowsError(
() => {
1n * value;
},
{
error: TypeError,
message: "Cannot use multiplication operator with BigInt and other type",
}
);
assertThrowsError(
() => {
1n / value;
},
{
error: TypeError,
message: "Cannot use division operator with BigInt and other type",
}
);
assertThrowsError(
() => {
1n % value;
},
{
error: TypeError,
message: "Cannot use modulo operator with BigInt and other type",
}
);
assertThrowsError(
() => {
1n ** value;
},
{
error: TypeError,
message: "Cannot use exponentiation operator with BigInt and other type",
}
);
assertThrowsError(
() => {
1n | value;
},
{
error: TypeError,
message: "Cannot use bitwise OR operator with BigInt and other type",
}
);
assertThrowsError(
() => {
1n & value;
},
{
error: TypeError,
message: "Cannot use bitwise AND operator with BigInt and other type",
}
);
assertThrowsError(
() => {
1n ^ value;
},
{
error: TypeError,
message: "Cannot use bitwise XOR operator with BigInt and other type",
}
);
assertThrowsError(
() => {
1n << value;
},
{
error: TypeError,
message: "Cannot use left-shift operator with BigInt and other type",
}
);
assertThrowsError(
() => {
1n >> value;
},
{
error: TypeError,
message: "Cannot use right-shift operator with BigInt and other type",
}
);
assertThrowsError(
() => {
1n >>> value;
},
{
error: TypeError,
message: "Cannot use unsigned right-shift operator with BigInt",
}
);
});
console.log("PASS");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
console.log("FAIL: " + e);
}