mirror of
https://github.com/tc39/test262.git
synced 2025-07-29 08:54:35 +02:00
Add TypedArrayConstructors test
This commit is contained in:
parent
02013fd1d6
commit
919415704b
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-typedarray-object
|
||||||
|
description: >
|
||||||
|
If object's @@iterator is `null`, it is considered an array-like object.
|
||||||
|
info: |
|
||||||
|
TypedArray ( object )
|
||||||
|
|
||||||
|
This description applies only if the TypedArray function is called with at
|
||||||
|
least one argument and the Type of the first argument is Object and that
|
||||||
|
object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
|
||||||
|
internal slot.
|
||||||
|
|
||||||
|
[...]
|
||||||
|
5. Let usingIterator be ? GetMethod(object, @@iterator).
|
||||||
|
6. If usingIterator is not undefined, then
|
||||||
|
[...]
|
||||||
|
7. NOTE: object is not an Iterable so assume it is already an array-like object.
|
||||||
|
[...]
|
||||||
|
|
||||||
|
GetMethod ( V, P )
|
||||||
|
|
||||||
|
[...]
|
||||||
|
2. Let func be ? GetV(V, P).
|
||||||
|
3. If func is either undefined or null, return undefined.
|
||||||
|
includes: [testTypedArray.js]
|
||||||
|
features: [Symbol.iterator, TypedArray]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var obj = {length: 2, 0: 1, 1: 2};
|
||||||
|
obj[Symbol.iterator] = null;
|
||||||
|
|
||||||
|
testWithTypedArrayConstructors(function(TypedArray) {
|
||||||
|
var typedArray = new TypedArray(obj);
|
||||||
|
|
||||||
|
assert(typedArray instanceof TypedArray);
|
||||||
|
assert.sameValue(typedArray.length, 2);
|
||||||
|
assert.sameValue(typedArray[0], 1);
|
||||||
|
assert.sameValue(typedArray[1], 2);
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user