haikuwebkit/LayoutTests/js/array-join.html

12 lines
240 B
HTML
Raw Permalink Normal View History

[JSC] Array.prototype.join() fails some conformance tests https://bugs.webkit.org/show_bug.cgi?id=159657 Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-07-12 Reviewed by Saam Barati. Source/JavaScriptCore: There were a couple of failures: -separator.toString() was called *before* we get the length and process ToLength() on it. -We were using toUInt32() on length instead of ToLength(), failing on big integers and various negative numbers. Additionally, I replaced the "fast" ArrayStorage path by a fully generic implementation that does not depends on StringJoiner. The reason is StringJoiner was doing poorly on sparse objects in certain cases. If you have a sparse object with a length > INT_MAX but very few indices defined, and you join on the empty string, it should be possible to join the array (albeit very slowly). With StringJoiner, we fail because we try to allocate > INT_MAX empty strings in a contiguous vector. * runtime/ArrayPrototype.cpp: (JSC::slowJoin): (JSC::canUseFastJoin): (JSC::fastJoin): (JSC::arrayProtoFuncJoin): (JSC::join): Deleted. * runtime/JSArray.h: (JSC::toLength): Source/WTF: * wtf/text/AtomicString.cpp: (WTF::AtomicString::number): * wtf/text/AtomicString.h: LayoutTests: I removed 3 sputnik tests that are incorrect in the latest spec. In ES5, Array.prototype.join() was using ToUint32 on the argument: https://es5.github.io/#x15.4.4.5 In ES6, the function uses ToLength: https://tc39.github.io/ecma262/#sec-array.prototype.join The test use Infinity and very large integer as the length. They are guaranteed to time out or run out of memory. Even if we waited the hours it takes to run this, the results would be different from what the tests expect. * js/array-join-expected.txt: Added. * js/array-join.html: Added. * js/script-tests/array-join.js: Added. Canonical link: https://commits.webkit.org/177847@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203147 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-13 01:25:25 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<script src="script-tests/array-join.js"></script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>