Debian Codegraph @

rhino/testsrc/tests/js1_5/Scope/regress-446026-01.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 var gTestfile = 'regress-446026-01.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 446026;
9 var summary = 'brian loves eval(s, o)';
10 var actual = '';
11 var expect = '';
12
13 printBugNumber(BUGNUMBER);
14 printStatus (summary);
15
16 var b = 45;
17
18 // Getting "private" variables
19 var obj = (function() {
20 var a = 21;
21 return {
22 // public function must reference 'a'
23 fn: function() {a;}
24 };
25 })();
26
27 expect = 'ReferenceError: a is not defined | undefined | 45';
28 actual = '';
29
30 var foo;
31
32 try {
33 eval('bar = b; foo=a', obj.fn);
34 } catch (e) {
35 actual = e;
36 }
37 print(actual += " | " + foo + " | " + bar); // 21
38 reportCompare(expect, actual, summary);
39
40 expect = 'No Error';
41 actual = 'No Error';
42
43 try
44 {
45 eval("", {print:1});
46 print(1);
47 }
48 catch(ex)
49 {
50 actual = ex + '';
51 }
52 reportCompare(expect, actual, summary);