summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/throw-exception-stack-location.js
blob: d3c5ea9dabc9ecb0c450b2b3244cd31fb4ed3f32 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function throwValue(value) {
  throw value;
}

// Test for-of loops keep the exception stack.
function testForOfLoop() {
  function f() {
    for (let _ of [null]) {
      throwValue("exception-value");
    }
  }

  let info = getExceptionInfo(f);
  assertEq(info.exception, "exception-value");
  assertEq(info.stack.includes("throwValue"), true);
}
testForOfLoop();

// Test try-finally keep the exception stack.
function testFinally() {
  function f() {
    try {
      throwValue("exception-value");
    } finally {
    }
  }

  let info = getExceptionInfo(f);
  assertEq(info.exception, "exception-value");
  assertEq(info.stack.includes("throwValue"), true);
}
testFinally();

// Test try-catch-finally keep the exception stack.
function testCatchFinally() {
  function f() {
    try {
      throw null;
    } catch {
     throwValue("exception-value");
    } finally {
    }
  }

  let info = getExceptionInfo(f);
  assertEq(info.exception, "exception-value");
  assertEq(info.stack.includes("throwValue"), true);
}
testCatchFinally();