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