summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests/throw-basic.js
blob: 6cf2c0fe58a086862d2fa1f833a5265613600054 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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");