Debian Codegraph @

rhino/testsrc/tests/ecma_3/Function/regress-94506.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 /*
7 * Date: 08 August 2001
8 *
9 * SUMMARY: When we invoke a function, the arguments object should take
10 * a back seat to any local identifier named "arguments".
11 *
12 * See http://bugzilla.mozilla.org/show_bug.cgi?id=94506
13 */
14 //-----------------------------------------------------------------------------
15 var gTestfile = 'regress-94506.js';
16 var UBound = 0;
17 var BUGNUMBER = 94506;
18 var summary = 'Testing functions employing identifiers named "arguments"';
19 var status = '';
20 var statusitems = [];
21 var actual = '';
22 var actualvalues = [];
23 var expect= '';
24 var expectedvalues = [];
25 var TYPE_OBJECT = typeof new Object();
26 var arguments = 5555;
27
28
29 // use a parameter named "arguments"
30 function F1(arguments)
31 {
32 return arguments;
33 }
34
35
36 // use a local variable named "arguments"
37 function F2()
38 {
39 var arguments = 55;
40 return arguments;
41 }
42
43
44 // same thing in a different order. CHANGES THE RESULT!
45 function F3()
46 {
47 return arguments;
48 var arguments = 555;
49 }
50
51
52 // use the global variable above named "arguments"
53 function F4()
54 {
55 return arguments;
56 }
57
58
59
60 /*
61 * In Sections 1 and 2, expect the local identifier, not the arguments object.
62 * In Sections 3 and 4, expect the arguments object, not the the identifier.
63 */
64
65 status = 'Section 1 of test';
66 actual = F1(5);
67 expect = 5;
68 addThis();
69
70
71 status = 'Section 2 of test';
72 actual = F2();
73 expect = 55;
74 addThis();
75
76
77 status = 'Section 3 of test';
78 actual = typeof F3();
79 expect = TYPE_OBJECT;
80 addThis();
81
82
83 status = 'Section 4 of test';
84 actual = typeof F4();
85 expect = TYPE_OBJECT;
86 addThis();
87
88
89 // Let's try calling F1 without providing a parameter -
90 status = 'Section 5 of test';
91 actual = F1();
92 expect = undefined;
93 addThis();
94
95
96 // Let's try calling F1 with too many parameters -
97 status = 'Section 6 of test';
98 actual = F1(3,33,333);
99 expect = 3;
100 addThis();
101
102
103
104 //-----------------------------------------------------------------------------
105 test();
106 //-----------------------------------------------------------------------------
107
108
109 function addThis()
110 {
111 statusitems[UBound] = status;
112 actualvalues[UBound] = actual;
113 expectedvalues[UBound] = expect;
114 UBound++;
115 }
116
117
118 function test()
119 {
120 enterFunc ('test');
121 printBugNumber(BUGNUMBER);
122 printStatus (summary);
123
124 for (var i = 0; i < UBound; i++)
125 {
126 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
127 }
128
129 exitFunc ('test');
130 }