blob: 63f88fb7e6bd71ae1c22907e8fbc41f8d2da7676 [file] [log] [blame]
Tests for Array.prototype.findIndex
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
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
PASS (new Array(20)).findIndex(passUndefined) is -1
PASS arrayWithHoles.findIndex(passUndefined) is -1
PASS arrayWithHoles.findIndex(passZero) is 10
PASS arrayWithHoles.findIndex(passNull) is 20
PASS arrayWithHoles.findIndex(passFalse) is 30
PASS arrayWithHoles.findIndex(passEmptyString) is 40
PASS arrayWithHoles.findIndex(passUndefined) is 50
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 -1
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
PASS Array.prototype.findIndex.call(undefined, function() {}) threw exception TypeError: Array.prototype.findIndex requires that |this| not be undefined.
PASS Array.prototype.findIndex.call(null, function() {}) threw exception TypeError: Array.prototype.findIndex requires that |this| not be null.
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.
find callback called with index 10
find callback called with index 20
find callback called with index 30
find callback called with index 40
find callback called with index 50
PASS numberOfCallbacksInFindIndexInArrayWithHoles() is 5
PASS successfullyParsed is true
TEST COMPLETE