1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_4/Functions/function-001.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,89 @@ 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: function-001.js 1.12 + * Description: 1.13 + * 1.14 + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=324455 1.15 + * 1.16 + * Earlier versions of JavaScript supported access to the arguments property 1.17 + * of the function object. This property held the arguments to the function. 1.18 + * function f() { 1.19 + * return f.arguments[0]; // deprecated 1.20 + * } 1.21 + * var x = f(3); // x will be 3 1.22 + * 1.23 + * This feature is not a part of the final ECMA standard. Instead, scripts 1.24 + * should simply use just "arguments": 1.25 + * 1.26 + * function f() { 1.27 + * return arguments[0]; // okay 1.28 + * } 1.29 + * 1.30 + * var x = f(3); // x will be 3 1.31 + * 1.32 + * Again, this feature was motivated by performance concerns. Access to the 1.33 + * arguments property is not threadsafe, which is of particular concern in 1.34 + * server environments. Also, the compiler can generate better code for 1.35 + * functions because it can tell when the arguments are being accessed only by 1.36 + * name and avoid setting up the arguments object. 1.37 + * 1.38 + * Author: christine@netscape.com 1.39 + * Date: 11 August 1998 1.40 + */ 1.41 +var SECTION = "function-001.js"; 1.42 +var VERSION = "JS1_4"; 1.43 +var TITLE = "Accessing the arguments property of a function object"; 1.44 +var BUGNUMBER="324455"; 1.45 +startTest(); 1.46 +writeHeaderToLog( SECTION + " "+ TITLE); 1.47 + 1.48 +new TestCase( 1.49 + SECTION, 1.50 + "return function.arguments", 1.51 + "P", 1.52 + TestFunction_2("P", "A","S","S")[0] +""); 1.53 + 1.54 + 1.55 +new TestCase( 1.56 + SECTION, 1.57 + "return arguments", 1.58 + "P", 1.59 + TestFunction_1( "P", "A", "S", "S" )[0] +""); 1.60 + 1.61 +new TestCase( 1.62 + SECTION, 1.63 + "return arguments when function contains an arguments property", 1.64 + "PASS", 1.65 + TestFunction_3( "P", "A", "S", "S" ) +""); 1.66 + 1.67 +new TestCase( 1.68 + SECTION, 1.69 + "return function.arguments when function contains an arguments property", 1.70 + "[object Arguments]", 1.71 + TestFunction_4( "F", "A", "I", "L" ) +""); 1.72 + 1.73 +test(); 1.74 + 1.75 +function TestFunction_1( a, b, c, d, e ) { 1.76 + return arguments; 1.77 +} 1.78 + 1.79 +function TestFunction_2( a, b, c, d, e ) { 1.80 + return TestFunction_2.arguments; 1.81 +} 1.82 + 1.83 +function TestFunction_3( a, b, c, d, e ) { 1.84 + var arguments = "PASS"; 1.85 + return arguments; 1.86 +} 1.87 + 1.88 +function TestFunction_4( a, b, c, d, e ) { 1.89 + var arguments = "FAIL"; 1.90 + return TestFunction_4.arguments; 1.91 +} 1.92 +