blob: 5d2c1933b5a0f58cc7bea6cd6461272b984952ce [file] [log] [blame]
Tests for Array.prototype.findLastIndex
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Array.prototype.findLastIndex.length is 1
PASS Array.prototype.findLastIndex.name is 'findLastIndex'
PASS [undefined, 0, null, false, ''].findLastIndex(passUndefined) is 0
PASS [undefined, 0, null, false, ''].findLastIndex(passZero) is 1
PASS [undefined, 0, null, false, ''].findLastIndex(passNull) is 2
PASS [undefined, 0, null, false, ''].findLastIndex(passFalse) is 3
PASS [undefined, 0, null, false, ''].findLastIndex(passEmptyString) is 4
PASS [0,1,2,3,4,5,6,7,8,9].findLastIndex(passEven) is 8
PASS [0,1,2,3,4,5,6,7,8,9].findLastIndex(passAfter5) is 9
PASS [0, null, false, ''].findLastIndex(passUndefined) is -1
PASS [undefined, 0, false, ''].findLastIndex(passNull) is -1
PASS [undefined, 0, null, ''].findLastIndex(passFalse) is -1
PASS [undefined, 0, null, false].findLastIndex(passEmptyString) is -1
PASS [1,3,5,7,9].findLastIndex(passEven) is -1
PASS [0,1,2,3,4].findLastIndex(passAfter5) is -1
PASS [undefined, null, false, ''].findLastIndex(passZero) is -1
Array with holes
PASS (new Array(20)).findLastIndex(passUndefined) is 19
PASS arrayWithHoles.findLastIndex(passUndefined) is 6
PASS arrayWithHoles.findLastIndex(passZero) is 1
PASS arrayWithHoles.findLastIndex(passNull) is 3
PASS arrayWithHoles.findLastIndex(passFalse) is 5
PASS arrayWithHoles.findLastIndex(passEmptyString) is 7
PASS arrayWithHoles.findLastIndex(passAfter5) is 7
PASS arrayWithHoles.findLastIndex(passUndefined) is 4
Generic Object
PASS toObject([undefined, 0, null, false, '']).findLastIndex(passUndefined) is 0
PASS toObject([undefined, 0, null, false, '']).findLastIndex(passZero) is 1
PASS toObject([undefined, 0, null, false, '']).findLastIndex(passNull) is 2
PASS toObject([undefined, 0, null, false, '']).findLastIndex(passFalse) is 3
PASS toObject([undefined, 0, null, false, '']).findLastIndex(passEmptyString) is 4
PASS toObject([0, null, false, '']).findLastIndex(passUndefined) is -1
PASS toObject([undefined, 0, false, '']).findLastIndex(passNull) is -1
PASS toObject([undefined, 0, null, '']).findLastIndex(passFalse) is -1
PASS toObject([undefined, 0, null, false]).findLastIndex(passEmptyString) is -1
PASS toObject([undefined, null, false, '']).findLastIndex(passZero) is -1
PASS toObject(new Array(20)).findLastIndex(passUndefined) is 19
Array-like object with invalid lengths
PASS var obj = { 0: 1, 1: 2, 2: 3, length: 0 }; Array.prototype.findLastIndex.call(obj, throwError) is -1
PASS var obj = { 0: 1, 1: 2, 2: 3, length: -0 }; Array.prototype.findLastIndex.call(obj, throwError) is -1
PASS var obj = { 0: 1, 1: 2, 2: 3, length: -3 }; Array.prototype.findLastIndex.call(obj, throwError) is -1
Modification during search
PASS [0,1,2,3,4,5,6,7,8,9].findLastIndex(findItemAddedDuringSearch) is -1
PASS [0,1,2,3,4,5,6,7,8,9].findLastIndex(findItemRemovedDuringSearch) is -1
Exceptions
PASS Array.prototype.findLastIndex.call(undefined, function() {}) threw exception TypeError: Array.prototype.findLastIndex requires that |this| not be null or undefined.
PASS Array.prototype.findLastIndex.call(null, function() {}) threw exception TypeError: Array.prototype.findLastIndex requires that |this| not be null or undefined.
PASS [].findLastIndex(1) threw exception TypeError: Array.prototype.findLastIndex callback must be a function.
PASS [].findLastIndex('hello') threw exception TypeError: Array.prototype.findLastIndex callback must be a function.
PASS [].findLastIndex([]) threw exception TypeError: Array.prototype.findLastIndex callback must be a function.
PASS [].findLastIndex({}) threw exception TypeError: Array.prototype.findLastIndex callback must be a function.
PASS [].findLastIndex(null) threw exception TypeError: Array.prototype.findLastIndex callback must be a function.
PASS [].findLastIndex(undefined) threw exception TypeError: Array.prototype.findLastIndex 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