1/* Copyright JS Foundation and other contributors, http://js.foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16var e = -1
17
18function f1()
19{
20  assert(e === undefined)
21  try {
22    throw 0
23  } catch (e) {
24    var e = 1
25    assert(e === 1)
26  }
27  assert(e === undefined)
28}
29f1()
30
31function f2()
32{
33  assert(e === undefined)
34  try {
35    throw 0
36  } catch (e) {
37    {
38      var e = 2
39      assert(e === 2)
40    }
41    assert(e === 2)
42  }
43  assert(e === undefined)
44}
45f2()
46
47function f3()
48{
49  assert(e === -1)
50  try {
51    throw [0]
52  } catch ([e]) {
53    {
54      try {
55        eval("var e = 2")
56        assert(false)
57      } catch (e) {
58        assert(e instanceof SyntaxError)
59      }
60    }
61    assert(e === 0)
62  }
63  assert(e === -1)
64}
65f3()
66
67function f4()
68{
69  assert(e === undefined)
70  try {
71    throw 0
72  } catch (e) {
73    {
74      function e() { return 3 }
75      assert(e() === 3)
76    }
77    assert(e === 0)
78  }
79  assert(e() === 3)
80}
81f4()
82
83function f5()
84{
85  assert(e === -1)
86  try {
87    throw 0
88  } catch (e) {
89    {
90      eval("function e() { return 3 } assert(e === 0)")
91      assert(e === 0)
92    }
93    assert(e === 0)
94  }
95  assert(e() === 3)
96}
97f5()
98
99function f6()
100{
101  let e = 4;
102  assert(e === 4)
103  try {
104    throw 0
105  } catch (e) {
106    {
107      function e() { return 5 }
108      assert(e() === 5)
109    }
110    assert(e === 0)
111  }
112  assert(e === 4)
113}
114f6()
115
116function f7()
117{
118  let e = 6;
119  assert(e === 6)
120  try {
121    throw 0
122  } catch (e) {
123    {
124      eval("function e() { return 7 } assert(e() === 7)")
125    }
126    assert(e === 0)
127  }
128  assert(e === 6)
129}
130f7()
131