~ubuntu-branches/ubuntu/trusty/mozjs24/trusty-proposed

« back to all changes in this revision

Viewing changes to js/src/tests/ecma/extensions/10.1.6.js

  • Committer: Package Import Robot
  • Author(s): Tim Lunn
  • Date: 2014-02-11 21:55:34 UTC
  • Revision ID: package-import@ubuntu.com-20140211215534-m1zyq5aj59md3y07
Tags: upstream-24.2.0
ImportĀ upstreamĀ versionĀ 24.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.6
 
9
   ECMA Section:       Activation Object
 
10
   Description:
 
11
 
 
12
   If the function object being invoked has an arguments property, let x be
 
13
   the value of that property; the activation object is also given an internal
 
14
   property [[OldArguments]] whose initial value is x; otherwise, an arguments
 
15
   property is created for the function object but the activation object is
 
16
   not given an [[OldArguments]] property. Next, arguments object described
 
17
   below (the same one stored in the arguments property of the activation
 
18
   object) is used as the new value of the arguments property of the function
 
19
   object. This new value is installed even if the arguments property already
 
20
   exists and has the ReadOnly attribute (as it will for native Function
 
21
   objects). (These actions are taken to provide compatibility with a form of
 
22
   program syntax that is now discouraged: to access the arguments object for
 
23
   function f within the body of f by using the expression f.arguments.
 
24
   The recommended way to access the arguments object for function f within
 
25
   the body of f is simply to refer to the variable arguments.)
 
26
 
 
27
   Author:             christine@netscape.com
 
28
   Date:               12 november 1997
 
29
*/
 
30
 
 
31
var SECTION = "10.1.6";
 
32
var VERSION = "ECMA_1";
 
33
startTest();
 
34
var TITLE   = "Activation Object";
 
35
 
 
36
writeHeaderToLog( SECTION + " "+ TITLE);
 
37
 
 
38
var arguments = "FAILED!";
 
39
 
 
40
var ARG_STRING = "value of the argument property";
 
41
 
 
42
new TestCase( SECTION,
 
43
              "(new TestObject(0,1,2,3,4,5)).length",
 
44
              6,
 
45
              (new TestObject(0,1,2,3,4,5)).length );
 
46
 
 
47
for ( i = 0; i < 6; i++ ) {
 
48
 
 
49
  new TestCase( SECTION,
 
50
                "(new TestObject(0,1,2,3,4,5))["+i+"]",
 
51
                i,
 
52
                (new TestObject(0,1,2,3,4,5))[i]);
 
53
}
 
54
 
 
55
 
 
56
//    The current object already has an arguments property.
 
57
 
 
58
new TestCase( SECTION,
 
59
              "(new AnotherTestObject(1,2,3)).arguments",
 
60
              ARG_STRING,
 
61
              (new AnotherTestObject(1,2,3)).arguments );
 
62
 
 
63
//  The function invoked with [[Call]]
 
64
 
 
65
new TestCase( SECTION,
 
66
              "TestFunction(1,2,3)",
 
67
              ARG_STRING,
 
68
              TestFunction() + '' );
 
69
 
 
70
 
 
71
test();
 
72
 
 
73
 
 
74
 
 
75
function Prototype() {
 
76
  this.arguments = ARG_STRING;
 
77
}
 
78
function TestObject() {
 
79
  this.__proto__ = new Prototype();
 
80
  return arguments;
 
81
}
 
82
function AnotherTestObject() {
 
83
  this.__proto__ = new Prototype();
 
84
  return this;
 
85
}
 
86
function TestFunction() {
 
87
  arguments = ARG_STRING;
 
88
  return arguments;
 
89
}
 
90
function AnotherTestFunction() {
 
91
  this.__proto__ = new Prototype();
 
92
  return this;
 
93
}