]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/js1_4/Functions/function-001.js
1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
11 * The Original Code is Mozilla Communicator client code, released March
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
23 * File Name: function-001.js
26 * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=324455
28 * Earlier versions of JavaScript supported access to the arguments property
29 * of the function object. This property held the arguments to the function.
31 * return f.arguments[0]; // deprecated
33 * var x = f(3); // x will be 3
35 * This feature is not a part of the final ECMA standard. Instead, scripts
36 * should simply use just "arguments":
39 * return arguments[0]; // okay
42 * var x = f(3); // x will be 3
44 * Again, this feature was motivated by performance concerns. Access to the
45 * arguments property is not threadsafe, which is of particular concern in
46 * server environments. Also, the compiler can generate better code for
47 * functions because it can tell when the arguments are being accessed only by
48 * name and avoid setting up the arguments object.
50 * Author: christine@netscape.com
51 * Date: 11 August 1998
53 var SECTION
= "function-001.js";
54 var VERSION
= "JS1_4";
55 var TITLE
= "Accessing the arguments property of a function object";
56 var BUGNUMBER
="324455";
58 writeHeaderToLog( SECTION
+ " "+ TITLE
);
60 var testcases
= new Array();
62 testcases
[tc
++] = new TestCase(
64 "return function.arguments",
66 TestFunction_2("P", "A","S","S")[0] +"");
69 testcases
[tc
++] = new TestCase(
73 TestFunction_1( "P", "A", "S", "S" )[0] +"");
75 testcases
[tc
++] = new TestCase(
77 "return arguments when function contains an arguments property",
79 TestFunction_3( "P", "A", "S", "S" ) +"");
81 testcases
[tc
++] = new TestCase(
83 "return function.arguments when function contains an arguments property",
85 TestFunction_4( "P", "A", "S", "S" ) +"");
89 function TestFunction_1( a
, b
, c
, d
, e
) {
93 function TestFunction_2( a
, b
, c
, d
, e
) {
94 return TestFunction_2
.arguments
;
97 function TestFunction_3( a
, b
, c
, d
, e
) {
98 var arguments
= "PASS";
102 function TestFunction_4( a
, b
, c
, d
, e
) {
103 var arguments
= "FAIL";
104 return Array
.prototype.join
.call(TestFunction_4
.arguments
, "");