|
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: 2001-06-14 |
|
8 * |
|
9 * SUMMARY: Regression test for Bugzilla bug 85880 |
|
10 * |
|
11 * Rhino interpreted mode was nulling out the arguments object of a |
|
12 * function if it happened to call another function inside its body. |
|
13 * |
|
14 * See http://bugzilla.mozilla.org/show_bug.cgi?id=85880 |
|
15 * |
|
16 */ |
|
17 //----------------------------------------------------------------------------- |
|
18 var UBound = 0; |
|
19 var BUGNUMBER = 85880; |
|
20 var summary = 'Arguments object of g(){f()} should not be null'; |
|
21 var cnNonNull = 'Arguments != null'; |
|
22 var cnNull = 'Arguments == null'; |
|
23 var cnRecurse = true; |
|
24 var status = ''; |
|
25 var statusitems = []; |
|
26 var actual = ''; |
|
27 var actualvalues = []; |
|
28 var expect= ''; |
|
29 var expectedvalues = []; |
|
30 |
|
31 |
|
32 function f1(x) |
|
33 { |
|
34 } |
|
35 |
|
36 |
|
37 function f2() |
|
38 { |
|
39 return f2.arguments; |
|
40 } |
|
41 status = 'Section A of test'; |
|
42 actual = (f2() == null); |
|
43 expect = false; |
|
44 addThis(); |
|
45 |
|
46 status = 'Section B of test'; |
|
47 actual = (f2(0) == null); |
|
48 expect = false; |
|
49 addThis(); |
|
50 |
|
51 |
|
52 function f3() |
|
53 { |
|
54 f1(); |
|
55 return f3.arguments; |
|
56 } |
|
57 status = 'Section C of test'; |
|
58 actual = (f3() == null); |
|
59 expect = false; |
|
60 addThis(); |
|
61 |
|
62 status = 'Section D of test'; |
|
63 actual = (f3(0) == null); |
|
64 expect = false; |
|
65 addThis(); |
|
66 |
|
67 |
|
68 function f4() |
|
69 { |
|
70 f1(); |
|
71 f2(); |
|
72 f3(); |
|
73 return f4.arguments; |
|
74 } |
|
75 status = 'Section E of test'; |
|
76 actual = (f4() == null); |
|
77 expect = false; |
|
78 addThis(); |
|
79 |
|
80 status = 'Section F of test'; |
|
81 actual = (f4(0) == null); |
|
82 expect = false; |
|
83 addThis(); |
|
84 |
|
85 |
|
86 function f5() |
|
87 { |
|
88 if (cnRecurse) |
|
89 { |
|
90 cnRecurse = false; |
|
91 f5(); |
|
92 } |
|
93 return f5.arguments; |
|
94 } |
|
95 status = 'Section G of test'; |
|
96 actual = (f5() == null); |
|
97 expect = false; |
|
98 addThis(); |
|
99 |
|
100 status = 'Section H of test'; |
|
101 actual = (f5(0) == null); |
|
102 expect = false; |
|
103 addThis(); |
|
104 |
|
105 |
|
106 |
|
107 //------------------------------------------------------------------------------------------------- |
|
108 test(); |
|
109 //------------------------------------------------------------------------------------------------- |
|
110 |
|
111 |
|
112 function addThis() |
|
113 { |
|
114 statusitems[UBound] = status; |
|
115 actualvalues[UBound] = isThisNull(actual); |
|
116 expectedvalues[UBound] = isThisNull(expect); |
|
117 UBound++; |
|
118 } |
|
119 |
|
120 |
|
121 function test() |
|
122 { |
|
123 enterFunc ('test'); |
|
124 printBugNumber(BUGNUMBER); |
|
125 printStatus (summary); |
|
126 |
|
127 for (var i = 0; i < UBound; i++) |
|
128 { |
|
129 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
|
130 } |
|
131 |
|
132 exitFunc ('test'); |
|
133 } |
|
134 |
|
135 |
|
136 function isThisNull(bool) |
|
137 { |
|
138 return bool? cnNull : cnNonNull |
|
139 } |