| Tests for Array.prototype.includes |
| |
| On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". |
| |
| |
| PASS Array.prototype.includes.length is 1 |
| PASS Array.prototype.includes.name is 'includes' |
| PASS [1, 2, 3].includes(2) is true |
| PASS [1, 2, 3].includes(4) is false |
| PASS [].includes(1) is false |
| PASS [1, 2, 3].includes(1, 2) is false |
| PASS [1, 2, 3].includes(3, 3) is false |
| PASS [1, 2, 3].includes(2, undefined) is true |
| PASS [1, 2, 3].includes(2, null) is true |
| PASS [1, 2, 3].includes(2, 1, 2) is true |
| PASS [1, 2, 3].includes(2, Number) is true |
| PASS [1, 2, 3].includes(2, Number(2)) is false |
| PASS [1, 2, 3].includes(2, 'egg') is true |
| PASS [1, 2, 3].includes(2, '3') is false |
| PASS [1, 2, 3].includes(3, -1) is true |
| PASS [1, 2, 3].includes(1, -2) is false |
| PASS [1, 2, 3].includes(1, -3) is true |
| PASS [1, 2, NaN, 4].includes(NaN) is true |
| PASS ['egg', 'bacon', 'sausage'].includes('egg') is true |
| PASS ['egg', 'bacon', 'sausage'].includes('spinach') is false |
| Array with holes (sparse array) |
| PASS a.includes('egg') is true |
| PASS a.includes('sausage') is true |
| PASS a.includes('hashbrown') is false |
| PASS a.includes('toast') is false |
| PASS Array.prototype.includes.call(undefined, 1) threw exception TypeError: Array.prototype.includes requires that |this| not be null or undefined. |
| PASS Array.prototype.includes.call(null, 1) threw exception TypeError: Array.prototype.includes requires that |this| not be null or undefined. |
| Array-like object with invalid lengths |
| PASS var obj = { 0: 1, 1: 1, 2: 1, length: 0 }; Array.prototype.includes.call(obj, 1) is false |
| PASS var obj = { 0: 1, 1: 1, 2: 1, length: -0 }; Array.prototype.includes.call(obj, 1) is false |
| PASS var obj = { 0: 1, 1: 1, 2: 1, length: -3 }; Array.prototype.includes.call(obj, 1) is false |
| The index is converted to integer |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(2, NaN) is true |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(7, NaN) is true |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(17, NaN) is true |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(2, Infinity) is false |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(7, Infinity) is false |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(17, Infinity) is false |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(2, -Infinity) is true |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(7, -Infinity) is true |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(17, -Infinity) is true |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(2, Number.MAX_SAFE_INTEGER) is false |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(7, Number.MAX_SAFE_INTEGER) is false |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(17, Number.MAX_SAFE_INTEGER) is false |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(2, Number.MAX_SAFE_INTEGER + 1) is false |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(7, Number.MAX_SAFE_INTEGER + 1) is false |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(17, Number.MAX_SAFE_INTEGER + 1) is false |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(2, Number.MIN_SAFE_INTEGER) is true |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(7, Number.MIN_SAFE_INTEGER) is true |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(17, Number.MIN_SAFE_INTEGER) is true |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(2, Number.MIN_SAFE_INTEGER - 1) is true |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(7, Number.MIN_SAFE_INTEGER - 1) is true |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(17, Number.MIN_SAFE_INTEGER - 1) is true |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(2, { valueOf: () => { return 1; } }) is false |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(7, { valueOf: () => { return 1; } }) is true |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(17, { valueOf: () => { return 1; } }) is true |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(2, { toString: () => { return '1'; } }) is false |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(7, { toString: () => { return '1'; } }) is true |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(17, { toString: () => { return '1'; } }) is true |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(2, '1') is false |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(7, '1') is true |
| PASS [2, 3, 5, 7, 11, 13, 17].includes(17, '1') is true |
| PASS successfullyParsed is true |
| |
| TEST COMPLETE |
| |