Debian Codegraph @

rhino/testsrc/tests/ecma_3/extensions/10.1.3-2.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 *
8 * Date: 11 Feb 2002
9 * SUMMARY: Testing functions having duplicate formal parameter names
10 *
11 * SpiderMonkey was crashing on each case below if the parameters had
12 * the same name. But duplicate parameter names are permitted by ECMA;
13 * see ECMA-262 3rd Edition Final Section 10.1.3
14 *
15 * NOTE: Rhino does not have toSource() and uneval(); they are non-ECMA
16 * extensions to the language. So we include a test for them at the beginning -
17 */
18 //-----------------------------------------------------------------------------
19 var gTestfile = '10.1.3-2.js';
20 var UBound = 0;
21 var BUGNUMBER = '(none)';
22 var summary = 'Testing functions having duplicate formal parameter names';
23 var status = '';
24 var statusitems = [];
25 var actual = '';
26 var actualvalues = [];
27 var expect= '';
28 var expectedvalues = [];
29 var OBJ = new Object();
30 var OBJ_TYPE = OBJ.toString();
31
32 /*
33 * Exit if the implementation doesn't support toSource() or uneval(),
34 * since these are non-ECMA extensions to the language -
35 */
36 try
37 {
38 if (!OBJ.toSource || !uneval(OBJ))
39 quit();
40 }
41 catch(e)
42 {
43 quit();
44 }
45
46
47 /*
48 * OK, now begin the test. Just checking that we don't crash on these -
49 */
50 function f1(x,x,x,x)
51 {
52 var ret = eval(arguments.toSource());
53 return ret.toString();
54 }
55 status = inSection(1);
56 actual = f1(1,2,3,4);
57 expect = OBJ_TYPE;
58 addThis();
59
60
61 /*
62 * Same thing, but preface |arguments| with the function name
63 */
64 function f2(x,x,x,x)
65 {
66 var ret = eval(f2.arguments.toSource());
67 return ret.toString();
68 }
69 status = inSection(2);
70 actual = f2(1,2,3,4);
71 expect = OBJ_TYPE;
72 addThis();
73
74
75 function f3(x,x,x,x)
76 {
77 var ret = eval(uneval(arguments));
78 return ret.toString();
79 }
80 status = inSection(3);
81 actual = f3(1,2,3,4);
82 expect = OBJ_TYPE;
83 addThis();
84
85
86 /*
87 * Same thing, but preface |arguments| with the function name
88 */
89 function f4(x,x,x,x)
90 {
91 var ret = eval(uneval(f4.arguments));
92 return ret.toString();
93 }
94 status = inSection(4);
95 actual = f4(1,2,3,4);
96 expect = OBJ_TYPE;
97 addThis();
98
99
100
101
102 //-----------------------------------------------------------------------------
103 test();
104 //-----------------------------------------------------------------------------
105
106
107
108 function addThis()
109 {
110 statusitems[UBound] = status;
111 actualvalues[UBound] = actual;
112 expectedvalues[UBound] = expect;
113 UBound++;
114 }
115
116
117 function test()
118 {
119 enterFunc('test');
120 printBugNumber(BUGNUMBER);
121 printStatus(summary);
122
123 for (var i=0; i<UBound; i++)
124 {
125 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
126 }
127
128 exitFunc ('test');
129 }