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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma/extensions/10.1.8-1.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,101 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +
    1.10 +/**
    1.11 +   File Name:          10.1.8
    1.12 +   ECMA Section:       Arguments Object
    1.13 +   Description:
    1.14 +
    1.15 +   When control enters an execution context for declared function code,
    1.16 +   anonymous code, or implementation-supplied code, an arguments object is
    1.17 +   created and initialized as follows:
    1.18 +
    1.19 +   The [[Prototype]] of the arguments object is to the original Object
    1.20 +   prototype object, the one that is the initial value of Object.prototype
    1.21 +   (section 15.2.3.1).
    1.22 +
    1.23 +   A property is created with name callee and property attributes {DontEnum}.
    1.24 +   The initial value of this property is the function object being executed.
    1.25 +   This allows anonymous functions to be recursive.
    1.26 +
    1.27 +   A property is created with name length and property attributes {DontEnum}.
    1.28 +   The initial value of this property is the number of actual parameter values
    1.29 +   supplied by the caller.
    1.30 +
    1.31 +   For each non-negative integer, iarg, less than the value of the length
    1.32 +   property, a property is created with name ToString(iarg) and property
    1.33 +   attributes { DontEnum }. The initial value of this property is the value
    1.34 +   of the corresponding actual parameter supplied by the caller. The first
    1.35 +   actual parameter value corresponds to iarg = 0, the second to iarg = 1 and
    1.36 +   so on. In the case when iarg is less than the number of formal parameters
    1.37 +   for the function object, this property shares its value with the
    1.38 +   corresponding property of the activation object. This means that changing
    1.39 +   this property changes the corresponding property of the activation object
    1.40 +   and vice versa. The value sharing mechanism depends on the implementation.
    1.41 +
    1.42 +   Author:             christine@netscape.com
    1.43 +   Date:               12 november 1997
    1.44 +*/
    1.45 +
    1.46 +var SECTION = "10.1.8";
    1.47 +var VERSION = "ECMA_1";
    1.48 +startTest();
    1.49 +var TITLE   = "Arguments Object";
    1.50 +
    1.51 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.52 +
    1.53 +var ARG_STRING = "value of the argument property";
    1.54 +
    1.55 +new TestCase( SECTION,
    1.56 +	      "GetCallee()",
    1.57 +	      GetCallee,
    1.58 +	      GetCallee() );
    1.59 +
    1.60 +var LIMIT = 100;
    1.61 +
    1.62 +for ( var i = 0, args = "" ; i < LIMIT; i++ ) {
    1.63 +  args += String(i) + ( i+1 < LIMIT ? "," : "" );
    1.64 +
    1.65 +}
    1.66 +
    1.67 +var LENGTH = eval( "GetLength("+ args +")" );
    1.68 +
    1.69 +new TestCase( SECTION,
    1.70 +	      "GetLength("+args+")",
    1.71 +	      100,
    1.72 +	      LENGTH );
    1.73 +
    1.74 +var ARGUMENTS = eval( "GetArguments( " +args+")" );
    1.75 +
    1.76 +for ( var i = 0; i < 100; i++ ) {
    1.77 +  new TestCase( SECTION,
    1.78 +		"GetArguments("+args+")["+i+"]",
    1.79 +		i,
    1.80 +		ARGUMENTS[i] );
    1.81 +}
    1.82 +
    1.83 +test();
    1.84 +
    1.85 +function TestFunction() {
    1.86 +  var arg_proto = arguments.__proto__;
    1.87 +}
    1.88 +function GetCallee() {
    1.89 +  var c = arguments.callee;
    1.90 +  return c;
    1.91 +}
    1.92 +function GetArguments() {
    1.93 +  var a = arguments;
    1.94 +  return a;
    1.95 +}
    1.96 +function GetLength() {
    1.97 +  var l = arguments.length;
    1.98 +  return l;
    1.99 +}
   1.100 +
   1.101 +function AnotherTestFunction() {
   1.102 +  this.__proto__ = new Prototype();
   1.103 +  return this;
   1.104 +}

mercurial