summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-is-null-as-array-like.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-is-null-as-array-like.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-is-null-as-array-like.js')
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-is-null-as-array-like.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-is-null-as-array-like.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-is-null-as-array-like.js
new file mode 100644
index 0000000000..de906f06b4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-is-null-as-array-like.js
@@ -0,0 +1,44 @@
+// 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);
+});
+
+reportCompare(0, 0);