Update tests for %TypedArray%.from and of

This commit is contained in:
Leonardo Balter 2016-02-03 11:43:20 -02:00 committed by Gorkem Yakin
parent 02cbd01bfb
commit 35dce20ec4
14 changed files with 144 additions and 81 deletions

View File

@ -1,21 +1,20 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 description: Returns error produced by accessing array-like's length
info: > 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")). 7. Let len be ? ToLength(? Get(arrayLike, "length")).
13. ReturnIfAbrupt(len).
... ...
includes: [testTypedArray.js] includes: [testTypedArray.js]
---*/ ---*/
var arrayLike = {}; var arrayLike = {};
Object.defineProperty(arrayLike, 'length', { Object.defineProperty(arrayLike, "length", {
get: function() { get: function() {
throw new Test262Error(); throw new Test262Error();
} }

View File

@ -1,23 +1,23 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 description: Returns error produced by interpreting length property as a length
info: > 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")). 7. Let len be ? ToLength(? Get(arrayLike, "length")).
13. ReturnIfAbrupt(len).
... ...
features: [Symbol.toPrimitive]
includes: [testTypedArray.js] includes: [testTypedArray.js]
---*/ ---*/
var arrayLike = { length: {} }; var arrayLike = { length: {} };
arrayLike.length[Symbol.toPrimitive] = function() { arrayLike.length = {
valueOf: function() {
throw new Test262Error(); throw new Test262Error();
}
}; };
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 22.2.2.1 id: sec-%typedarray%.from
description: > description: >
"from" cannot be invoked as a function "from" cannot be invoked as a function
info: > info: >

View File

@ -1,29 +1,19 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 22.2.2.1 id: sec-%typedarray%.from
description: > description: >
"from" cannot be invoked as a method of %TypedArray% "from" cannot be invoked as a method of %TypedArray%
info: > info: >
22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
... ...
6. Return TypedArrayFrom(C, source, f, t). 8. Let targetObj be ? TypedArrayCreate(C, «len»).
22.2.2.1.1 Runtime Semantics: TypedArrayFrom( constructor, items, mapfn,
thisArg )
...
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 )
... 1. Let newTypedArray be ? Construct(constructor, argumentList).
2. If SameValue(%TypedArray%, newTarget) is true, throw a TypeError exception.
... ...
includes: [testTypedArray.js] includes: [testTypedArray.js]
---*/ ---*/

View File

@ -1,15 +1,18 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 description: Returns error produced by accessing @@iterator
info: > info: >
22.2.2.1.1 Runtime Semantics: TypedArrayFrom( constructor, items, mapfn, 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
thisArg )
... ...
6. Let usingIterator be GetMethod(items, @@iterator). 6. Let arrayLike be ? IterableToArrayLike(source).
7. ReturnIfAbrupt(usingIterator). ...
22.2.2.1.1 Runtime Semantics: IterableToArrayLike( items )
1. Let usingIterator be ? GetMethod(items, @@iterator).
... ...
features: [Symbol.iterator] features: [Symbol.iterator]
includes: [testTypedArray.js] includes: [testTypedArray.js]

View File

@ -1,16 +1,20 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 description: Returns error produced by invoking @@iterator
info: > info: >
22.2.2.1.1 Runtime Semantics: TypedArrayFrom( constructor, items, mapfn, 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
thisArg )
... ...
8. If usingIterator is not undefined, then 6. Let arrayLike be ? IterableToArrayLike(source).
a. Let iterator be GetIterator(items, usingIterator). ...
b. ReturnIfAbrupt(iterator).
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] features: [Symbol.iterator]
includes: [testTypedArray.js] includes: [testTypedArray.js]

View File

@ -1,18 +1,15 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 description: Returns error produced by advancing the iterator
info: > info: >
22.2.2.1.1 Runtime Semantics: TypedArrayFrom( constructor, items, mapfn, 22.2.2.1.1 Runtime Semantics: IterableToArrayLike( items )
thisArg )
2. If usingIterator is not undefined, then
... ...
8. If usingIterator is not undefined, then d. Repeat, while next is not false
... i. Let next be ? IteratorStep(iterator).
e. Repeat, while next is not false
i. Let next be IteratorStep(iterator).
ii. ReturnIfAbrupt(next).
... ...
features: [Symbol.iterator] features: [Symbol.iterator]
includes: [testTypedArray.js] includes: [testTypedArray.js]

View File

@ -1,18 +1,18 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 description: Returns error produced by accessing iterated value
info: > info: >
22.2.2.1.1 Runtime Semantics: TypedArrayFrom( constructor, items, mapfn, 22.2.2.1.1 Runtime Semantics: IterableToArrayLike( items )
thisArg )
2. If usingIterator is not undefined, then
... ...
8. If usingIterator is not undefined, then d. Repeat, while next is not false
...
ii. If next is not false, then
1. Let nextValue be ? IteratorValue(next).
... ...
e. If next is not false, then
i. Let nextValue be IteratorValue(next).
ii. ReturnIfAbrupt(nextValue).
features: [Symbol.iterator] features: [Symbol.iterator]
includes: [testTypedArray.js] includes: [testTypedArray.js]
---*/ ---*/

View File

@ -2,22 +2,23 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 22.2.2.1 id: sec-%typedarray%.from
description: > description: >
%TypedArray%.from.length is 1. %TypedArray%.from.length is 1.
info: > info: >
%TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
17 ECMAScript Standard Built-in Objects: 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 Every built-in Function object, including constructors, has a length property
object has the attributes { [[Writable]]: false, [[Enumerable]]: false, 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 }. [[Configurable]]: true }.
includes: [propertyHelper.js, testTypedArray.js] includes: [propertyHelper.js, testTypedArray.js]
---*/ ---*/

View File

@ -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);
});

View File

@ -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, []);
});

View File

@ -1,21 +1,19 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 22.2.2.2 id: sec-%typedarray%.of
description: > description: >
"of" cannot be invoked as a method of %TypedArray% "of" cannot be invoked as a method of %TypedArray%
info: > info: >
22.2.2.2 %TypedArray%.of ( ...items ) 22.2.2.2 %TypedArray%.of ( ...items )
... ...
5. Let newObj be AllocateTypedArray(C, len). 5. Let newObj be ? TypedArrayCreate(C, «len»).
6. ReturnIfAbrupt(newObj).
... ...
22.2.1.2.1 Runtime Semantics: AllocateTypedArray (newTarget, length ) 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
... 1. Let newTypedArray be ? Construct(constructor, argumentList).
2. If SameValue(%TypedArray%, newTarget) is true, throw a TypeError exception.
... ...
includes: [testTypedArray.js] includes: [testTypedArray.js]
---*/ ---*/

View File

@ -2,22 +2,23 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 22.2.2.2 id: sec-%typedarray%-of
description: > description: >
%TypedArray%.of.length is 0. %TypedArray%.of.length is 0.
info: > info: >
%TypedArray%.of ( ...items ) %TypedArray%.of ( ...items )
17 ECMAScript Standard Built-in Objects: 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 Every built-in Function object, including constructors, has a length property
object has the attributes { [[Writable]]: false, [[Enumerable]]: false, 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 }. [[Configurable]]: true }.
includes: [propertyHelper.js, testTypedArray.js] includes: [propertyHelper.js, testTypedArray.js]
---*/ ---*/

View File

@ -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, []);
});