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

99 lines
4.0 KiB
Plaintext
Raw Permalink Normal View History

ES6: Implement Array.from() https://bugs.webkit.org/show_bug.cgi?id=141054 <rdar://problem/19654521> Reviewed by Filip Pizlo. Source/JavaScriptCore: Implement the Array.from() ES6 method as defined in Section 22.1.2.1 of the specification. Given that we can't rely on the built-in global functions or objects to be untainted, I had to expose a few of them directly to the function via private names. In particular: - Math.floor -> @floor - Math.abs -> @abs - Number -> @Number - Array -> @Array - isFinite -> @isFinite * builtins/ArrayConstructor.js: Added. (from): Implementation of Array.from in JavaScript. * runtime/ArrayConstructor.cpp: Add "from" to the lookup table for the constructor object. * runtime/CommonIdentifiers.h: Add the private versions of the identifiers listed above. * runtime/JSGlobalObject.cpp: Add the implementations of those identifiers to the global object (using their private names). (JSC::JSGlobalObject::init): * runtime/JSGlobalObjectFunctions.cpp: (JSC::globalPrivateFuncAbs): Implementation of the abs function. (JSC::globalPrivateFuncFloor): Implementation of the floor function. * runtime/JSGlobalObjectFunctions.h: LayoutTests: Test for Array.from(). The test has one expected failure: using from() on a Set object, which will be addressed in a followup: https://bugs.webkit.org/show_bug.cgi?id=141055 * js/array-from-expected.txt: Added. * js/array-from.html: Added. * js/script-tests/array-from.js: Added. * js/Object-getOwnPropertyNames.html: Update results for the new value on the constructor. Canonical link: https://commits.webkit.org/159839@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180370 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-02-20 00:20:54 +00:00
Tests for Array.from
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Length of Array.from
-------
PASS Array.from.length is 1
Simple construction
-------
PASS Array.from instanceof Function is true
PASS Array.from([1]) is [1]
PASS Array.from([1, 2, 3]) is [1, 2, 3]
PASS Array.from([1, 2, 3]).length is 3
PASS Array.from('abc') is ['a', 'b', 'c']
PASS Array.from('abc').length is 3
PASS Array.from(Array.from([4, 5, 6])) is [4, 5, 6]
PASS Array.from([null, null]) is [null, null]
PASS Array.from([]).length is 0
PASS Array.from(new Uint8Array([1, 2, 3])) is [1, 2, 3]
Incorrect construction
-------
PASS Array.from() threw exception TypeError: Array.from requires an array-like object - not null or undefined.
PASS Array.from(null) threw exception TypeError: Array.from requires an array-like object - not null or undefined.
PASS Array.from(undefined) threw exception TypeError: Array.from requires an array-like object - not null or undefined.
Declare wayTooSmall = { length: -1 }
PASS Array.from(wayTooSmall) is []
Declare wayTooBig = { length: Infinity }
PASS Array.from(wayTooBig) threw exception RangeError: Array size is not a small enough positive integer..
Mapped construction
-------
PASS Array.from([1, 2, 3], function (x) { return x * 10; }) is [10, 20, 30]
PASS Array.from([1, 2, 3], function (x) { return null; }) is [null, null, null]
PASS Array.from([1, 2, 3], function (x) { }).length is 3
PASS Array.from({length: 5}, function(v, k) { return k; }) is [0, 1, 2, 3, 4]
Declare var bacon = { eggs: 5 }
PASS Array.from([1, 2, 3], function (x) { return x * this.eggs; }, bacon) is [5, 10, 15]
Incorrect mapped construction
-------
PASS Array.from([1, 2, 3], null) threw exception TypeError: Array.from requires that the second argument, when provided, be a function.
PASS Array.from([1, 2, 3], []) threw exception TypeError: Array.from requires that the second argument, when provided, be a function.
PASS Array.from([1, 2, 3], [1]) threw exception TypeError: Array.from requires that the second argument, when provided, be a function.
Weird construction
-------
PASS Array.from(Math).length is 0
Declare wayTooWrong = { length: NaN }
PASS Array.from(wayTooWrong) is []
Array with holes
-------
PASS Array.from(arrayWithHoles) is [,,, true,,,, , , 'hi']
Modify length during construction
-------
PASS Array.from(crazyPants) is ['one', 'two', 'three', 'four']
Modify length during mapping
-------
PASS Array.from(crazyPants, function (x) { crazyPants.length = x; return x; }) is ['one', 'two', 'three', 'four']
Construction using Set object
-------
PASS Array.from(set) is ['zero', 'one', 'two']
"this" is a constructor
-------
PASS Array.from.call(CustomConstructor, ['WebKit']).constructor is CustomConstructor
PASS Object.getPrototypeOf(Array.from.call(CustomConstructor, ['WebKit'])) is CustomConstructor.prototype
PASS Array.from.call(nonConstructor, ['WebKit']).length is 1
PASS Array.from.call(nonConstructor, ['WebKit'])[0] is "WebKit"
PASS Array.from.call(CustomConstructor, nonIterable).constructor is CustomConstructor
PASS Object.getPrototypeOf(Array.from.call(CustomConstructor, nonIterable)) is CustomConstructor.prototype
PASS Array.from.call(nonConstructor, nonIterable).length is 2
PASS Array.from.call(nonConstructor, nonIterable)[0] is "one"
PASS Array.from.call(nonConstructor, nonIterable)[1] is 2
"this" is not a constructor
-------
PASS Array.from.call(nonConstructor, ['WebKit']).constructor is Array
PASS Object.getPrototypeOf(Array.from.call(nonConstructor, ['WebKit'])) is Array.prototype
PASS Array.from.call(nonConstructor, ['WebKit']).length is 1
PASS Array.from.call(nonConstructor, ['WebKit'])[0] is "WebKit"
PASS nonConstructorWasCalled is false
PASS Array.from.call(nonConstructor, nonIterable).constructor is Array
PASS Object.getPrototypeOf(Array.from.call(nonConstructor, nonIterable)) is Array.prototype
PASS Array.from.call(nonConstructor, nonIterable).length is 2
PASS Array.from.call(nonConstructor, nonIterable)[0] is "one"
PASS Array.from.call(nonConstructor, nonIterable)[1] is 2
ES6: Implement Array.from() https://bugs.webkit.org/show_bug.cgi?id=141054 <rdar://problem/19654521> Reviewed by Filip Pizlo. Source/JavaScriptCore: Implement the Array.from() ES6 method as defined in Section 22.1.2.1 of the specification. Given that we can't rely on the built-in global functions or objects to be untainted, I had to expose a few of them directly to the function via private names. In particular: - Math.floor -> @floor - Math.abs -> @abs - Number -> @Number - Array -> @Array - isFinite -> @isFinite * builtins/ArrayConstructor.js: Added. (from): Implementation of Array.from in JavaScript. * runtime/ArrayConstructor.cpp: Add "from" to the lookup table for the constructor object. * runtime/CommonIdentifiers.h: Add the private versions of the identifiers listed above. * runtime/JSGlobalObject.cpp: Add the implementations of those identifiers to the global object (using their private names). (JSC::JSGlobalObject::init): * runtime/JSGlobalObjectFunctions.cpp: (JSC::globalPrivateFuncAbs): Implementation of the abs function. (JSC::globalPrivateFuncFloor): Implementation of the floor function. * runtime/JSGlobalObjectFunctions.h: LayoutTests: Test for Array.from(). The test has one expected failure: using from() on a Set object, which will be addressed in a followup: https://bugs.webkit.org/show_bug.cgi?id=141055 * js/array-from-expected.txt: Added. * js/array-from.html: Added. * js/script-tests/array-from.js: Added. * js/Object-getOwnPropertyNames.html: Update results for the new value on the constructor. Canonical link: https://commits.webkit.org/159839@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180370 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-02-20 00:20:54 +00:00
PASS successfullyParsed is true
TEST COMPLETE