| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
var gTestfile = 'regress-364104.js'; |
| 7 |
|
| 8 |
var BUGNUMBER = "364104"; |
| 9 |
var summary = "Array.prototype.indexOf, Array.prototype.lastIndexOf issues " + |
| 10 |
"with the optional second fromIndex argument"; |
| 11 |
var actual, expect; |
| 12 |
|
| 13 |
printBugNumber(BUGNUMBER); |
| 14 |
printStatus(summary); |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
var failed = false; |
| 21 |
|
| 22 |
try |
| 23 |
{ |
| 24 |
|
| 25 |
if ([2].indexOf(2) != 0) |
| 26 |
throw "indexOf: not finding 2!?"; |
| 27 |
if ([2].indexOf(2, 0) != 0) |
| 28 |
throw "indexOf: not interpreting explicit second argument 0!"; |
| 29 |
if ([2].indexOf(2, 1) != -1) |
| 30 |
throw "indexOf: ignoring second argument with value equal to array length!"; |
| 31 |
if ([2].indexOf(2, 2) != -1) |
| 32 |
throw "indexOf: ignoring second argument greater than array length!"; |
| 33 |
if ([2].indexOf(2, 17) != -1) |
| 34 |
throw "indexOf: ignoring large second argument!"; |
| 35 |
if ([2].indexOf(2, -5) != 0) |
| 36 |
throw "indexOf: calculated fromIndex < 0, should search entire array!"; |
| 37 |
if ([2, 3].indexOf(2, -1) != -1) |
| 38 |
throw "indexOf: not handling index == (-1 + 2), element 2 correctly!"; |
| 39 |
if ([2, 3].indexOf(3, -1) != 1) |
| 40 |
throw "indexOf: not handling index == (-1 + 2), element 3 correctly!"; |
| 41 |
|
| 42 |
|
| 43 |
if ([2].lastIndexOf(2) != 0) |
| 44 |
throw "lastIndexOf: not finding 2!?"; |
| 45 |
if ([2].lastIndexOf(2, 1) != 0) |
| 46 |
throw "lastIndexOf: not interpreting explicit second argument 1!?"; |
| 47 |
if ([2].lastIndexOf(2, 17) != 0) |
| 48 |
throw "lastIndexOf: should have searched entire array!"; |
| 49 |
if ([2].lastIndexOf(2, -5) != -1) |
| 50 |
throw "lastIndexOf: -5 + 1 < 0, so array shouldn't be searched!"; |
| 51 |
if ([2].lastIndexOf(2, -2) != -1) |
| 52 |
throw "lastIndexOf: -2 + 1 < 0, so array shouldn't be searched!"; |
| 53 |
if ([2, 3].lastIndexOf(2, -1) != 0) |
| 54 |
throw "lastIndexOf: not handling index == (-1 + 2), element 2 correctly!"; |
| 55 |
if ([2, 3].lastIndexOf(3, -1) != 1) |
| 56 |
throw "lastIndexOf: not handling index == (-1 + 2), element 3 correctly!"; |
| 57 |
if ([2, 3].lastIndexOf(2, -2) != 0) |
| 58 |
throw "lastIndexOf: not handling index == (-2 + 2), element 2 correctly!"; |
| 59 |
if ([2, 3].lastIndexOf(3, -2) != -1) |
| 60 |
throw "lastIndexOf: not handling index == (-2 + 2), element 3 correctly!"; |
| 61 |
if ([2, 3].lastIndexOf(2, -3) != -1) |
| 62 |
throw "lastIndexOf: calculated fromIndex < 0, shouldn't search array for 2!"; |
| 63 |
if ([2, 3].lastIndexOf(3, -3) != -1) |
| 64 |
throw "lastIndexOf: calculated fromIndex < 0, shouldn't search array for 3!"; |
| 65 |
} |
| 66 |
catch (e) |
| 67 |
{ |
| 68 |
failed = e; |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
expect = false; |
| 73 |
actual = failed; |
| 74 |
|
| 75 |
reportCompare(expect, actual, summary); |