initial import
[vuplus_webkit] / Source / JavaScriptCore / tests / mozilla / ecma_3 / Function / regress-85880.js
1 /*
2 * The contents of this file are subject to the Netscape Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/NPL/
6 *
7 * Software distributed under the License is distributed on an "AS
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 * implied. See the License for the specific language governing
10 * rights and limitations under the License.
11 *
12 * The Original Code is mozilla.org code.
13 *
14 * The Initial Developer of the Original Code is Netscape
15 * Communications Corporation.  Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation.
17 * All Rights Reserved.
18 *
19 * Contributor(s): pschwartau@netscape.com
20 * Date: 2001-06-14
21 *
22 * SUMMARY: Regression test for Bugzilla bug 85880
23 *
24 * Rhino interpreted mode was nulling out the arguments object of a
25 * function if it happened to call another function inside its body.
26 *
27 * See http://bugzilla.mozilla.org/show_bug.cgi?id=85880
28 *
29 */
30 //-------------------------------------------------------------------------------------------------
31 var UBound = 0;
32 var bug = 85880;
33 var summary = 'Arguments object of g(){f()} should not be null';
34 var cnNonNull = 'Arguments != null';
35 var cnNull = 'Arguments == null';
36 var cnRecurse = true;
37 var status = '';
38 var statusitems = [];
39 var actual = '';
40 var actualvalues = [];
41 var expect= '';
42 var expectedvalues = [];
43
44
45 function f1(x)
46 {
47 }
48
49
50 function f2()
51 {
52   return f2.arguments;
53 }
54 status = 'Section A of test';
55 actual = (f2() == null);
56 expect = false;
57 addThis();
58
59 status = 'Section B of test';
60 actual = (f2(0) == null);
61 expect = false;
62 addThis();
63
64
65 function f3()
66 {
67   f1();
68   return f3.arguments;
69 }
70 status = 'Section C of test';
71 actual = (f3() == null);
72 expect = false;
73 addThis();
74
75 status = 'Section D of test';
76 actual = (f3(0) == null);
77 expect = false;
78 addThis();
79
80
81 function f4()
82 {
83   f1();
84   f2();
85   f3();
86   return f4.arguments;
87 }
88 status = 'Section E of test';
89 actual = (f4() == null);
90 expect = false;
91 addThis();
92
93 status = 'Section F of test';
94 actual = (f4(0) == null);
95 expect = false;
96 addThis();
97
98
99 function f5()
100 {
101   if (cnRecurse)
102   {
103     cnRecurse = false;
104     f5();
105   }
106   return f5.arguments;
107 }
108 status = 'Section G of test';
109 actual = (f5() == null);
110 expect = false;
111 addThis();
112
113 status = 'Section H of test';
114 actual = (f5(0) == null);
115 expect = false;
116 addThis();
117
118
119
120 //-------------------------------------------------------------------------------------------------
121 test();
122 //-------------------------------------------------------------------------------------------------
123
124
125 function addThis()
126 {
127   statusitems[UBound] = status;
128   actualvalues[UBound] = isThisNull(actual);
129   expectedvalues[UBound] = isThisNull(expect);
130   UBound++;
131 }
132
133
134 function test()
135 {
136   enterFunc ('test');
137   printBugNumber (bug);
138   printStatus (summary);
139
140   for (var i = 0; i < UBound; i++)
141   {
142     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
143   }
144
145   exitFunc ('test');
146 }
147
148
149 function isThisNull(bool)
150 {
151   return bool? cnNull : cnNonNull
152 }