Debian Codegraph @

rhino/testsrc/tests/ecma_3/Function/regress-85880.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: 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 gTestfile = 'regress-85880.js';
19 var UBound = 0;
20 var BUGNUMBER = 85880;
21 var summary = 'Arguments object of g(){f()} should not be null';
22 var cnNonNull = 'Arguments != null';
23 var cnNull = 'Arguments == null';
24 var cnRecurse = true;
25 var status = '';
26 var statusitems = [];
27 var actual = '';
28 var actualvalues = [];
29 var expect= '';
30 var expectedvalues = [];
31
32
33 function f1(x)
34 {
35 }
36
37
38 function f2()
39 {
40 return f2.arguments;
41 }
42 status = 'Section A of test';
43 actual = (f2() == null);
44 expect = false;
45 addThis();
46
47 status = 'Section B of test';
48 actual = (f2(0) == null);
49 expect = false;
50 addThis();
51
52
53 function f3()
54 {
55 f1();
56 return f3.arguments;
57 }
58 status = 'Section C of test';
59 actual = (f3() == null);
60 expect = false;
61 addThis();
62
63 status = 'Section D of test';
64 actual = (f3(0) == null);
65 expect = false;
66 addThis();
67
68
69 function f4()
70 {
71 f1();
72 f2();
73 f3();
74 return f4.arguments;
75 }
76 status = 'Section E of test';
77 actual = (f4() == null);
78 expect = false;
79 addThis();
80
81 status = 'Section F of test';
82 actual = (f4(0) == null);
83 expect = false;
84 addThis();
85
86
87 function f5()
88 {
89 if (cnRecurse)
90 {
91 cnRecurse = false;
92 f5();
93 }
94 return f5.arguments;
95 }
96 status = 'Section G of test';
97 actual = (f5() == null);
98 expect = false;
99 addThis();
100
101 status = 'Section H of test';
102 actual = (f5(0) == null);
103 expect = false;
104 addThis();
105
106
107
108 //-------------------------------------------------------------------------------------------------
109 test();
110 //-------------------------------------------------------------------------------------------------
111
112
113 function addThis()
114 {
115 statusitems[UBound] = status;
116 actualvalues[UBound] = isThisNull(actual);
117 expectedvalues[UBound] = isThisNull(expect);
118 UBound++;
119 }
120
121
122 function test()
123 {
124 enterFunc ('test');
125 printBugNumber(BUGNUMBER);
126 printStatus (summary);
127
128 for (var i = 0; i < UBound; i++)
129 {
130 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
131 }
132
133 exitFunc ('test');
134 }
135
136
137 function isThisNull(bool)
138 {
139 return bool? cnNull : cnNonNull
140 }