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
16function f() {
17  try {
18    a;
19    assert (false);
20  } catch (e) {
21    assert (e instanceof ReferenceError);
22  }
23
24  eval ("assert (a === undefined); { function a() { return 5; } }");
25  assert (a() === 5);
26
27  /* Variables created by eval can be deleted. */
28  delete a;
29
30  try {
31    a;
32    assert (false);
33  } catch (e) {
34    assert (e instanceof ReferenceError);
35  }
36}
37f();
38
39function g() {
40  let a = 1;
41
42  eval ("assert (a === 1);"
43        + "{ function a() { return 2; } assert (a() === 2) }"
44        + "assert (a === 1);");
45
46  assert (a === 1);
47}
48g();
49