summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/fromAsync/this-non-constructor.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Array/fromAsync/this-non-constructor.js')
-rw-r--r--js/src/tests/test262/built-ins/Array/fromAsync/this-non-constructor.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/this-non-constructor.js b/js/src/tests/test262/built-ins/Array/fromAsync/this-non-constructor.js
new file mode 100644
index 0000000000..10934a855a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/fromAsync/this-non-constructor.js
@@ -0,0 +1,49 @@
+// |reftest| async
+// Copyright (C) 2023 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.fromasync
+description: >
+ Constructs an intrinsic Array if this-value is not a constructor, and length
+ and element properties are set accordingly.
+info: |
+ 3.e. If IsConstructor(_C_) is *true*, then
+ ...
+ f. Else,
+ i. Let _A_ be ! ArrayCreate(0).
+
+ ...
+ j. If _iteratorRecord_ is not *undefined*, then
+ ...
+ k. Else,
+ ...
+ iv. If IsConstructor(_C_) is *true*, then
+ ...
+ v. Else,
+ 1. Let _A_ be ? ArrayCreate(_len_).
+includes: [compareArray.js, asyncHelpers.js]
+flags: [async]
+features: [Array.fromAsync]
+---*/
+
+asyncTest(async function () {
+ const thisValue = {
+ length: 4000,
+ 0: 32,
+ 1: 64,
+ 2: 128
+ };
+
+ let result = await Array.fromAsync.call(thisValue, [1, 2]);
+ assert(Array.isArray(result), "result is an intrinsic Array");
+ assert.compareArray(result, [1, 2], "result is not disrupted by properties of this-value");
+
+ result = await Array.fromAsync.call(thisValue, {
+ length: 2,
+ 0: 1,
+ 1: 2
+ });
+ assert(Array.isArray(result), "result is an intrinsic Array");
+ assert.compareArray(result, [1, 2], "result is not disrupted by properties of this-value");
+});