michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: /** michael@0: * File Name: eval-003.js michael@0: * Description: (SEE REVISED DESCRIPTION FURTHER BELOW) michael@0: * michael@0: * The global eval function may not be accessed indirectly and then called. michael@0: * This feature will continue to work in JavaScript 1.3 but will result in an michael@0: * error in JavaScript 1.4. This restriction is also in place for the With and michael@0: * Closure constructors. michael@0: * michael@0: * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=324451 michael@0: * michael@0: * Author: christine@netscape.com michael@0: * Date: 11 August 1998 michael@0: * michael@0: * michael@0: * REVISION: 05 February 2001 michael@0: * Author: pschwartau@netscape.com michael@0: * michael@0: * Indirect eval IS NOT ILLEGAL per ECMA3!!! See michael@0: * michael@0: * http://bugzilla.mozilla.org/show_bug.cgi?id=38512 michael@0: * michael@0: * ------- Additional Comments From Brendan Eich 2001-01-30 17:12 ------- michael@0: * ECMA-262 Edition 3 doesn't require implementations to throw EvalError, michael@0: * see the short, section-less Chapter 16. It does say an implementation that michael@0: * doesn't throw EvalError must allow assignment to eval and indirect calls michael@0: * of the evalnative method. michael@0: * michael@0: */ michael@0: var SECTION = "eval-003.js"; michael@0: var VERSION = "JS1_4"; michael@0: var TITLE = "Calling eval indirectly should NOT fail in version 140"; michael@0: var BUGNUMBER="38512"; michael@0: michael@0: startTest(); michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: var MY_EVAL = eval; michael@0: var RESULT = ""; michael@0: var EXPECT= ""; michael@0: var h = function f(x,y){var g = function(z){return Math.exp(z);}; return g(x+y);}; michael@0: michael@0: michael@0: new EvalTest(); michael@0: michael@0: test(); michael@0: michael@0: function EvalTest() michael@0: { michael@0: with( this ) { michael@0: MY_EVAL( "RESULT = h(-1, 1)" ); michael@0: EXPECT = 1; //The base e to the power (-1 + 1), i.e. the power 0, equals 1 .... michael@0: michael@0: new TestCase( michael@0: SECTION, michael@0: "Call eval indirectly", michael@0: EXPECT, michael@0: RESULT ); michael@0: } michael@0: } michael@0: