haikuwebkit/LayoutTests/js/array-findIndex-expected.txt

68 lines
3.8 KiB
Plaintext
Raw Permalink Normal View History

Tests for Array.prototype.findIndex
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Array.prototype methods must use ToLength https://bugs.webkit.org/show_bug.cgi?id=144128 Reviewed by Oliver Hunt. Source/JavaScriptCore: Per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength This patch introduces ToLength and ToInteger JS implementation to encourage the DFG/FTL's inlining. These implementations are located in GlobalObject.js. And set to the JSGlobalObject with the private symbols @ToLength and @ToInteger manually. * builtins/Array.prototype.js: (every): (forEach): (filter): (map): (some): (fill): (find): (findIndex): (includes): * builtins/ArrayConstructor.js: (from): * builtins/GlobalObject.js: Copied from Source/JavaScriptCore/builtins/StringConstructor.js. (ToInteger): (ToLength): * builtins/StringConstructor.js: (raw): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObjectFunctions.h: LayoutTests: * fast/profiler/built-in-function-calls-anonymous-expected.txt: * fast/profiler/built-in-function-calls-user-defined-function-expected.txt: * js/array-every-expected.txt: * js/array-fill-expected.txt: * js/array-filter-expected.txt: * js/array-find-expected.txt: * js/array-findIndex-expected.txt: * js/array-functions-non-arrays-expected.txt: * js/array-includes-expected.txt: * js/script-tests/array-every.js: (throwError): * js/script-tests/array-fill.js: (throwError): * js/script-tests/array-filter.js: (throwError): * js/script-tests/array-find.js: (throwError): * js/script-tests/array-findIndex.js: (toObject): (throwError): * js/script-tests/array-functions-non-arrays.js: (throwError): * js/script-tests/array-includes.js: Canonical link: https://commits.webkit.org/163178@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184582 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-05-19 19:51:46 +00:00
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.prototype methods must use ToLength https://bugs.webkit.org/show_bug.cgi?id=144128 Reviewed by Oliver Hunt. Source/JavaScriptCore: Per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength This patch introduces ToLength and ToInteger JS implementation to encourage the DFG/FTL's inlining. These implementations are located in GlobalObject.js. And set to the JSGlobalObject with the private symbols @ToLength and @ToInteger manually. * builtins/Array.prototype.js: (every): (forEach): (filter): (map): (some): (fill): (find): (findIndex): (includes): * builtins/ArrayConstructor.js: (from): * builtins/GlobalObject.js: Copied from Source/JavaScriptCore/builtins/StringConstructor.js. (ToInteger): (ToLength): * builtins/StringConstructor.js: (raw): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObjectFunctions.h: LayoutTests: * fast/profiler/built-in-function-calls-anonymous-expected.txt: * fast/profiler/built-in-function-calls-user-defined-function-expected.txt: * js/array-every-expected.txt: * js/array-fill-expected.txt: * js/array-filter-expected.txt: * js/array-find-expected.txt: * js/array-findIndex-expected.txt: * js/array-functions-non-arrays-expected.txt: * js/array-includes-expected.txt: * js/script-tests/array-every.js: (throwError): * js/script-tests/array-fill.js: (throwError): * js/script-tests/array-filter.js: (throwError): * js/script-tests/array-find.js: (throwError): * js/script-tests/array-findIndex.js: (toObject): (throwError): * js/script-tests/array-functions-non-arrays.js: (throwError): * js/script-tests/array-includes.js: Canonical link: https://commits.webkit.org/163178@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184582 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-05-19 19:51:46 +00:00
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
Array.prototype methods must use ToLength https://bugs.webkit.org/show_bug.cgi?id=144128 Reviewed by Oliver Hunt. Source/JavaScriptCore: Per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength This patch introduces ToLength and ToInteger JS implementation to encourage the DFG/FTL's inlining. These implementations are located in GlobalObject.js. And set to the JSGlobalObject with the private symbols @ToLength and @ToInteger manually. * builtins/Array.prototype.js: (every): (forEach): (filter): (map): (some): (fill): (find): (findIndex): (includes): * builtins/ArrayConstructor.js: (from): * builtins/GlobalObject.js: Copied from Source/JavaScriptCore/builtins/StringConstructor.js. (ToInteger): (ToLength): * builtins/StringConstructor.js: (raw): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObjectFunctions.h: LayoutTests: * fast/profiler/built-in-function-calls-anonymous-expected.txt: * fast/profiler/built-in-function-calls-user-defined-function-expected.txt: * js/array-every-expected.txt: * js/array-fill-expected.txt: * js/array-filter-expected.txt: * js/array-find-expected.txt: * js/array-findIndex-expected.txt: * js/array-functions-non-arrays-expected.txt: * js/array-includes-expected.txt: * js/script-tests/array-every.js: (throwError): * js/script-tests/array-fill.js: (throwError): * js/script-tests/array-filter.js: (throwError): * js/script-tests/array-find.js: (throwError): * js/script-tests/array-findIndex.js: (toObject): (throwError): * js/script-tests/array-functions-non-arrays.js: (throwError): * js/script-tests/array-includes.js: Canonical link: https://commits.webkit.org/163178@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184582 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-05-19 19:51:46 +00:00
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.prototype methods must use ToLength https://bugs.webkit.org/show_bug.cgi?id=144128 Reviewed by Oliver Hunt. Source/JavaScriptCore: Per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength This patch introduces ToLength and ToInteger JS implementation to encourage the DFG/FTL's inlining. These implementations are located in GlobalObject.js. And set to the JSGlobalObject with the private symbols @ToLength and @ToInteger manually. * builtins/Array.prototype.js: (every): (forEach): (filter): (map): (some): (fill): (find): (findIndex): (includes): * builtins/ArrayConstructor.js: (from): * builtins/GlobalObject.js: Copied from Source/JavaScriptCore/builtins/StringConstructor.js. (ToInteger): (ToLength): * builtins/StringConstructor.js: (raw): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObjectFunctions.h: LayoutTests: * fast/profiler/built-in-function-calls-anonymous-expected.txt: * fast/profiler/built-in-function-calls-user-defined-function-expected.txt: * js/array-every-expected.txt: * js/array-fill-expected.txt: * js/array-filter-expected.txt: * js/array-find-expected.txt: * js/array-findIndex-expected.txt: * js/array-functions-non-arrays-expected.txt: * js/array-includes-expected.txt: * js/script-tests/array-every.js: (throwError): * js/script-tests/array-fill.js: (throwError): * js/script-tests/array-filter.js: (throwError): * js/script-tests/array-find.js: (throwError): * js/script-tests/array-findIndex.js: (toObject): (throwError): * js/script-tests/array-functions-non-arrays.js: (throwError): * js/script-tests/array-includes.js: Canonical link: https://commits.webkit.org/163178@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184582 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-05-19 19:51:46 +00:00
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
Array.prototype methods must use ToLength https://bugs.webkit.org/show_bug.cgi?id=144128 Reviewed by Oliver Hunt. Source/JavaScriptCore: Per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength This patch introduces ToLength and ToInteger JS implementation to encourage the DFG/FTL's inlining. These implementations are located in GlobalObject.js. And set to the JSGlobalObject with the private symbols @ToLength and @ToInteger manually. * builtins/Array.prototype.js: (every): (forEach): (filter): (map): (some): (fill): (find): (findIndex): (includes): * builtins/ArrayConstructor.js: (from): * builtins/GlobalObject.js: Copied from Source/JavaScriptCore/builtins/StringConstructor.js. (ToInteger): (ToLength): * builtins/StringConstructor.js: (raw): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObjectFunctions.h: LayoutTests: * fast/profiler/built-in-function-calls-anonymous-expected.txt: * fast/profiler/built-in-function-calls-user-defined-function-expected.txt: * js/array-every-expected.txt: * js/array-fill-expected.txt: * js/array-filter-expected.txt: * js/array-find-expected.txt: * js/array-findIndex-expected.txt: * js/array-functions-non-arrays-expected.txt: * js/array-includes-expected.txt: * js/script-tests/array-every.js: (throwError): * js/script-tests/array-fill.js: (throwError): * js/script-tests/array-filter.js: (throwError): * js/script-tests/array-find.js: (throwError): * js/script-tests/array-findIndex.js: (toObject): (throwError): * js/script-tests/array-functions-non-arrays.js: (throwError): * js/script-tests/array-includes.js: Canonical link: https://commits.webkit.org/163178@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184582 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-05-19 19:51:46 +00:00
Exceptions
Make builtin TypeErrors consistent https://bugs.webkit.org/show_bug.cgi?id=159899 Patch by Joseph Pecoraro <pecoraro@apple.com> on 2016-07-18 Reviewed by Keith Miller. Source/JavaScriptCore: Converge on the single TypeError for non-coercible this objects in builtins. Also update some other style to be more consistent with-in builtins. * builtins/ArrayIteratorPrototype.js: (next): * builtins/ArrayPrototype.js: (values): (keys): (entries): (reduce): (reduceRight): (every): (forEach): (filter): (map): (some): (fill): (find): (findIndex): (includes): (sort): (concatSlowPath): (copyWithin): * builtins/StringPrototype.js: (match): (repeat): (padStart): (padEnd): (intrinsic.StringPrototypeReplaceIntrinsic.replace): (localeCompare): (search): (split): * tests/es6/String.prototype_methods_String.prototype.padEnd.js: * tests/es6/String.prototype_methods_String.prototype.padStart.js: * tests/stress/array-iterators-next-error-messages.js: (catch): * tests/stress/array-iterators-next-with-call.js: * tests/stress/regexp-match.js: (shouldThrow): * tests/stress/regexp-search.js: (shouldThrow): LayoutTests: * js/array-find-expected.txt: * js/array-findIndex-expected.txt: * js/array-includes-expected.txt: * js/dom/array-prototype-properties-expected.txt: * js/dom/script-tests/string-prototype-properties.js: * js/dom/string-prototype-properties-expected.txt: * js/script-tests/array-find.js: * js/script-tests/array-findIndex.js: * js/script-tests/string-localeCompare.js: * js/string-localeCompare-expected.txt: * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.10_String.prototype.match/S15.5.4.10_A1_T3-expected.txt: * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.11_String.prototype.replace/S15.5.4.11_A1_T3-expected.txt: * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.12_String.prototype.search/S15.5.4.12_A1_T3-expected.txt: * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.14_String.prototype.split/S15.5.4.14_A1_T3-expected.txt: Canonical link: https://commits.webkit.org/178077@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203393 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-19 02:45:35 +00:00
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