michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: /** michael@0: * File Name: function-001.js michael@0: * Description: michael@0: * michael@0: * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=324455 michael@0: * michael@0: * Earlier versions of JavaScript supported access to the arguments property michael@0: * of the function object. This property held the arguments to the function. michael@0: * function f() { michael@0: * return f.arguments[0]; // deprecated michael@0: * } michael@0: * var x = f(3); // x will be 3 michael@0: * michael@0: * This feature is not a part of the final ECMA standard. Instead, scripts michael@0: * should simply use just "arguments": michael@0: * michael@0: * function f() { michael@0: * return arguments[0]; // okay michael@0: * } michael@0: * michael@0: * var x = f(3); // x will be 3 michael@0: * michael@0: * Again, this feature was motivated by performance concerns. Access to the michael@0: * arguments property is not threadsafe, which is of particular concern in michael@0: * server environments. Also, the compiler can generate better code for michael@0: * functions because it can tell when the arguments are being accessed only by michael@0: * name and avoid setting up the arguments object. michael@0: * michael@0: * Author: christine@netscape.com michael@0: * Date: 11 August 1998 michael@0: */ michael@0: var SECTION = "function-001.js"; michael@0: var VERSION = "JS1_4"; michael@0: var TITLE = "Accessing the arguments property of a function object"; michael@0: var BUGNUMBER="324455"; michael@0: startTest(); michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: new TestCase( michael@0: SECTION, michael@0: "return function.arguments", michael@0: "P", michael@0: TestFunction_2("P", "A","S","S")[0] +""); michael@0: michael@0: michael@0: new TestCase( michael@0: SECTION, michael@0: "return arguments", michael@0: "P", michael@0: TestFunction_1( "P", "A", "S", "S" )[0] +""); michael@0: michael@0: new TestCase( michael@0: SECTION, michael@0: "return arguments when function contains an arguments property", michael@0: "PASS", michael@0: TestFunction_3( "P", "A", "S", "S" ) +""); michael@0: michael@0: new TestCase( michael@0: SECTION, michael@0: "return function.arguments when function contains an arguments property", michael@0: "[object Arguments]", michael@0: TestFunction_4( "F", "A", "I", "L" ) +""); michael@0: michael@0: test(); michael@0: michael@0: function TestFunction_1( a, b, c, d, e ) { michael@0: return arguments; michael@0: } michael@0: michael@0: function TestFunction_2( a, b, c, d, e ) { michael@0: return TestFunction_2.arguments; michael@0: } michael@0: michael@0: function TestFunction_3( a, b, c, d, e ) { michael@0: var arguments = "PASS"; michael@0: return arguments; michael@0: } michael@0: michael@0: function TestFunction_4( a, b, c, d, e ) { michael@0: var arguments = "FAIL"; michael@0: return TestFunction_4.arguments; michael@0: } michael@0: