| 1 |
/* -*- indent-tabs-mode: nil; js-indent-level: 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 |
* |
| 8 |
* Date: 26 June 2002 |
| 9 |
* SUMMARY: Testing array.join() when separator is a variable, not a literal |
| 10 |
* See http://bugzilla.mozilla.org/show_bug.cgi?id=154338 |
| 11 |
* |
| 12 |
*/ |
| 13 |
//----------------------------------------------------------------------------- |
| 14 |
var UBound = 0; |
| 15 |
var BUGNUMBER = 154338; |
| 16 |
var summary = 'Test array.join() when separator is a variable, not a literal'; |
| 17 |
var status = ''; |
| 18 |
var statusitems = []; |
| 19 |
var actual = ''; |
| 20 |
var actualvalues = []; |
| 21 |
var expect= ''; |
| 22 |
var expectedvalues = []; |
| 23 |
|
| 24 |
|
| 25 |
/* |
| 26 |
* Note that x === 'H' and y === 'ome'. |
| 27 |
* |
| 28 |
* Yet for some reason, using |x| or |y| as the separator |
| 29 |
* in arr.join() was causing out-of-memory errors, whereas |
| 30 |
* using the literals 'H', 'ome' was not - |
| 31 |
* |
| 32 |
*/ |
| 33 |
var x = 'Home'[0]; |
| 34 |
var y = ('Home'.split('H'))[1]; |
| 35 |
|
| 36 |
|
| 37 |
status = inSection(1); |
| 38 |
var arr = Array('a', 'b'); |
| 39 |
actual = arr.join('H'); |
| 40 |
expect = 'aHb'; |
| 41 |
addThis(); |
| 42 |
|
| 43 |
status = inSection(2); |
| 44 |
arr = Array('a', 'b'); |
| 45 |
actual = arr.join(x); |
| 46 |
expect = 'aHb'; |
| 47 |
addThis(); |
| 48 |
|
| 49 |
status = inSection(3); |
| 50 |
arr = Array('a', 'b'); |
| 51 |
actual = arr.join('ome'); |
| 52 |
expect = 'aomeb'; |
| 53 |
addThis(); |
| 54 |
|
| 55 |
status = inSection(4); |
| 56 |
arr = Array('a', 'b'); |
| 57 |
actual = arr.join(y); |
| 58 |
expect = 'aomeb'; |
| 59 |
addThis(); |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
//----------------------------------------------------------------------------- |
| 64 |
test(); |
| 65 |
//----------------------------------------------------------------------------- |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
function addThis() |
| 70 |
{ |
| 71 |
statusitems[UBound] = status; |
| 72 |
actualvalues[UBound] = actual; |
| 73 |
expectedvalues[UBound] = expect; |
| 74 |
UBound++; |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
function test() |
| 79 |
{ |
| 80 |
printBugNumber(BUGNUMBER); |
| 81 |
printStatus(summary); |
| 82 |
|
| 83 |
for (var i=0; i<UBound; i++) |
| 84 |
{ |
| 85 |
reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
| 86 |
} |
| 87 |
} |