js/src/tests/js1_4/Eval/eval-003.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_4/Eval/eval-003.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,67 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +
    1.10 +/**
    1.11 + *  File Name:    eval-003.js
    1.12 + *  Description:  (SEE REVISED DESCRIPTION FURTHER BELOW)
    1.13 + *
    1.14 + *  The global eval function may not be accessed indirectly and then called.
    1.15 + *  This feature will continue to work in JavaScript 1.3 but will result in an
    1.16 + *  error in JavaScript 1.4. This restriction is also in place for the With and
    1.17 + *  Closure constructors.
    1.18 + *
    1.19 + *  http://scopus.mcom.com/bugsplat/show_bug.cgi?id=324451
    1.20 + *
    1.21 + *  Author:          christine@netscape.com
    1.22 + *  Date:               11 August 1998
    1.23 + *
    1.24 + *
    1.25 + *  REVISION:    05  February 2001
    1.26 + *  Author:          pschwartau@netscape.com
    1.27 + * 
    1.28 + *  Indirect eval IS NOT ILLEGAL per ECMA3!!!  See
    1.29 + *
    1.30 + *  http://bugzilla.mozilla.org/show_bug.cgi?id=38512
    1.31 + *
    1.32 + *  ------- Additional Comments From Brendan Eich 2001-01-30 17:12 -------
    1.33 + * ECMA-262 Edition 3 doesn't require implementations to throw EvalError,
    1.34 + * see the short, section-less Chapter 16.  It does say an implementation that
    1.35 + * doesn't throw EvalError must allow assignment to eval and indirect calls
    1.36 + * of the evalnative method.
    1.37 + *
    1.38 + */
    1.39 +var SECTION = "eval-003.js";
    1.40 +var VERSION = "JS1_4";
    1.41 +var TITLE   = "Calling eval indirectly should NOT fail in version 140";
    1.42 +var BUGNUMBER="38512";
    1.43 +
    1.44 +startTest();
    1.45 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.46 +
    1.47 +var MY_EVAL = eval;
    1.48 +var RESULT = "";
    1.49 +var EXPECT= "";
    1.50 +var h = function f(x,y){var g = function(z){return Math.exp(z);}; return g(x+y);};
    1.51 +   
    1.52 +
    1.53 +new EvalTest();
    1.54 +
    1.55 +test();
    1.56 +
    1.57 +function EvalTest()
    1.58 +{
    1.59 +  with( this ) {
    1.60 +    MY_EVAL( "RESULT = h(-1, 1)" );
    1.61 +    EXPECT = 1;  //The base e to the power (-1 + 1),  i.e. the power 0,  equals 1 ....
    1.62 +
    1.63 +    new TestCase(
    1.64 +      SECTION,
    1.65 +      "Call eval indirectly",
    1.66 +      EXPECT,
    1.67 +      RESULT );
    1.68 +  }
    1.69 +}
    1.70 +

mercurial