initial import
[vuplus_webkit] / Source / JavaScriptCore / 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/
5  *
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.
10  *
11  * The Original Code is Mozilla Communicator client code, released March
12  * 31, 1998.
13  *
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
17  * Rights Reserved.
18  *
19  * Contributor(s): 
20  * 
21  */
22 /**
23     File Name:          10.1.8
24     ECMA Section:       Arguments Object
25     Description:
26
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:
30
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
33     (section 15.2.3.1).
34
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.
38
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.
42
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.
53
54     Author:             christine@netscape.com
55     Date:               12 november 1997
56 */
57
58     var SECTION = "10.1.8";
59     var VERSION = "ECMA_1";
60     startTest();
61     var TITLE   = "Arguments Object";
62
63     writeHeaderToLog( SECTION + " "+ TITLE);
64
65     var testcases = new Array();
66
67     var ARG_STRING = "value of the argument property";
68
69     testcases[tc++] = new TestCase( SECTION,
70                                     "GetCallee()",
71                                     GetCallee,
72                                     GetCallee() );
73
74     var LIMIT = 100;
75
76     for ( var i = 0, args = "" ; i < LIMIT; i++ ) {
77         args += String(i) + ( i+1 < LIMIT ? "," : "" );
78
79     }
80
81     var LENGTH = eval( "GetLength("+ args +")" );
82
83     testcases[tc++] = new TestCase( SECTION,
84                                     "GetLength("+args+")",
85                                     100,
86                                     LENGTH );
87
88     var ARGUMENTS = eval( "GetArguments( " +args+")" );
89
90     for ( var i = 0; i < 100; i++ ) {
91         testcases[tc++] = new TestCase( SECTION,
92                                         "GetArguments("+args+")["+i+"]",
93                                         i,
94                                         ARGUMENTS[i] );
95     }
96
97     test();
98
99 function TestFunction() {
100     var arg_proto = arguments.__proto__;
101 }
102 function GetCallee() {
103     var c = arguments.callee;
104     return c;
105 }
106 function GetArguments() {
107     var a = arguments;
108     return a;
109 }
110 function GetLength() {
111     var l = arguments.length;
112     return l;
113 }
114
115 function AnotherTestFunction() {
116     this.__proto__ = new Prototype();
117     return this;
118 }
119
120 function test() {
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 );
127
128         testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
129     }
130     stopTest();
131     return ( testcases );
132 }