|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 |
|
7 /** |
|
8 File Name: 10.1.8 |
|
9 ECMA Section: Arguments Object |
|
10 Description: |
|
11 |
|
12 When control enters an execution context for declared function code, |
|
13 anonymous code, or implementation-supplied code, an arguments object is |
|
14 created and initialized as follows: |
|
15 |
|
16 The [[Prototype]] of the arguments object is to the original Object |
|
17 prototype object, the one that is the initial value of Object.prototype |
|
18 (section 15.2.3.1). |
|
19 |
|
20 A property is created with name callee and property attributes {DontEnum}. |
|
21 The initial value of this property is the function object being executed. |
|
22 This allows anonymous functions to be recursive. |
|
23 |
|
24 A property is created with name length and property attributes {DontEnum}. |
|
25 The initial value of this property is the number of actual parameter values |
|
26 supplied by the caller. |
|
27 |
|
28 For each non-negative integer, iarg, less than the value of the length |
|
29 property, a property is created with name ToString(iarg) and property |
|
30 attributes { DontEnum }. The initial value of this property is the value |
|
31 of the corresponding actual parameter supplied by the caller. The first |
|
32 actual parameter value corresponds to iarg = 0, the second to iarg = 1 and |
|
33 so on. In the case when iarg is less than the number of formal parameters |
|
34 for the function object, this property shares its value with the |
|
35 corresponding property of the activation object. This means that changing |
|
36 this property changes the corresponding property of the activation object |
|
37 and vice versa. The value sharing mechanism depends on the implementation. |
|
38 |
|
39 Author: christine@netscape.com |
|
40 Date: 12 november 1997 |
|
41 */ |
|
42 |
|
43 var SECTION = "10.1.8"; |
|
44 var VERSION = "ECMA_1"; |
|
45 startTest(); |
|
46 var TITLE = "Arguments Object"; |
|
47 |
|
48 writeHeaderToLog( SECTION + " "+ TITLE); |
|
49 |
|
50 var ARG_STRING = "value of the argument property"; |
|
51 |
|
52 new TestCase( SECTION, |
|
53 "GetCallee()", |
|
54 GetCallee, |
|
55 GetCallee() ); |
|
56 |
|
57 var LIMIT = 100; |
|
58 |
|
59 for ( var i = 0, args = "" ; i < LIMIT; i++ ) { |
|
60 args += String(i) + ( i+1 < LIMIT ? "," : "" ); |
|
61 |
|
62 } |
|
63 |
|
64 var LENGTH = eval( "GetLength("+ args +")" ); |
|
65 |
|
66 new TestCase( SECTION, |
|
67 "GetLength("+args+")", |
|
68 100, |
|
69 LENGTH ); |
|
70 |
|
71 var ARGUMENTS = eval( "GetArguments( " +args+")" ); |
|
72 |
|
73 for ( var i = 0; i < 100; i++ ) { |
|
74 new TestCase( SECTION, |
|
75 "GetArguments("+args+")["+i+"]", |
|
76 i, |
|
77 ARGUMENTS[i] ); |
|
78 } |
|
79 |
|
80 test(); |
|
81 |
|
82 function TestFunction() { |
|
83 var arg_proto = arguments.__proto__; |
|
84 } |
|
85 function GetCallee() { |
|
86 var c = arguments.callee; |
|
87 return c; |
|
88 } |
|
89 function GetArguments() { |
|
90 var a = arguments; |
|
91 return a; |
|
92 } |
|
93 function GetLength() { |
|
94 var l = arguments.length; |
|
95 return l; |
|
96 } |
|
97 |
|
98 function AnotherTestFunction() { |
|
99 this.__proto__ = new Prototype(); |
|
100 return this; |
|
101 } |