]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/ExecutionContexts/10.1.8-1.js
1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
11 * The Original Code is Mozilla Communicator client code, released March
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
24 ECMA Section: Arguments Object
27 When control enters an execution context for declared function code,
28 anonymous code, or implementation-supplied code, an arguments object is
29 created and initialized as follows:
31 The [[Prototype]] of the arguments object is to the original Object
32 prototype object, the one that is the initial value of Object.prototype
35 A property is created with name callee and property attributes {DontEnum}.
36 The initial value of this property is the function object being executed.
37 This allows anonymous functions to be recursive.
39 A property is created with name length and property attributes {DontEnum}.
40 The initial value of this property is the number of actual parameter values
41 supplied by the caller.
43 For each non-negative integer, iarg, less than the value of the length
44 property, a property is created with name ToString(iarg) and property
45 attributes { DontEnum }. The initial value of this property is the value
46 of the corresponding actual parameter supplied by the caller. The first
47 actual parameter value corresponds to iarg = 0, the second to iarg = 1 and
48 so on. In the case when iarg is less than the number of formal parameters
49 for the function object, this property shares its value with the
50 corresponding property of the activation object. This means that changing
51 this property changes the corresponding property of the activation object
52 and vice versa. The value sharing mechanism depends on the implementation.
54 Author: christine@netscape.com
55 Date: 12 november 1997
58 var SECTION
= "10.1.8";
59 var VERSION
= "ECMA_1";
61 var TITLE
= "Arguments Object";
63 writeHeaderToLog( SECTION
+ " "+ TITLE
);
65 var testcases
= new Array();
67 var ARG_STRING
= "value of the argument property";
69 testcases
[tc
++] = new TestCase( SECTION
,
76 for ( var i
= 0, args
= "" ; i
< LIMIT
; i
++ ) {
77 args
+= String(i
) + ( i
+1 < LIMIT
? "," : "" );
81 var LENGTH
= eval( "GetLength("+ args
+")" );
83 testcases
[tc
++] = new TestCase( SECTION
,
84 "GetLength("+args
+")",
88 var ARGUMENTS
= eval( "GetArguments( " +args
+")" );
90 for ( var i
= 0; i
< 100; i
++ ) {
91 testcases
[tc
++] = new TestCase( SECTION
,
92 "GetArguments("+args
+")["+i
+"]",
99 function TestFunction() {
100 var arg_proto
= arguments
.__proto__
;
102 function GetCallee() {
103 var c
= arguments
.callee
;
106 function GetArguments() {
110 function GetLength() {
111 var l
= arguments
.length
;
115 function AnotherTestFunction() {
116 this.__proto__
= new Prototype();
121 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
122 testcases
[tc
].passed
= writeTestCaseResult(
123 testcases
[tc
].expect
,
124 testcases
[tc
].actual
,
125 testcases
[tc
].description
+" = "+
126 testcases
[tc
].actual
);
128 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
131 return ( testcases
);