summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/letTDZSwitchClosure.js
blob: c601f9858dd08c6b387a4854c4cd6d86b9933bd6 (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
50
51
52
53
54
55
56
57
58
59
60
function assertThrowsReferenceError(f) {
  var err;
  try {
    f();
  } catch (e) {
    err = e;
  }
  assertEq(err instanceof ReferenceError, true);
}

function f() {
    switch (0) {
        case 1:
            let x
        case function() {
            print(x)
        }():
    }
}
assertThrowsReferenceError(f);

function g() {
  switch (0) {
    case 1:
      let x;
    case 0:
      var inner = function () {
        print(x);
      }
      inner();
      break;
  }
}
assertThrowsReferenceError(g);

function h() {
  switch (0) {
    case 0:
      var inner = function () {
        print(x);
      }
      inner();
    case 1:
      let x;
  }
}
assertThrowsReferenceError(h);

// Tests that a dominating lexical doesn't throw.
function F() {
  switch (0) {
    case 0:
      let x = 42;
      var inner = function () {
        assertEq(x, 42);
      }
      inner();
  }
}
F();