ladybird/Libraries/LibJS/Tests/throw-basic.js

31 lines
401 B
JavaScript
Raw Normal View History

load("test-common.js");
try {
throw 1;
2020-04-13 13:11:09 +00:00
assertNotReached();
} catch (e) {
assert(e === 1);
}
try {
throw [99];
2020-04-13 13:11:09 +00:00
assertNotReached();
} catch (e) {
assert(typeof e === "object");
assert(e.length === 1);
}
function foo() {
throw "hello";
2020-04-13 13:11:09 +00:00
assertNotReached();
}
try {
foo();
2020-04-13 13:11:09 +00:00
assertNotReached();
} catch (e) {
assert(e === "hello");
}
console.log("PASS");