this-non-constructor.js (1302B)
1 // |reftest| async 2 // Copyright (C) 2023 Igalia, S.L. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-array.fromasync 7 description: > 8 Constructs an intrinsic Array if this-value is not a constructor, and length 9 and element properties are set accordingly. 10 info: | 11 3.e. If IsConstructor(_C_) is *true*, then 12 ... 13 f. Else, 14 i. Let _A_ be ! ArrayCreate(0). 15 16 ... 17 j. If _iteratorRecord_ is not *undefined*, then 18 ... 19 k. Else, 20 ... 21 iv. If IsConstructor(_C_) is *true*, then 22 ... 23 v. Else, 24 1. Let _A_ be ? ArrayCreate(_len_). 25 includes: [compareArray.js, asyncHelpers.js] 26 flags: [async] 27 features: [Array.fromAsync] 28 ---*/ 29 30 asyncTest(async function () { 31 const thisValue = { 32 length: 4000, 33 0: 32, 34 1: 64, 35 2: 128 36 }; 37 38 let result = await Array.fromAsync.call(thisValue, [1, 2]); 39 assert(Array.isArray(result), "result is an intrinsic Array"); 40 assert.compareArray(result, [1, 2], "result is not disrupted by properties of this-value"); 41 42 result = await Array.fromAsync.call(thisValue, { 43 length: 2, 44 0: 1, 45 1: 2 46 }); 47 assert(Array.isArray(result), "result is an intrinsic Array"); 48 assert.compareArray(result, [1, 2], "result is not disrupted by properties of this-value"); 49 });