js/src/tests/ecma/extensions/10.1.8-1.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     7 /**
     8    File Name:          10.1.8
     9    ECMA Section:       Arguments Object
    10    Description:
    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:
    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).
    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.
    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.
    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.
    39    Author:             christine@netscape.com
    40    Date:               12 november 1997
    41 */
    43 var SECTION = "10.1.8";
    44 var VERSION = "ECMA_1";
    45 startTest();
    46 var TITLE   = "Arguments Object";
    48 writeHeaderToLog( SECTION + " "+ TITLE);
    50 var ARG_STRING = "value of the argument property";
    52 new TestCase( SECTION,
    53 	      "GetCallee()",
    54 	      GetCallee,
    55 	      GetCallee() );
    57 var LIMIT = 100;
    59 for ( var i = 0, args = "" ; i < LIMIT; i++ ) {
    60   args += String(i) + ( i+1 < LIMIT ? "," : "" );
    62 }
    64 var LENGTH = eval( "GetLength("+ args +")" );
    66 new TestCase( SECTION,
    67 	      "GetLength("+args+")",
    68 	      100,
    69 	      LENGTH );
    71 var ARGUMENTS = eval( "GetArguments( " +args+")" );
    73 for ( var i = 0; i < 100; i++ ) {
    74   new TestCase( SECTION,
    75 		"GetArguments("+args+")["+i+"]",
    76 		i,
    77 		ARGUMENTS[i] );
    78 }
    80 test();
    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 }
    98 function AnotherTestFunction() {
    99   this.__proto__ = new Prototype();
   100   return this;
   101 }

mercurial