|
| 1 | +Tests for Array.prototype.findLastIndex |
| 2 | + |
| 3 | +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". |
| 4 | + |
| 5 | + |
| 6 | +PASS Array.prototype.findLastIndex.length is 1 |
| 7 | +PASS Array.prototype.findLastIndex.name is 'findLastIndex' |
| 8 | +PASS [undefined, 0, null, false, ''].findLastIndex(passUndefined) is 0 |
| 9 | +PASS [undefined, 0, null, false, ''].findLastIndex(passZero) is 1 |
| 10 | +PASS [undefined, 0, null, false, ''].findLastIndex(passNull) is 2 |
| 11 | +PASS [undefined, 0, null, false, ''].findLastIndex(passFalse) is 3 |
| 12 | +PASS [undefined, 0, null, false, ''].findLastIndex(passEmptyString) is 4 |
| 13 | +PASS [0,1,2,3,4,5,6,7,8,9].findLastIndex(passEven) is 8 |
| 14 | +PASS [0,1,2,3,4,5,6,7,8,9].findLastIndex(passAfter5) is 9 |
| 15 | +PASS [0, null, false, ''].findLastIndex(passUndefined) is -1 |
| 16 | +PASS [undefined, 0, false, ''].findLastIndex(passNull) is -1 |
| 17 | +PASS [undefined, 0, null, ''].findLastIndex(passFalse) is -1 |
| 18 | +PASS [undefined, 0, null, false].findLastIndex(passEmptyString) is -1 |
| 19 | +PASS [1,3,5,7,9].findLastIndex(passEven) is -1 |
| 20 | +PASS [0,1,2,3,4].findLastIndex(passAfter5) is -1 |
| 21 | +PASS [undefined, null, false, ''].findLastIndex(passZero) is -1 |
| 22 | +Array with holes |
| 23 | +PASS (new Array(20)).findLastIndex(passUndefined) is 19 |
| 24 | +PASS arrayWithHoles.findLastIndex(passUndefined) is 6 |
| 25 | +PASS arrayWithHoles.findLastIndex(passZero) is 1 |
| 26 | +PASS arrayWithHoles.findLastIndex(passNull) is 3 |
| 27 | +PASS arrayWithHoles.findLastIndex(passFalse) is 5 |
| 28 | +PASS arrayWithHoles.findLastIndex(passEmptyString) is 7 |
| 29 | +PASS arrayWithHoles.findLastIndex(passAfter5) is 7 |
| 30 | +PASS arrayWithHoles.findLastIndex(passUndefined) is 4 |
| 31 | +Generic Object |
| 32 | +PASS toObject([undefined, 0, null, false, '']).findLastIndex(passUndefined) is 0 |
| 33 | +PASS toObject([undefined, 0, null, false, '']).findLastIndex(passZero) is 1 |
| 34 | +PASS toObject([undefined, 0, null, false, '']).findLastIndex(passNull) is 2 |
| 35 | +PASS toObject([undefined, 0, null, false, '']).findLastIndex(passFalse) is 3 |
| 36 | +PASS toObject([undefined, 0, null, false, '']).findLastIndex(passEmptyString) is 4 |
| 37 | +PASS toObject([0, null, false, '']).findLastIndex(passUndefined) is -1 |
| 38 | +PASS toObject([undefined, 0, false, '']).findLastIndex(passNull) is -1 |
| 39 | +PASS toObject([undefined, 0, null, '']).findLastIndex(passFalse) is -1 |
| 40 | +PASS toObject([undefined, 0, null, false]).findLastIndex(passEmptyString) is -1 |
| 41 | +PASS toObject([undefined, null, false, '']).findLastIndex(passZero) is -1 |
| 42 | +PASS toObject(new Array(20)).findLastIndex(passUndefined) is 19 |
| 43 | +Array-like object with invalid lengths |
| 44 | +PASS var obj = { 0: 1, 1: 2, 2: 3, length: 0 }; Array.prototype.findLastIndex.call(obj, throwError) is -1 |
| 45 | +PASS var obj = { 0: 1, 1: 2, 2: 3, length: -0 }; Array.prototype.findLastIndex.call(obj, throwError) is -1 |
| 46 | +PASS var obj = { 0: 1, 1: 2, 2: 3, length: -3 }; Array.prototype.findLastIndex.call(obj, throwError) is -1 |
| 47 | +Modification during search |
| 48 | +PASS [0,1,2,3,4,5,6,7,8,9].findLastIndex(findItemAddedDuringSearch) is -1 |
| 49 | +PASS [0,1,2,3,4,5,6,7,8,9].findLastIndex(findItemRemovedDuringSearch) is -1 |
| 50 | +Exceptions |
| 51 | +PASS Array.prototype.findLastIndex.call(undefined, function() {}) threw exception TypeError: Array.prototype.findLastIndex requires that |this| not be null or undefined. |
| 52 | +PASS Array.prototype.findLastIndex.call(null, function() {}) threw exception TypeError: Array.prototype.findLastIndex requires that |this| not be null or undefined. |
| 53 | +PASS [].findLastIndex(1) threw exception TypeError: Array.prototype.findLastIndex callback must be a function. |
| 54 | +PASS [].findLastIndex('hello') threw exception TypeError: Array.prototype.findLastIndex callback must be a function. |
| 55 | +PASS [].findLastIndex([]) threw exception TypeError: Array.prototype.findLastIndex callback must be a function. |
| 56 | +PASS [].findLastIndex({}) threw exception TypeError: Array.prototype.findLastIndex callback must be a function. |
| 57 | +PASS [].findLastIndex(null) threw exception TypeError: Array.prototype.findLastIndex callback must be a function. |
| 58 | +PASS [].findLastIndex(undefined) threw exception TypeError: Array.prototype.findLastIndex callback must be a function. |
| 59 | +Callbacks in the expected order and *not* skipping holes |
| 60 | +find callback called with index 0 |
| 61 | +find callback called with index 1 |
| 62 | +find callback called with index 2 |
| 63 | +find callback called with index 3 |
| 64 | +find callback called with index 4 |
| 65 | +find callback called with index 5 |
| 66 | +find callback called with index 6 |
| 67 | +find callback called with index 7 |
| 68 | +PASS numberOfCallbacksInFindIndexInArrayWithHoles() is 8 |
| 69 | +PASS successfullyParsed is true |
| 70 | + |
| 71 | +TEST COMPLETE |
| 72 | + |
0 commit comments