diff --git a/test/built-ins/TypedArray/from/arylk-get-length-error.js b/test/built-ins/TypedArray/from/arylk-get-length-error.js index b851406ba7d9667ce6b645e62b70b55cf381a0c7..f3b09d0c352dc5331ab1921364db3d54344f5664 100644 --- a/test/built-ins/TypedArray/from/arylk-get-length-error.js +++ b/test/built-ins/TypedArray/from/arylk-get-length-error.js @@ -1,21 +1,20 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 22.2.2.1.1 +id: sec-%typedarray%.from description: Returns error produced by accessing array-like's length info: > - 22.2.2.1.1 Runtime Semantics: TypedArrayFrom( constructor, items, mapfn, thisArg ) + 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) ... - 12. Let len be ToLength(Get(arrayLike, "length")). - 13. ReturnIfAbrupt(len). + 7. Let len be ? ToLength(? Get(arrayLike, "length")). ... includes: [testTypedArray.js] ---*/ var arrayLike = {}; -Object.defineProperty(arrayLike, 'length', { +Object.defineProperty(arrayLike, "length", { get: function() { throw new Test262Error(); } diff --git a/test/built-ins/TypedArray/from/arylk-to-length-error.js b/test/built-ins/TypedArray/from/arylk-to-length-error.js index b5907b2021ce5d5615138e961de4179590cd65a1..857a279a0670a0d4f41ca757f9078ae030b90207 100644 --- a/test/built-ins/TypedArray/from/arylk-to-length-error.js +++ b/test/built-ins/TypedArray/from/arylk-to-length-error.js @@ -1,23 +1,23 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 22.2.2.1.1 +id: sec-%typedarray%.from description: Returns error produced by interpreting length property as a length info: > - 22.2.2.1.1 Runtime Semantics: TypedArrayFrom( constructor, items, mapfn, thisArg ) + 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) ... - 12. Let len be ToLength(Get(arrayLike, "length")). - 13. ReturnIfAbrupt(len). + 7. Let len be ? ToLength(? Get(arrayLike, "length")). ... -features: [Symbol.toPrimitive] includes: [testTypedArray.js] ---*/ var arrayLike = { length: {} }; -arrayLike.length[Symbol.toPrimitive] = function() { - throw new Test262Error(); +arrayLike.length = { + valueOf: function() { + throw new Test262Error(); + } }; assert.throws(Test262Error, function() { diff --git a/test/built-ins/TypedArray/from/invoked-as-func.js b/test/built-ins/TypedArray/from/invoked-as-func.js index 3574555e88ab2940081fe68a58003d937671bc80..2fc2000dd2ff2872e0006feb4a6082265f3730c2 100644 --- a/test/built-ins/TypedArray/from/invoked-as-func.js +++ b/test/built-ins/TypedArray/from/invoked-as-func.js @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 22.2.2.1 +id: sec-%typedarray%.from description: > "from" cannot be invoked as a function info: > diff --git a/test/built-ins/TypedArray/from/invoked-as-method.js b/test/built-ins/TypedArray/from/invoked-as-method.js index a40f5299b1399cc760e2ba70cc352ab6d34783d5..ca880ec2596bbe7f75ef281524fe776698a87bc3 100644 --- a/test/built-ins/TypedArray/from/invoked-as-method.js +++ b/test/built-ins/TypedArray/from/invoked-as-method.js @@ -1,29 +1,19 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 22.2.2.1 +id: sec-%typedarray%.from description: > "from" cannot be invoked as a method of %TypedArray% info: > 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) ... - 6. Return TypedArrayFrom(C, source, f, t). - - 22.2.2.1.1 Runtime Semantics: TypedArrayFrom( constructor, items, mapfn, - thisArg ) - + 8. Let targetObj be ? TypedArrayCreate(C, «len»). ... - 8. If usingIterator is not undefined, then - ... - g. Let targetObj be AllocateTypedArray(C, len). - h. ReturnIfAbrupt(targetObj). - ... - 22.2.1.2.1 Runtime Semantics: AllocateTypedArray (newTarget, length ) + 22.2.4.6 TypedArrayCreate ( constructor, argumentList ) - ... - 2. If SameValue(%TypedArray%, newTarget) is true, throw a TypeError exception. + 1. Let newTypedArray be ? Construct(constructor, argumentList). ... includes: [testTypedArray.js] ---*/ diff --git a/test/built-ins/TypedArray/from/iter-access-error.js b/test/built-ins/TypedArray/from/iter-access-error.js index 503ca0b1314c7ec3c7d1992bbf3ea6cee59670e4..036be68b67409b4aa1b3ed3747c0babf5674847a 100644 --- a/test/built-ins/TypedArray/from/iter-access-error.js +++ b/test/built-ins/TypedArray/from/iter-access-error.js @@ -1,15 +1,18 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 22.2.2.1.1 +id: sec-%typedarray%.from description: Returns error produced by accessing @@iterator info: > - 22.2.2.1.1 Runtime Semantics: TypedArrayFrom( constructor, items, mapfn, - thisArg ) + 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) ... - 6. Let usingIterator be GetMethod(items, @@iterator). - 7. ReturnIfAbrupt(usingIterator). + 6. Let arrayLike be ? IterableToArrayLike(source). + ... + + 22.2.2.1.1 Runtime Semantics: IterableToArrayLike( items ) + + 1. Let usingIterator be ? GetMethod(items, @@iterator). ... features: [Symbol.iterator] includes: [testTypedArray.js] diff --git a/test/built-ins/TypedArray/from/iter-invoke-error.js b/test/built-ins/TypedArray/from/iter-invoke-error.js index b846a377995d403e5ab6aafb9033b6691a87ceed..40f4088dc3ed7a190ff3f27dd69fa4ed53fdb5e2 100644 --- a/test/built-ins/TypedArray/from/iter-invoke-error.js +++ b/test/built-ins/TypedArray/from/iter-invoke-error.js @@ -1,16 +1,20 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 22.2.2.1.1 +id: sec-%typedarray%.from description: Returns error produced by invoking @@iterator info: > - 22.2.2.1.1 Runtime Semantics: TypedArrayFrom( constructor, items, mapfn, - thisArg ) + 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) ... - 8. If usingIterator is not undefined, then - a. Let iterator be GetIterator(items, usingIterator). - b. ReturnIfAbrupt(iterator). + 6. Let arrayLike be ? IterableToArrayLike(source). + ... + + 22.2.2.1.1 Runtime Semantics: IterableToArrayLike( items ) + + 1. Let usingIterator be ? GetMethod(items, @@iterator). + 2. If usingIterator is not undefined, then + a. Let iterator be ? GetIterator(items, usingIterator). ... features: [Symbol.iterator] includes: [testTypedArray.js] diff --git a/test/built-ins/TypedArray/from/iter-next-error.js b/test/built-ins/TypedArray/from/iter-next-error.js index 014e26b9c86b9255b3bc37dbadcc6ede32b480db..45ea827b7aebafd625810a36a0844735a9a25b77 100644 --- a/test/built-ins/TypedArray/from/iter-next-error.js +++ b/test/built-ins/TypedArray/from/iter-next-error.js @@ -1,19 +1,16 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 22.2.2.1.1 +id: sec-%typedarray%.from description: Returns error produced by advancing the iterator info: > - 22.2.2.1.1 Runtime Semantics: TypedArrayFrom( constructor, items, mapfn, - thisArg ) + 22.2.2.1.1 Runtime Semantics: IterableToArrayLike( items ) - ... - 8. If usingIterator is not undefined, then - ... - e. Repeat, while next is not false - i. Let next be IteratorStep(iterator). - ii. ReturnIfAbrupt(next). + 2. If usingIterator is not undefined, then ... + d. Repeat, while next is not false + i. Let next be ? IteratorStep(iterator). + ... features: [Symbol.iterator] includes: [testTypedArray.js] ---*/ diff --git a/test/built-ins/TypedArray/from/iter-next-value-error.js b/test/built-ins/TypedArray/from/iter-next-value-error.js index 8081dc9830ca4895a890f8be025bd6ddd8960f33..8d0a4d82151c43cb406c86050d0c28e1026b7241 100644 --- a/test/built-ins/TypedArray/from/iter-next-value-error.js +++ b/test/built-ins/TypedArray/from/iter-next-value-error.js @@ -1,18 +1,18 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 22.2.2.1.1 +id: sec-%typedarray%.from description: Returns error produced by accessing iterated value info: > - 22.2.2.1.1 Runtime Semantics: TypedArrayFrom( constructor, items, mapfn, - thisArg ) + 22.2.2.1.1 Runtime Semantics: IterableToArrayLike( items ) - ... - 8. If usingIterator is not undefined, then + 2. If usingIterator is not undefined, then ... - e. If next is not false, then - i. Let nextValue be IteratorValue(next). - ii. ReturnIfAbrupt(nextValue). + d. Repeat, while next is not false + ... + ii. If next is not false, then + 1. Let nextValue be ? IteratorValue(next). + ... features: [Symbol.iterator] includes: [testTypedArray.js] ---*/ diff --git a/test/built-ins/TypedArray/from/length.js b/test/built-ins/TypedArray/from/length.js index f01edd4d04a0f031e073d2230a078989afab8b4a..a6c95808f5fa3a16ca171c683310b9e2306bfd73 100755 --- a/test/built-ins/TypedArray/from/length.js +++ b/test/built-ins/TypedArray/from/length.js @@ -2,23 +2,24 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 22.2.2.1 +id: sec-%typedarray%.from description: > %TypedArray%.from.length is 1. info: > %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) 17 ECMAScript Standard Built-in Objects: - Every built-in Function object, including constructors, has a length - property whose value is an integer. Unless otherwise specified, this - value is equal to the largest number of named arguments shown in the - subclause headings for the function description, including optional - parameters. However, rest parameters shown using the form “...name†- are not included in the default argument count. - Unless otherwise specified, the length property of a built-in Function - object has the attributes { [[Writable]]: false, [[Enumerable]]: false, - [[Configurable]]: true }. + Every built-in Function object, including constructors, has a length property + whose value is an integer. Unless otherwise specified, this value is equal to + the largest number of named arguments shown in the subclause headings for the + function description. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are shown using the form «...name») are not + included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function object + has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. includes: [propertyHelper.js, testTypedArray.js] ---*/ diff --git a/test/built-ins/TypedArray/from/mapfn-is-not-callable.js b/test/built-ins/TypedArray/from/mapfn-is-not-callable.js new file mode 100644 index 0000000000000000000000000000000000000000..76fb375ce1c77c1cd72e55f44149d7907e1252f1 --- /dev/null +++ b/test/built-ins/TypedArray/from/mapfn-is-not-callable.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-%typedarray%.from +description: Throw a TypeError exception is mapfn is not callable +info: > + 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 3. If mapfn was supplied and mapfn is not undefined, then + a. If IsCallable(mapfn) is false, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol.iterator] +---*/ + +var arrayLike = {}; +Object.defineProperty(arrayLike, Symbol.iterator, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(TypeError, function() { + TypedArray.from(arrayLike, 42); +}); diff --git a/test/built-ins/TypedArray/from/this-is-not-constructor.js b/test/built-ins/TypedArray/from/this-is-not-constructor.js new file mode 100644 index 0000000000000000000000000000000000000000..799d50a99c850450776d4bc3457757b3cc94304b --- /dev/null +++ b/test/built-ins/TypedArray/from/this-is-not-constructor.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-%typedarray%.from +description: > + Throws a TypeError exception if this is not a constructor +info: > + 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + 1. Let C be the this value. + 2. If IsConstructor(C) is false, throw a TypeError exception. + ... +includes: [testTypedArray.js] +---*/ + +var from = TypedArray.from; +var m = { m() {} }.m; + +assert.throws(TypeError, function() { + from.call(o.m, []); +}); diff --git a/test/built-ins/TypedArray/of/invoked-as-method.js b/test/built-ins/TypedArray/of/invoked-as-method.js index cb0f30b634ead1a813bfd2df2da3e1791efe18d7..71ad8c195f68ee4cc7f17cd326d0f599c840eade 100644 --- a/test/built-ins/TypedArray/of/invoked-as-method.js +++ b/test/built-ins/TypedArray/of/invoked-as-method.js @@ -1,21 +1,19 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 22.2.2.2 +id: sec-%typedarray%.of description: > "of" cannot be invoked as a method of %TypedArray% info: > 22.2.2.2 %TypedArray%.of ( ...items ) ... - 5. Let newObj be AllocateTypedArray(C, len). - 6. ReturnIfAbrupt(newObj). + 5. Let newObj be ? TypedArrayCreate(C, «len»). ... - 22.2.1.2.1 Runtime Semantics: AllocateTypedArray (newTarget, length ) + 22.2.4.6 TypedArrayCreate ( constructor, argumentList ) - ... - 2. If SameValue(%TypedArray%, newTarget) is true, throw a TypeError exception. + 1. Let newTypedArray be ? Construct(constructor, argumentList). ... includes: [testTypedArray.js] ---*/ diff --git a/test/built-ins/TypedArray/of/length.js b/test/built-ins/TypedArray/of/length.js index 22142c18df033d0369428496c672f22ac8024a51..ffe86c0c68d98e58630dc301bd48d001bb7e5425 100755 --- a/test/built-ins/TypedArray/of/length.js +++ b/test/built-ins/TypedArray/of/length.js @@ -2,23 +2,24 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 22.2.2.2 +id: sec-%typedarray%-of description: > %TypedArray%.of.length is 0. info: > %TypedArray%.of ( ...items ) 17 ECMAScript Standard Built-in Objects: - Every built-in Function object, including constructors, has a length - property whose value is an integer. Unless otherwise specified, this - value is equal to the largest number of named arguments shown in the - subclause headings for the function description, including optional - parameters. However, rest parameters shown using the form “...name†- are not included in the default argument count. - Unless otherwise specified, the length property of a built-in Function - object has the attributes { [[Writable]]: false, [[Enumerable]]: false, - [[Configurable]]: true }. + Every built-in Function object, including constructors, has a length property + whose value is an integer. Unless otherwise specified, this value is equal to + the largest number of named arguments shown in the subclause headings for the + function description. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are shown using the form «...name») are not + included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function object + has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. includes: [propertyHelper.js, testTypedArray.js] ---*/ diff --git a/test/built-ins/TypedArray/of/this-is-not-constructor.js b/test/built-ins/TypedArray/of/this-is-not-constructor.js new file mode 100644 index 0000000000000000000000000000000000000000..ff716ddac42dbd5c4b45ae46f8004319410c6f6d --- /dev/null +++ b/test/built-ins/TypedArray/of/this-is-not-constructor.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-%typedarray%.of +description: > + Throws a TypeError exception if this is not a constructor +info: > + 22.2.2.2 %TypedArray%.of ( ...items ) + + ... + 3. Let C be the this value. + 4. If IsConstructor(C) is false, throw a TypeError exception. + ... +includes: [testTypedArray.js] +---*/ + +var o = { + m() {} +}; + +assert.throws(TypeError, function() { + TypedArray.of.call(o.m, []); +});