js/src/tests/ecma/extensions/10.1.6.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.6.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,93 @@
     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.6
    1.12 +   ECMA Section:       Activation Object
    1.13 +   Description:
    1.14 +
    1.15 +   If the function object being invoked has an arguments property, let x be
    1.16 +   the value of that property; the activation object is also given an internal
    1.17 +   property [[OldArguments]] whose initial value is x; otherwise, an arguments
    1.18 +   property is created for the function object but the activation object is
    1.19 +   not given an [[OldArguments]] property. Next, arguments object described
    1.20 +   below (the same one stored in the arguments property of the activation
    1.21 +   object) is used as the new value of the arguments property of the function
    1.22 +   object. This new value is installed even if the arguments property already
    1.23 +   exists and has the ReadOnly attribute (as it will for native Function
    1.24 +   objects). (These actions are taken to provide compatibility with a form of
    1.25 +   program syntax that is now discouraged: to access the arguments object for
    1.26 +   function f within the body of f by using the expression f.arguments.
    1.27 +   The recommended way to access the arguments object for function f within
    1.28 +   the body of f is simply to refer to the variable arguments.)
    1.29 +
    1.30 +   Author:             christine@netscape.com
    1.31 +   Date:               12 november 1997
    1.32 +*/
    1.33 +
    1.34 +var SECTION = "10.1.6";
    1.35 +var VERSION = "ECMA_1";
    1.36 +startTest();
    1.37 +var TITLE   = "Activation Object";
    1.38 +
    1.39 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.40 +
    1.41 +var arguments = "FAILED!";
    1.42 +
    1.43 +var ARG_STRING = "value of the argument property";
    1.44 +
    1.45 +new TestCase( SECTION,
    1.46 +	      "(new TestObject(0,1,2,3,4,5)).length",
    1.47 +	      6,
    1.48 +	      (new TestObject(0,1,2,3,4,5)).length );
    1.49 +
    1.50 +for ( i = 0; i < 6; i++ ) {
    1.51 +
    1.52 +  new TestCase( SECTION,
    1.53 +		"(new TestObject(0,1,2,3,4,5))["+i+"]",
    1.54 +		i,
    1.55 +		(new TestObject(0,1,2,3,4,5))[i]);
    1.56 +}
    1.57 +
    1.58 +
    1.59 +//    The current object already has an arguments property.
    1.60 +
    1.61 +new TestCase( SECTION,
    1.62 +	      "(new AnotherTestObject(1,2,3)).arguments",
    1.63 +	      ARG_STRING,
    1.64 +	      (new AnotherTestObject(1,2,3)).arguments );
    1.65 +
    1.66 +//  The function invoked with [[Call]]
    1.67 +
    1.68 +new TestCase( SECTION,
    1.69 +	      "TestFunction(1,2,3)",
    1.70 +	      ARG_STRING,
    1.71 +	      TestFunction() + '' );
    1.72 +
    1.73 +
    1.74 +test();
    1.75 +
    1.76 +
    1.77 +
    1.78 +function Prototype() {
    1.79 +  this.arguments = ARG_STRING;
    1.80 +}
    1.81 +function TestObject() {
    1.82 +  this.__proto__ = new Prototype();
    1.83 +  return arguments;
    1.84 +}
    1.85 +function AnotherTestObject() {
    1.86 +  this.__proto__ = new Prototype();
    1.87 +  return this;
    1.88 +}
    1.89 +function TestFunction() {
    1.90 +  arguments = ARG_STRING;
    1.91 +  return arguments;
    1.92 +}
    1.93 +function AnotherTestFunction() {
    1.94 +  this.__proto__ = new Prototype();
    1.95 +  return this;
    1.96 +}

mercurial