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: 10.1.8 michael@0: ECMA Section: Arguments Object michael@0: Description: michael@0: michael@0: When control enters an execution context for declared function code, michael@0: anonymous code, or implementation-supplied code, an arguments object is michael@0: created and initialized as follows: michael@0: michael@0: The [[Prototype]] of the arguments object is to the original Object michael@0: prototype object, the one that is the initial value of Object.prototype michael@0: (section 15.2.3.1). michael@0: michael@0: A property is created with name callee and property attributes {DontEnum}. michael@0: The initial value of this property is the function object being executed. michael@0: This allows anonymous functions to be recursive. michael@0: michael@0: A property is created with name length and property attributes {DontEnum}. michael@0: The initial value of this property is the number of actual parameter values michael@0: supplied by the caller. michael@0: michael@0: For each non-negative integer, iarg, less than the value of the length michael@0: property, a property is created with name ToString(iarg) and property michael@0: attributes { DontEnum }. The initial value of this property is the value michael@0: of the corresponding actual parameter supplied by the caller. The first michael@0: actual parameter value corresponds to iarg = 0, the second to iarg = 1 and michael@0: so on. In the case when iarg is less than the number of formal parameters michael@0: for the function object, this property shares its value with the michael@0: corresponding property of the activation object. This means that changing michael@0: this property changes the corresponding property of the activation object michael@0: and vice versa. The value sharing mechanism depends on the implementation. michael@0: michael@0: Author: christine@netscape.com michael@0: Date: 12 november 1997 michael@0: */ michael@0: michael@0: var SECTION = "10.1.8"; michael@0: var VERSION = "ECMA_1"; michael@0: startTest(); michael@0: var TITLE = "Arguments Object"; michael@0: michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: var ARG_STRING = "value of the argument property"; michael@0: michael@0: new TestCase( SECTION, michael@0: "GetCallee()", michael@0: GetCallee, michael@0: GetCallee() ); michael@0: michael@0: var LIMIT = 100; michael@0: michael@0: for ( var i = 0, args = "" ; i < LIMIT; i++ ) { michael@0: args += String(i) + ( i+1 < LIMIT ? "," : "" ); michael@0: michael@0: } michael@0: michael@0: var LENGTH = eval( "GetLength("+ args +")" ); michael@0: michael@0: new TestCase( SECTION, michael@0: "GetLength("+args+")", michael@0: 100, michael@0: LENGTH ); michael@0: michael@0: var ARGUMENTS = eval( "GetArguments( " +args+")" ); michael@0: michael@0: for ( var i = 0; i < 100; i++ ) { michael@0: new TestCase( SECTION, michael@0: "GetArguments("+args+")["+i+"]", michael@0: i, michael@0: ARGUMENTS[i] ); michael@0: } michael@0: michael@0: test(); michael@0: michael@0: function TestFunction() { michael@0: var arg_proto = arguments.__proto__; michael@0: } michael@0: function GetCallee() { michael@0: var c = arguments.callee; michael@0: return c; michael@0: } michael@0: function GetArguments() { michael@0: var a = arguments; michael@0: return a; michael@0: } michael@0: function GetLength() { michael@0: var l = arguments.length; michael@0: return l; michael@0: } michael@0: michael@0: function AnotherTestFunction() { michael@0: this.__proto__ = new Prototype(); michael@0: return this; michael@0: }