Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / js / tests / js1_6 / Array / regress-304828.js
blobd3ab1f2a5b23396631838dc910201a480943e02a
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is JavaScript Engine testing utilities.
17 * The Initial Developer of the Original Code is
18 * Mozilla Foundation.
19 * Portions created by the Initial Developer are Copyright (C) 2005
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 var gTestfile = 'regress-304828.js';
39 //-----------------------------------------------------------------------------
40 var BUGNUMBER = 304828;
41 var summary = 'Array Generic Methods';
42 var actual = '';
43 var expect = '';
44 printBugNumber(BUGNUMBER);
45 printStatus (summary);
47 var value;
49 // use Array methods on a String
50 // join
51 value = '123';
52 expect = '1,2,3';
53 try
55 actual = Array.prototype.join.call(value);
57 catch(e)
59 actual = e + '';
61 reportCompare(expect, actual, summary + ': join');
63 // reverse
64 value = '123';
65 expect = '123';
66 try
68 actual = Array.prototype.reverse.call(value) + '';
70 catch(e)
72 actual = e + '';
74 reportCompare(expect, actual, summary + ': reverse');
76 // sort
77 value = 'cba';
78 expect = 'cba';
79 try
81 actual = Array.prototype.sort.call(value) + '';
83 catch(e)
85 actual = e + '';
87 reportCompare(expect, actual, summary + ': sort');
89 // push
90 value = 'abc';
91 expect = 6;
92 try
94 actual = Array.prototype.push.call(value, 'd', 'e', 'f');
96 catch(e)
98 actual = e + '';
100 reportCompare(expect, actual, summary + ': push');
101 reportCompare('abc', value, summary + ': push');
103 // pop
104 value = 'abc';
105 expect = 'c';
108 actual = Array.prototype.pop.call(value);
110 catch(e)
112 actual = e + '';
114 reportCompare(expect, actual, summary + ': pop');
115 reportCompare('abc', value, summary + ': pop');
117 // unshift
118 value = 'def';
119 expect = 6;
122 actual = Array.prototype.unshift.call(value, 'a', 'b', 'c');
124 catch(e)
126 actual = e + '';
128 reportCompare(expect, actual, summary + ': unshift');
129 reportCompare('def', value, summary + ': unshift');
131 // shift
132 value = 'abc';
133 expect = 'a';
136 actual = Array.prototype.shift.call(value);
138 catch(e)
140 actual = e + '';
142 reportCompare(expect, actual, summary + ': shift');
143 reportCompare('abc', value, summary + ': shift');
145 // splice
146 value = 'abc';
147 expect = 'b';
150 actual = Array.prototype.splice.call(value, 1, 1) + '';
152 catch(e)
154 actual = e + '';
156 reportCompare(expect, actual, summary + ': splice');
158 // concat
159 value = 'abc';
160 expect = 'abc,d,e,f';
163 actual = Array.prototype.concat.call(value, 'd', 'e', 'f') + '';
165 catch(e)
167 actual = e + '';
169 reportCompare(expect, actual, summary + ': concat');
171 // slice
172 value = 'abc';
173 expect = 'b';
176 actual = Array.prototype.slice.call(value, 1, 2) + '';
178 catch(e)
180 actual = e + '';
182 reportCompare(expect, actual, summary + ': slice');
184 // indexOf
185 value = 'abc';
186 expect = 1;
189 actual = Array.prototype.indexOf.call(value, 'b');
191 catch(e)
193 actual = e + '';
195 reportCompare(expect, actual, summary + ': indexOf');
197 // lastIndexOf
198 value = 'abcabc';
199 expect = 4;
202 actual = Array.prototype.lastIndexOf.call(value, 'b');
204 catch(e)
206 actual = e + '';
208 reportCompare(expect, actual, summary + ': lastIndexOf');
210 // forEach
211 value = 'abc';
212 expect = 'ABC';
213 actual = '';
216 Array.prototype.forEach.call(value,
217 function (v, index, array)
218 {actual += array[index].toUpperCase();});
220 catch(e)
222 actual = e + '';
224 reportCompare(expect, actual, summary + ': forEach');
226 // map
227 value = 'abc';
228 expect = 'A,B,C';
231 actual = Array.prototype.map.call(value,
232 function (v, index, array)
233 {return v.toUpperCase();}) + '';
235 catch(e)
237 actual = e + '';
239 reportCompare(expect, actual, summary + ': map');
241 // filter
242 value = '1234567890';
243 expect = '2,4,6,8,0';
246 actual = Array.prototype.filter.call(value,
247 function (v, index, array)
248 {return array[index] % 2 == 0;}) + '';
250 catch(e)
252 actual = e + '';
254 reportCompare(expect, actual, summary + ': filter');
256 // every
257 value = '1234567890';
258 expect = false;
261 actual = Array.prototype.every.call(value,
262 function (v, index, array)
263 {return array[index] % 2 == 0;});
265 catch(e)
267 actual = e + '';
269 reportCompare(expect, actual, summary + ': every');