LibJS: Add a basic test for the "throw" keyword

This commit is contained in:
Andreas Kling 2020-03-25 16:09:23 +01:00
parent 9e8d3d6287
commit 30d24af54a
Notes: sideshowbarker 2024-07-19 08:08:05 +09:00

View file

@ -0,0 +1,26 @@
function assert(x) { if (!x) console.log("FAIL"); }
try {
throw 1;
} catch (e) {
assert(e === 1);
}
try {
throw [99];
} catch (e) {
assert(typeof e === "object");
assert(e.length === 1);
}
function foo() {
throw "hello";
}
try {
foo();
} catch (e) {
assert(e === "hello");
}
console.log("PASS");