| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
var gTestfile = 'regress-304828.js'; |
| 7 |
|
| 8 |
var BUGNUMBER = 304828; |
| 9 |
var summary = 'Array Generic Methods'; |
| 10 |
var actual = ''; |
| 11 |
var expect = ''; |
| 12 |
printBugNumber(BUGNUMBER); |
| 13 |
printStatus (summary); |
| 14 |
|
| 15 |
var value; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
value = '123'; |
| 20 |
expect = '1,2,3'; |
| 21 |
try |
| 22 |
{ |
| 23 |
actual = Array.prototype.join.call(value); |
| 24 |
} |
| 25 |
catch(e) |
| 26 |
{ |
| 27 |
actual = e + ''; |
| 28 |
} |
| 29 |
reportCompare(expect, actual, summary + ': join'); |
| 30 |
|
| 31 |
|
| 32 |
value = '123'; |
| 33 |
expect = '123'; |
| 34 |
try |
| 35 |
{ |
| 36 |
actual = Array.prototype.reverse.call(value) + ''; |
| 37 |
} |
| 38 |
catch(e) |
| 39 |
{ |
| 40 |
actual = e + ''; |
| 41 |
} |
| 42 |
reportCompare(expect, actual, summary + ': reverse'); |
| 43 |
|
| 44 |
|
| 45 |
value = 'cba'; |
| 46 |
expect = 'cba'; |
| 47 |
try |
| 48 |
{ |
| 49 |
actual = Array.prototype.sort.call(value) + ''; |
| 50 |
} |
| 51 |
catch(e) |
| 52 |
{ |
| 53 |
actual = e + ''; |
| 54 |
} |
| 55 |
reportCompare(expect, actual, summary + ': sort'); |
| 56 |
|
| 57 |
|
| 58 |
value = 'abc'; |
| 59 |
expect = 6; |
| 60 |
try |
| 61 |
{ |
| 62 |
actual = Array.prototype.push.call(value, 'd', 'e', 'f'); |
| 63 |
} |
| 64 |
catch(e) |
| 65 |
{ |
| 66 |
actual = e + ''; |
| 67 |
} |
| 68 |
reportCompare(expect, actual, summary + ': push'); |
| 69 |
reportCompare('abc', value, summary + ': push'); |
| 70 |
|
| 71 |
|
| 72 |
value = 'abc'; |
| 73 |
expect = 'c'; |
| 74 |
try |
| 75 |
{ |
| 76 |
actual = Array.prototype.pop.call(value); |
| 77 |
} |
| 78 |
catch(e) |
| 79 |
{ |
| 80 |
actual = e + ''; |
| 81 |
} |
| 82 |
reportCompare(expect, actual, summary + ': pop'); |
| 83 |
reportCompare('abc', value, summary + ': pop'); |
| 84 |
|
| 85 |
|
| 86 |
value = 'def'; |
| 87 |
expect = 6; |
| 88 |
try |
| 89 |
{ |
| 90 |
actual = Array.prototype.unshift.call(value, 'a', 'b', 'c'); |
| 91 |
} |
| 92 |
catch(e) |
| 93 |
{ |
| 94 |
actual = e + ''; |
| 95 |
} |
| 96 |
reportCompare(expect, actual, summary + ': unshift'); |
| 97 |
reportCompare('def', value, summary + ': unshift'); |
| 98 |
|
| 99 |
|
| 100 |
value = 'abc'; |
| 101 |
expect = 'a'; |
| 102 |
try |
| 103 |
{ |
| 104 |
actual = Array.prototype.shift.call(value); |
| 105 |
} |
| 106 |
catch(e) |
| 107 |
{ |
| 108 |
actual = e + ''; |
| 109 |
} |
| 110 |
reportCompare(expect, actual, summary + ': shift'); |
| 111 |
reportCompare('abc', value, summary + ': shift'); |
| 112 |
|
| 113 |
|
| 114 |
value = 'abc'; |
| 115 |
expect = 'b'; |
| 116 |
try |
| 117 |
{ |
| 118 |
actual = Array.prototype.splice.call(value, 1, 1) + ''; |
| 119 |
} |
| 120 |
catch(e) |
| 121 |
{ |
| 122 |
actual = e + ''; |
| 123 |
} |
| 124 |
reportCompare(expect, actual, summary + ': splice'); |
| 125 |
|
| 126 |
|
| 127 |
value = 'abc'; |
| 128 |
expect = 'abc,d,e,f'; |
| 129 |
try |
| 130 |
{ |
| 131 |
actual = Array.prototype.concat.call(value, 'd', 'e', 'f') + ''; |
| 132 |
} |
| 133 |
catch(e) |
| 134 |
{ |
| 135 |
actual = e + ''; |
| 136 |
} |
| 137 |
reportCompare(expect, actual, summary + ': concat'); |
| 138 |
|
| 139 |
|
| 140 |
value = 'abc'; |
| 141 |
expect = 'b'; |
| 142 |
try |
| 143 |
{ |
| 144 |
actual = Array.prototype.slice.call(value, 1, 2) + ''; |
| 145 |
} |
| 146 |
catch(e) |
| 147 |
{ |
| 148 |
actual = e + ''; |
| 149 |
} |
| 150 |
reportCompare(expect, actual, summary + ': slice'); |
| 151 |
|
| 152 |
|
| 153 |
value = 'abc'; |
| 154 |
expect = 1; |
| 155 |
try |
| 156 |
{ |
| 157 |
actual = Array.prototype.indexOf.call(value, 'b'); |
| 158 |
} |
| 159 |
catch(e) |
| 160 |
{ |
| 161 |
actual = e + ''; |
| 162 |
} |
| 163 |
reportCompare(expect, actual, summary + ': indexOf'); |
| 164 |
|
| 165 |
|
| 166 |
value = 'abcabc'; |
| 167 |
expect = 4; |
| 168 |
try |
| 169 |
{ |
| 170 |
actual = Array.prototype.lastIndexOf.call(value, 'b'); |
| 171 |
} |
| 172 |
catch(e) |
| 173 |
{ |
| 174 |
actual = e + ''; |
| 175 |
} |
| 176 |
reportCompare(expect, actual, summary + ': lastIndexOf'); |
| 177 |
|
| 178 |
|
| 179 |
value = 'abc'; |
| 180 |
expect = 'ABC'; |
| 181 |
actual = ''; |
| 182 |
try |
| 183 |
{ |
| 184 |
Array.prototype.forEach.call(value, |
| 185 |
function (v, index, array) |
| 186 |
{actual += array[index].toUpperCase();}); |
| 187 |
} |
| 188 |
catch(e) |
| 189 |
{ |
| 190 |
actual = e + ''; |
| 191 |
} |
| 192 |
reportCompare(expect, actual, summary + ': forEach'); |
| 193 |
|
| 194 |
|
| 195 |
value = 'abc'; |
| 196 |
expect = 'A,B,C'; |
| 197 |
try |
| 198 |
{ |
| 199 |
actual = Array.prototype.map.call(value, |
| 200 |
function (v, index, array) |
| 201 |
{return v.toUpperCase();}) + ''; |
| 202 |
} |
| 203 |
catch(e) |
| 204 |
{ |
| 205 |
actual = e + ''; |
| 206 |
} |
| 207 |
reportCompare(expect, actual, summary + ': map'); |
| 208 |
|
| 209 |
|
| 210 |
value = '1234567890'; |
| 211 |
expect = '2,4,6,8,0'; |
| 212 |
try |
| 213 |
{ |
| 214 |
actual = Array.prototype.filter.call(value, |
| 215 |
function (v, index, array) |
| 216 |
{return array[index] % 2 == 0;}) + ''; |
| 217 |
} |
| 218 |
catch(e) |
| 219 |
{ |
| 220 |
actual = e + ''; |
| 221 |
} |
| 222 |
reportCompare(expect, actual, summary + ': filter'); |
| 223 |
|
| 224 |
|
| 225 |
value = '1234567890'; |
| 226 |
expect = false; |
| 227 |
try |
| 228 |
{ |
| 229 |
actual = Array.prototype.every.call(value, |
| 230 |
function (v, index, array) |
| 231 |
{return array[index] % 2 == 0;}); |
| 232 |
} |
| 233 |
catch(e) |
| 234 |
{ |
| 235 |
actual = e + ''; |
| 236 |
} |
| 237 |
reportCompare(expect, actual, summary + ': every'); |
| 238 |
|
| 239 |
|
| 240 |
|