Debian Codegraph @

rhino/testsrc/tests/js1_4/Eval/eval-003.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 gTestfile = 'eval-003.js';
7
8 /**
9 * File Name: eval-003.js
10 * Description: (SEE REVISED DESCRIPTION FURTHER BELOW)
11 *
12 * The global eval function may not be accessed indirectly and then called.
13 * This feature will continue to work in JavaScript 1.3 but will result in an
14 * error in JavaScript 1.4. This restriction is also in place for the With and
15 * Closure constructors.
16 *
17 * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=324451
18 *
19 * Author: [email protected]
20 * Date: 11 August 1998
21 *
22 *
23 * REVISION: 05 February 2001
24 * Author: [email protected]
25 *
26 * Indirect eval IS NOT ILLEGAL per ECMA3!!! See
27 *
28 * http://bugzilla.mozilla.org/show_bug.cgi?id=38512
29 *
30 * ------- Additional Comments From Brendan Eich 2001-01-30 17:12 -------
31 * ECMA-262 Edition 3 doesn't require implementations to throw EvalError,
32 * see the short, section-less Chapter 16. It does say an implementation that
33 * doesn't throw EvalError must allow assignment to eval and indirect calls
34 * of the evalnative method.
35 *
36 */
37 var SECTION = "eval-003.js";
38 var VERSION = "JS1_4";
39 var TITLE = "Calling eval indirectly should NOT fail in version 140";
40 var BUGNUMBER="38512";
41
42 startTest();
43 writeHeaderToLog( SECTION + " "+ TITLE);
44
45 var MY_EVAL = eval;
46 var RESULT = "";
47 var EXPECT= "";
48 var h = function f(x,y){var g = function(z){return Math.exp(z);}; return g(x+y);};
49
50
51 new EvalTest();
52
53 test();
54
55 function EvalTest()
56 {
57 with( this ) {
58 MY_EVAL( "RESULT = h(-1, 1)" );
59 EXPECT = 1; //The base e to the power (-1 + 1), i.e. the power 0, equals 1 ....
60
61 new TestCase(
62 SECTION,
63 "Call eval indirectly",
64 EXPECT,
65 RESULT );
66 }
67 }
68