js/src/tests/ecma/ExecutionContexts/10.1.8-2.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma/ExecutionContexts/10.1.8-2.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,86 @@
     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:          10.1.8-2
    1.12 +   ECMA Section:       Arguments Object
    1.13 +   Description:
    1.14 +
    1.15 +   When control enters an execution context for declared function code,
    1.16 +   anonymous code, or implementation-supplied code, an arguments object is
    1.17 +   created and initialized as follows:
    1.18 +
    1.19 +   The [[Prototype]] of the arguments object is to the original Object
    1.20 +   prototype object, the one that is the initial value of Object.prototype
    1.21 +   (section 15.2.3.1).
    1.22 +
    1.23 +   A property is created with name callee and property attributes {DontEnum}.
    1.24 +   The initial value of this property is the function object being executed.
    1.25 +   This allows anonymous functions to be recursive.
    1.26 +
    1.27 +   A property is created with name length and property attributes {DontEnum}.
    1.28 +   The initial value of this property is the number of actual parameter values
    1.29 +   supplied by the caller.
    1.30 +
    1.31 +   For each non-negative integer, iarg, less than the value of the length
    1.32 +   property, a property is created with name ToString(iarg) and property
    1.33 +   attributes { DontEnum }. The initial value of this property is the value
    1.34 +   of the corresponding actual parameter supplied by the caller. The first
    1.35 +   actual parameter value corresponds to iarg = 0, the second to iarg = 1 and
    1.36 +   so on. In the case when iarg is less than the number of formal parameters
    1.37 +   for the function object, this property shares its value with the
    1.38 +   corresponding property of the activation object. This means that changing
    1.39 +   this property changes the corresponding property of the activation object
    1.40 +   and vice versa. The value sharing mechanism depends on the implementation.
    1.41 +
    1.42 +   Author:             christine@netscape.com
    1.43 +   Date:               12 november 1997
    1.44 +*/
    1.45 +
    1.46 +var SECTION = "10.1.8-2";
    1.47 +var VERSION = "ECMA_1";
    1.48 +startTest();
    1.49 +var TITLE   = "Arguments Object";
    1.50 +
    1.51 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.52 +
    1.53 +//  Tests for anonymous functions
    1.54 +
    1.55 +var GetCallee       = new Function( "var c = arguments.callee; return c" );
    1.56 +var GetArguments    = new Function( "var a = arguments; return a" );
    1.57 +var GetLength       = new Function( "var l = arguments.length; return l" );
    1.58 +
    1.59 +var ARG_STRING = "value of the argument property";
    1.60 +
    1.61 +new TestCase( SECTION,
    1.62 +	      "GetCallee()",
    1.63 +	      GetCallee,
    1.64 +	      GetCallee() );
    1.65 +
    1.66 +var LIMIT = 100;
    1.67 +
    1.68 +for ( var i = 0, args = "" ; i < LIMIT; i++ ) {
    1.69 +  args += String(i) + ( i+1 < LIMIT ? "," : "" );
    1.70 +
    1.71 +}
    1.72 +
    1.73 +var LENGTH = eval( "GetLength("+ args +")" );
    1.74 +
    1.75 +new TestCase( SECTION,
    1.76 +	      "GetLength("+args+")",
    1.77 +	      100,
    1.78 +	      LENGTH );
    1.79 +
    1.80 +var ARGUMENTS = eval( "GetArguments( " +args+")" );
    1.81 +
    1.82 +for ( var i = 0; i < 100; i++ ) {
    1.83 +  new TestCase( SECTION,
    1.84 +		"GetArguments("+args+")["+i+"]",
    1.85 +		i,
    1.86 +		ARGUMENTS[i] );
    1.87 +}
    1.88 +
    1.89 +test();

mercurial