• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
15function f() {
16  try {
17    a;
18    assert (false);
19  } catch (e) {
20    assert (e instanceof ReferenceError);
21  }
22
23  var o = { a:1 };
24
25  with (o)
26  {
27    eval("var a = 2")
28  }
29
30  assert (o.a === 2);
31  assert (a === undefined);
32}
33f();
34
35function g() {
36  try {
37    a;
38    assert (false);
39  } catch (e) {
40    assert (e instanceof ReferenceError);
41  }
42
43  var o = { a:1 };
44
45  with (o)
46  {
47    eval("function a() { return 8; }")
48  }
49
50  assert (o.a === 1);
51  assert (a() === 8);
52}
53g();
54