| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
var gTestfile = 'regress-179524.js'; |
| 22 |
var UBound = 0; |
| 23 |
var BUGNUMBER = 179524; |
| 24 |
var summary = "Don't crash on extraneous arguments to str.match(), etc."; |
| 25 |
var status = ''; |
| 26 |
var statusitems = []; |
| 27 |
var actual = ''; |
| 28 |
var actualvalues = []; |
| 29 |
var expect= ''; |
| 30 |
var expectedvalues = []; |
| 31 |
|
| 32 |
|
| 33 |
str = 'ABC abc'; |
| 34 |
var re = /z/ig; |
| 35 |
|
| 36 |
status = inSection(1); |
| 37 |
actual = str.match(re); |
| 38 |
expect = null; |
| 39 |
addThis(); |
| 40 |
|
| 41 |
status = inSection(2); |
| 42 |
actual = str.match(re, 'i'); |
| 43 |
expect = null; |
| 44 |
addThis(); |
| 45 |
|
| 46 |
status = inSection(3); |
| 47 |
actual = str.match(re, 'g', ''); |
| 48 |
expect = null; |
| 49 |
addThis(); |
| 50 |
|
| 51 |
status = inSection(4); |
| 52 |
actual = str.match(re, 'z', new Object(), new Date()); |
| 53 |
expect = null; |
| 54 |
addThis(); |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
status = inSection(5); |
| 61 |
actual = str.search(re); |
| 62 |
expect = -1; |
| 63 |
addThis(); |
| 64 |
|
| 65 |
status = inSection(6); |
| 66 |
actual = str.search(re, 'i'); |
| 67 |
expect = -1; |
| 68 |
addThis(); |
| 69 |
|
| 70 |
status = inSection(7); |
| 71 |
actual = str.search(re, 'g', ''); |
| 72 |
expect = -1; |
| 73 |
addThis(); |
| 74 |
|
| 75 |
status = inSection(8); |
| 76 |
actual = str.search(re, 'z', new Object(), new Date()); |
| 77 |
expect = -1; |
| 78 |
addThis(); |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
status = inSection(9); |
| 85 |
actual = str.replace(re, 'Z'); |
| 86 |
expect = str; |
| 87 |
addThis(); |
| 88 |
|
| 89 |
status = inSection(10); |
| 90 |
actual = str.replace(re, 'Z', 'i'); |
| 91 |
expect = str; |
| 92 |
addThis(); |
| 93 |
|
| 94 |
status = inSection(11); |
| 95 |
actual = str.replace(re, 'Z', 'g', ''); |
| 96 |
expect = str; |
| 97 |
addThis(); |
| 98 |
|
| 99 |
status = inSection(12); |
| 100 |
actual = str.replace(re, 'Z', 'z', new Object(), new Date()); |
| 101 |
expect = str; |
| 102 |
addThis(); |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
status = inSection(13); |
| 115 |
actual = str.match('a').toString(); |
| 116 |
expect = str.match(/a/).toString(); |
| 117 |
addThis(); |
| 118 |
|
| 119 |
status = inSection(14); |
| 120 |
actual = str.match('a', 'i').toString(); |
| 121 |
expect = str.match(/a/i).toString(); |
| 122 |
addThis(); |
| 123 |
|
| 124 |
status = inSection(15); |
| 125 |
actual = str.match('a', 'ig').toString(); |
| 126 |
expect = str.match(/a/ig).toString(); |
| 127 |
addThis(); |
| 128 |
|
| 129 |
status = inSection(16); |
| 130 |
actual = str.match('\\s', 'm').toString(); |
| 131 |
expect = str.match(/\s/m).toString(); |
| 132 |
addThis(); |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
status = inSection(17); |
| 139 |
actual = str.match('a', 'i', 'g').toString(); |
| 140 |
expect = str.match(/a/i).toString(); |
| 141 |
addThis(); |
| 142 |
|
| 143 |
status = inSection(18); |
| 144 |
actual = str.match('a', 'ig', new Object()).toString(); |
| 145 |
expect = str.match(/a/ig).toString(); |
| 146 |
addThis(); |
| 147 |
|
| 148 |
status = inSection(19); |
| 149 |
actual = str.match('\\s', 'm', 999).toString(); |
| 150 |
expect = str.match(/\s/m).toString(); |
| 151 |
addThis(); |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
status = inSection(20); |
| 158 |
try |
| 159 |
{ |
| 160 |
actual = str.match('a', 'z').toString(); |
| 161 |
expect = 'SHOULD HAVE FALLEN INTO CATCH-BLOCK!'; |
| 162 |
addThis(); |
| 163 |
} |
| 164 |
catch (e) |
| 165 |
{ |
| 166 |
actual = e instanceof SyntaxError; |
| 167 |
expect = true; |
| 168 |
addThis(); |
| 169 |
} |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
status = inSection(21); |
| 180 |
actual = str.search('a'); |
| 181 |
expect = str.search(/a/); |
| 182 |
addThis(); |
| 183 |
|
| 184 |
status = inSection(22); |
| 185 |
actual = str.search('a', 'i'); |
| 186 |
expect = str.search(/a/i); |
| 187 |
addThis(); |
| 188 |
|
| 189 |
status = inSection(23); |
| 190 |
actual = str.search('a', 'ig'); |
| 191 |
expect = str.search(/a/ig); |
| 192 |
addThis(); |
| 193 |
|
| 194 |
status = inSection(24); |
| 195 |
actual = str.search('\\s', 'm'); |
| 196 |
expect = str.search(/\s/m); |
| 197 |
addThis(); |
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
status = inSection(25); |
| 204 |
actual = str.search('a', 'i', 'g'); |
| 205 |
expect = str.search(/a/i); |
| 206 |
addThis(); |
| 207 |
|
| 208 |
status = inSection(26); |
| 209 |
actual = str.search('a', 'ig', new Object()); |
| 210 |
expect = str.search(/a/ig); |
| 211 |
addThis(); |
| 212 |
|
| 213 |
status = inSection(27); |
| 214 |
actual = str.search('\\s', 'm', 999); |
| 215 |
expect = str.search(/\s/m); |
| 216 |
addThis(); |
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
status = inSection(28); |
| 223 |
try |
| 224 |
{ |
| 225 |
actual = str.search('a', 'z'); |
| 226 |
expect = 'SHOULD HAVE FALLEN INTO CATCH-BLOCK!'; |
| 227 |
addThis(); |
| 228 |
} |
| 229 |
catch (e) |
| 230 |
{ |
| 231 |
actual = e instanceof SyntaxError; |
| 232 |
expect = true; |
| 233 |
addThis(); |
| 234 |
} |
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
status = inSection(29); |
| 247 |
actual = str.replace('a', 'Z'); |
| 248 |
expect = str.replace(/a/, 'Z'); |
| 249 |
addThis(); |
| 250 |
|
| 251 |
status = inSection(30); |
| 252 |
actual = str.replace('a', 'Z', 'i'); |
| 253 |
expect = str.replace(/a/i, 'Z'); |
| 254 |
addThis(); |
| 255 |
|
| 256 |
status = inSection(31); |
| 257 |
actual = str.replace('a', 'Z', 'ig'); |
| 258 |
expect = str.replace(/a/ig, 'Z'); |
| 259 |
addThis(); |
| 260 |
|
| 261 |
status = inSection(32); |
| 262 |
actual = str.replace('\\s', 'Z', 'm'); |
| 263 |
actual = str.replace(' ', 'Z', 'm'); |
| 264 |
expect = str.replace(/\s/m, 'Z'); |
| 265 |
addThis(); |
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
status = inSection(33); |
| 272 |
actual = str.replace('a', 'Z', 'i', 'g'); |
| 273 |
expect = str.replace(/a/i, 'Z'); |
| 274 |
addThis(); |
| 275 |
|
| 276 |
status = inSection(34); |
| 277 |
actual = str.replace('a', 'Z', 'ig', new Object()); |
| 278 |
expect = str.replace(/a/ig, 'Z'); |
| 279 |
addThis(); |
| 280 |
|
| 281 |
status = inSection(35); |
| 282 |
actual = str.replace('\\s', 'Z', 'm', 999); |
| 283 |
actual = str.replace(' ', 'Z', 'm', 999); |
| 284 |
expect = str.replace(/\s/m, 'Z'); |
| 285 |
addThis(); |
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
status = inSection(36); |
| 292 |
try |
| 293 |
{ |
| 294 |
actual = str.replace('a', 'Z', 'z'); |
| 295 |
expect = 'SHOULD HAVE FALLEN INTO CATCH-BLOCK!'; |
| 296 |
addThis(); |
| 297 |
} |
| 298 |
catch (e) |
| 299 |
{ |
| 300 |
actual = e instanceof SyntaxError; |
| 301 |
expect = true; |
| 302 |
addThis(); |
| 303 |
} |
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
test(); |
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
function addThis() |
| 315 |
{ |
| 316 |
statusitems[UBound] = status; |
| 317 |
actualvalues[UBound] = actual; |
| 318 |
expectedvalues[UBound] = expect; |
| 319 |
UBound++; |
| 320 |
} |
| 321 |
|
| 322 |
|
| 323 |
function test() |
| 324 |
{ |
| 325 |
enterFunc('test'); |
| 326 |
printBugNumber(BUGNUMBER); |
| 327 |
printStatus(summary); |
| 328 |
|
| 329 |
for (var i=0; i<UBound; i++) |
| 330 |
{ |
| 331 |
reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
| 332 |
} |
| 333 |
|
| 334 |
exitFunc ('test'); |
| 335 |
} |