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