Debian Codegraph @

rhino/testsrc/tests/js1_4/Functions/function-001.js

raw symbols SCIP
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 gTestfile = 'function-001.js';
7
8 /**
9 * File Name: function-001.js
10 * Description:
11 *
12 * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=324455
13 *
14 * Earlier versions of JavaScript supported access to the arguments property
15 * of the function object. This property held the arguments to the function.
16 * function f() {
17 * return f.arguments[0]; // deprecated
18 * }
19 * var x = f(3); // x will be 3
20 *
21 * This feature is not a part of the final ECMA standard. Instead, scripts
22 * should simply use just "arguments":
23 *
24 * function f() {
25 * return arguments[0]; // okay
26 * }
27 *
28 * var x = f(3); // x will be 3
29 *
30 * Again, this feature was motivated by performance concerns. Access to the
31 * arguments property is not threadsafe, which is of particular concern in
32 * server environments. Also, the compiler can generate better code for
33 * functions because it can tell when the arguments are being accessed only by
34 * name and avoid setting up the arguments object.
35 *
36 * Author: [email protected]
37 * Date: 11 August 1998
38 */
39 var SECTION = "function-001.js";
40 var VERSION = "JS1_4";
41 var TITLE = "Accessing the arguments property of a function object";
42 var BUGNUMBER="324455";
43 startTest();
44 writeHeaderToLog( SECTION + " "+ TITLE);
45
46 new TestCase(
47 SECTION,
48 "return function.arguments",
49 "P",
50 TestFunction_2("P", "A","S","S")[0] +"");
51
52
53 new TestCase(
54 SECTION,
55 "return arguments",
56 "P",
57 TestFunction_1( "P", "A", "S", "S" )[0] +"");
58
59 new TestCase(
60 SECTION,
61 "return arguments when function contains an arguments property",
62 "PASS",
63 TestFunction_3( "P", "A", "S", "S" ) +"");
64
65 new TestCase(
66 SECTION,
67 "return function.arguments when function contains an arguments property",
68 "PASS",
69 TestFunction_4( "F", "A", "I", "L" ) +"");
70
71 test();
72
73 function TestFunction_1( a, b, c, d, e ) {
74 return arguments;
75 }
76
77 function TestFunction_2( a, b, c, d, e ) {
78 return TestFunction_2.arguments;
79 }
80
81 function TestFunction_3( a, b, c, d, e ) {
82 var arguments = "PASS";
83 return arguments;
84 }
85
86 function TestFunction_4( a, b, c, d, e ) {
87 var arguments = "PASS";
88 return TestFunction_4.arguments;
89 }
90