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/ 5 * 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. 10 * 11 * The Original Code is Mozilla Communicator client code, released March 12 * 31, 1998. 13 * 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 17 * Rights Reserved. 18 * 19 * Contributor(s): 20 * 21 */ 22/** 23 * File Name: function-001.js 24 * Description: 25 * 26 * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=324455 27 * 28 * Earlier versions of JavaScript supported access to the arguments property 29 * of the function object. This property held the arguments to the function. 30 * function f() { 31 * return f.arguments[0]; // deprecated 32 * } 33 * var x = f(3); // x will be 3 34 * 35 * This feature is not a part of the final ECMA standard. Instead, scripts 36 * should simply use just "arguments": 37 * 38 * function f() { 39 * return arguments[0]; // okay 40 * } 41 * 42 * var x = f(3); // x will be 3 43 * 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. 49 * 50 * Author: christine@netscape.com 51 * Date: 11 August 1998 52 */ 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"; 57 startTest(); 58 writeHeaderToLog( SECTION + " "+ TITLE); 59 60 var testcases = new Array(); 61 62 testcases[tc++] = new TestCase( 63 SECTION, 64 "return function.arguments", 65 "P", 66 TestFunction_2("P", "A","S","S")[0] +""); 67 68 69 testcases[tc++] = new TestCase( 70 SECTION, 71 "return arguments", 72 "P", 73 TestFunction_1( "P", "A", "S", "S" )[0] +""); 74 75 testcases[tc++] = new TestCase( 76 SECTION, 77 "return arguments when function contains an arguments property", 78 "PASS", 79 TestFunction_3( "P", "A", "S", "S" ) +""); 80 81 testcases[tc++] = new TestCase( 82 SECTION, 83 "return function.arguments when function contains an arguments property", 84 "PASS", 85 TestFunction_4( "P", "A", "S", "S" ) +""); 86 87 test(); 88 89 function TestFunction_1( a, b, c, d, e ) { 90 return arguments; 91 } 92 93 function TestFunction_2( a, b, c, d, e ) { 94 return TestFunction_2.arguments; 95 } 96 97 function TestFunction_3( a, b, c, d, e ) { 98 var arguments = "PASS"; 99 return arguments; 100 } 101 102 function TestFunction_4( a, b, c, d, e ) { 103 var arguments = "FAIL"; 104 return Array.prototype.join.call(TestFunction_4.arguments, ""); 105 } 106 107