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.
// 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();
}

View File

@ -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() {

View File

@ -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: >

View File

@ -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]
---*/

View File

@ -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]

View File

@ -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]

View File

@ -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 )
2. If usingIterator is not undefined, then
...
d. Repeat, while next is not false
i. Let next be ? IteratorStep(iterator).
...
8. If usingIterator is not undefined, then
...
e. Repeat, while next is not false
i. Let next be IteratorStep(iterator).
ii. ReturnIfAbrupt(next).
...
features: [Symbol.iterator]
includes: [testTypedArray.js]
---*/

View File

@ -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]
---*/

View File

@ -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]
---*/

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.
// 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]
---*/

View File

@ -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]
---*/

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