Changeset 184942 in webkit
- Timestamp:
- May 27, 2015, 10:47:11 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r184933 r184942 1 2015-05-27 Jordan Harband <ljharb@gmail.com> 2 3 Array.of should work with other constructors 4 https://bugs.webkit.org/show_bug.cgi?id=145365 5 6 Reviewed by Yusuke Suzuki. 7 8 * js/array-of-expected.txt: 9 * js/script-tests/array-of.js: 10 (Foo): 11 1 12 2015-05-27 Benjamin Poulain <bpoulain@apple.com> 2 13 -
trunk/LayoutTests/js/array-of-expected.txt
r180441 r184942 4 4 5 5 6 PASS Array.of.length is 0 7 PASS Array.of.name is 'of' 6 8 PASS Array.of(1) is [1] 7 9 PASS Array.of(1, 2) is [1, 2] … … 16 18 Check that a setter isn't called. 17 19 PASS Array.of(1, 2, 3) did not throw exception. 20 PASS Array.of.call(Foo, 'a', 'b', 'c') instanceof Foo is true 21 PASS Array.of.call(Foo, 'a', 'b', 'c').givenLength is 3 22 PASS var foo = Array.of.call(Foo, 'a', 'b', 'c'); [foo.length, foo[0], foo[1], foo[2]] is [3, 'a', 'b', 'c'] 18 23 PASS successfullyParsed is true 19 24 -
trunk/LayoutTests/js/script-tests/array-of.js
r180441 r184942 1 1 description("Tests for Array.of"); 2 3 shouldBe("Array.of.length", "0"); 4 shouldBe("Array.of.name", "'of'"); 2 5 3 6 shouldBe("Array.of(1)", "[1]"); … … 23 26 shouldNotThrow("Array.of(1, 2, 3)"); 24 27 28 var Foo = function FooBar(length) { this.givenLength = length; }; 29 shouldBeTrue("Array.of.call(Foo, 'a', 'b', 'c') instanceof Foo") 30 shouldBe("Array.of.call(Foo, 'a', 'b', 'c').givenLength", "3"); 31 shouldBe("var foo = Array.of.call(Foo, 'a', 'b', 'c'); [foo.length, foo[0], foo[1], foo[2]]", "[3, 'a', 'b', 'c']"); -
trunk/Source/JavaScriptCore/ChangeLog
r184933 r184942 1 2015-05-27 Jordan Harband <ljharb@gmail.com> 2 3 Array.of should work with other constructors 4 https://bugs.webkit.org/show_bug.cgi?id=145365 5 Per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.of 6 step 4 7 8 Reviewed by Yusuke Suzuki. 9 10 * builtins/ArrayConstructor.js: 11 (of): 12 * runtime/ArrayConstructor.cpp: 13 (JSC::arrayConstructorOf): Deleted. 14 1 15 2015-05-27 Benjamin Poulain <bpoulain@apple.com> 2 16 -
trunk/Source/JavaScriptCore/builtins/ArrayConstructor.js
r184582 r184942 23 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 26 function of(/* items... */) 27 { 28 "use strict"; 29 30 var length = arguments.length; 31 // TODO: Need isConstructor(this) instead of typeof "function" check. 32 var array = typeof this === 'function' ? new this(length) : new @Array(length); 33 for (var k = 0; k < length; ++k) 34 @putByValDirect(array, k, arguments[k]); 35 array.length = length; 36 return array; 37 } 25 38 26 39 function from(items /*, mapFn, thisArg */) { -
trunk/Source/JavaScriptCore/runtime/ArrayConstructor.cpp
r180370 r184942 38 38 39 39 static EncodedJSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState*); 40 static EncodedJSValue JSC_HOST_CALL arrayConstructorOf(ExecState*);41 40 42 41 } … … 130 129 } 131 130 132 EncodedJSValue JSC_HOST_CALL arrayConstructorOf(ExecState* exec)133 {134 ArgList args(exec);135 size_t length = args.size();136 137 JSArray* result = constructEmptyArray(exec, nullptr, length);138 139 for (unsigned i = 0; i < length; i++)140 result->putDirectIndex(exec, i, args.at(i));141 142 return JSValue::encode(result);143 }144 145 131 } // namespace JSC
Note:
See TracChangeset
for help on using the changeset viewer.