| Tests for Array.prototype.findIndex |
| |
| On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". |
| |
| |
| PASS Array.prototype.findIndex.length is 1 |
| PASS Array.prototype.findIndex.name is 'findIndex' |
| PASS [undefined, 0, null, false, ''].findIndex(passUndefined) is 0 |
| PASS [undefined, 0, null, false, ''].findIndex(passZero) is 1 |
| PASS [undefined, 0, null, false, ''].findIndex(passNull) is 2 |
| PASS [undefined, 0, null, false, ''].findIndex(passFalse) is 3 |
| PASS [undefined, 0, null, false, ''].findIndex(passEmptyString) is 4 |
| PASS [0, null, false, ''].findIndex(passUndefined) is -1 |
| PASS [undefined, 0, false, ''].findIndex(passNull) is -1 |
| PASS [undefined, 0, null, ''].findIndex(passFalse) is -1 |
| PASS [undefined, 0, null, false].findIndex(passEmptyString) is -1 |
| PASS [undefined, null, false, ''].findIndex(passZero) is -1 |
| Array with holes |
| PASS (new Array(20)).findIndex(passUndefined) is 0 |
| PASS arrayWithHoles.findIndex(passUndefined) is 0 |
| PASS arrayWithHoles.findIndex(passZero) is 1 |
| PASS arrayWithHoles.findIndex(passNull) is 3 |
| PASS arrayWithHoles.findIndex(passFalse) is 5 |
| PASS arrayWithHoles.findIndex(passEmptyString) is 7 |
| PASS arrayWithHoles.findIndex(passUndefined) is 2 |
| Generic Object |
| PASS toObject([undefined, 0, null, false, '']).findIndex(passUndefined) is 0 |
| PASS toObject([undefined, 0, null, false, '']).findIndex(passZero) is 1 |
| PASS toObject([undefined, 0, null, false, '']).findIndex(passNull) is 2 |
| PASS toObject([undefined, 0, null, false, '']).findIndex(passFalse) is 3 |
| PASS toObject([undefined, 0, null, false, '']).findIndex(passEmptyString) is 4 |
| PASS toObject([0, null, false, '']).findIndex(passUndefined) is -1 |
| PASS toObject([undefined, 0, false, '']).findIndex(passNull) is -1 |
| PASS toObject([undefined, 0, null, '']).findIndex(passFalse) is -1 |
| PASS toObject([undefined, 0, null, false]).findIndex(passEmptyString) is -1 |
| PASS toObject([undefined, null, false, '']).findIndex(passZero) is -1 |
| PASS toObject(new Array(20)).findIndex(passUndefined) is 0 |
| Array-like object with invalid lengths |
| PASS var obj = { 0: 1, 1: 2, 2: 3, length: 0 }; Array.prototype.findIndex.call(obj, throwError) is -1 |
| PASS var obj = { 0: 1, 1: 2, 2: 3, length: -0 }; Array.prototype.findIndex.call(obj, throwError) is -1 |
| PASS var obj = { 0: 1, 1: 2, 2: 3, length: -3 }; Array.prototype.findIndex.call(obj, throwError) is -1 |
| Modification during search |
| PASS [0,1,2,3,4,5,6,7,8,9].findIndex(findItemAddedDuringSearch) is -1 |
| PASS [0,1,2,3,4,5,6,7,8,9].findIndex(findItemRemovedDuringSearch) is -1 |
| Exceptions |
| PASS Array.prototype.findIndex.call(undefined, function() {}) threw exception TypeError: Array.prototype.findIndex requires that |this| not be null or undefined. |
| PASS Array.prototype.findIndex.call(null, function() {}) threw exception TypeError: Array.prototype.findIndex requires that |this| not be null or undefined. |
| PASS [].findIndex(1) threw exception TypeError: Array.prototype.findIndex callback must be a function. |
| PASS [].findIndex('hello') threw exception TypeError: Array.prototype.findIndex callback must be a function. |
| PASS [].findIndex([]) threw exception TypeError: Array.prototype.findIndex callback must be a function. |
| PASS [].findIndex({}) threw exception TypeError: Array.prototype.findIndex callback must be a function. |
| PASS [].findIndex(null) threw exception TypeError: Array.prototype.findIndex callback must be a function. |
| PASS [].findIndex(undefined) threw exception TypeError: Array.prototype.findIndex callback must be a function. |
| Callbacks in the expected order and *not* skipping holes |
| find callback called with index 0 |
| find callback called with index 1 |
| find callback called with index 2 |
| find callback called with index 3 |
| find callback called with index 4 |
| find callback called with index 5 |
| find callback called with index 6 |
| find callback called with index 7 |
| PASS numberOfCallbacksInFindIndexInArrayWithHoles() is 8 |
| PASS successfullyParsed is true |
| |
| TEST COMPLETE |
| |