initial import
[vuplus_webkit] / Source / JavaScriptCore / tests / mozilla / js1_5 / Array / regress-107138.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): morse@netscape.com, pschwartau@netscape.com
20 * Date: 29 October 2001
21 *
22 * SUMMARY: Regression test for bug 107138
23 * See http://bugzilla.mozilla.org/show_bug.cgi?id=107138
24 *
25 * The bug: arr['1'] == undefined instead of arr['1'] == 'one'.
26 * The bug was intermittent and did not always occur...
27 *
28 * The cnSTRESS constant defines how many times to repeat this test.
29 */
30 //-----------------------------------------------------------------------------
31 var UBound = 0;
32 var cnSTRESS = 10;
33 var cnDASH = '-';
34 var bug = 107138;
35 var summary = 'Regression test for bug 107138';
36 var status = '';
37 var statusitems = [];
38 var actual = '';
39 var actualvalues = [];
40 var expect= '';
41 var expectedvalues = [];
42
43
44 var arr = ['zero', 'one', 'two', 'three', 'four', 'five',
45            'six', 'seven', 'eight', 'nine', 'ten'];
46
47
48 // This bug was intermittent. Stress-test it.
49 for (var j=0; j<cnSTRESS; j++)
50 {
51   status = inSection(j + cnDASH + 1);
52   actual = arr[0];
53   expect = 'zero';
54   addThis();
55
56   status = inSection(j + cnDASH + 2);
57   actual = arr['0'];
58   expect = 'zero';
59   addThis();
60
61   status = inSection(j + cnDASH + 3);
62   actual = arr[1];
63   expect = 'one';
64   addThis();
65
66   status = inSection(j + cnDASH + 4);
67   actual = arr['1'];
68   expect = 'one';
69   addThis();
70
71   status = inSection(j + cnDASH + 5);
72   actual = arr[2];
73   expect = 'two';
74   addThis();
75
76   status = inSection(j + cnDASH + 6);
77   actual = arr['2'];
78   expect = 'two';
79   addThis();
80
81   status = inSection(j + cnDASH + 7);
82   actual = arr[3];
83   expect = 'three';
84   addThis();
85
86   status = inSection(j + cnDASH + 8);
87   actual = arr['3'];
88   expect = 'three';
89   addThis();
90
91   status = inSection(j + cnDASH + 9);
92   actual = arr[4];
93   expect = 'four';
94   addThis();
95
96   status = inSection(j + cnDASH + 10);
97   actual = arr['4'];
98   expect = 'four';
99   addThis();
100
101   status = inSection(j + cnDASH + 11);
102   actual = arr[5];
103   expect = 'five';
104   addThis();
105
106   status = inSection(j + cnDASH + 12);
107   actual = arr['5'];
108   expect = 'five';
109   addThis();
110
111   status = inSection(j + cnDASH + 13);
112   actual = arr[6];
113   expect = 'six';
114   addThis();
115
116   status = inSection(j + cnDASH + 14);
117   actual = arr['6'];
118   expect = 'six';
119   addThis();
120
121   status = inSection(j + cnDASH + 15);
122   actual = arr[7];
123   expect = 'seven';
124   addThis();
125
126   status = inSection(j + cnDASH + 16);
127   actual = arr['7'];
128   expect = 'seven';
129   addThis();
130
131   status = inSection(j + cnDASH + 17);
132   actual = arr[8];
133   expect = 'eight';
134   addThis();
135
136   status = inSection(j + cnDASH + 18);
137   actual = arr['8'];
138   expect = 'eight';
139   addThis();
140
141   status = inSection(j + cnDASH + 19);
142   actual = arr[9];
143   expect = 'nine';
144   addThis();
145
146   status = inSection(j + cnDASH + 20);
147   actual = arr['9'];
148   expect = 'nine';
149   addThis();
150
151   status = inSection(j + cnDASH + 21);
152   actual = arr[10];
153   expect = 'ten';
154   addThis();
155
156   status = inSection(j + cnDASH + 22);
157   actual = arr['10'];
158   expect = 'ten';
159   addThis();
160 }
161
162
163 //-----------------------------------------------------------------------------
164 test();
165 //-----------------------------------------------------------------------------
166
167
168
169 function addThis()
170 {
171   statusitems[UBound] = status;
172   actualvalues[UBound] = actual;
173   expectedvalues[UBound] = expect;
174   UBound++;
175 }
176
177
178 function test()
179 {
180   enterFunc ('test');
181   printBugNumber (bug);
182   printStatus (summary);
183
184   for (var i=0; i<UBound; i++)
185   {
186     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
187   }
188
189   exitFunc ('test');
190 }