3 // Copyright (C) 2022 Igalia, S.L. All rights reserved.
4 // This code is governed by the BSD license found in the LICENSE file.
7 esid: sec-array.fromasync
9 If thisArg is a primitive, mapfn is called with it as the this-value in strict
12 6. If _mapping_ is *true*, then
13 a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »).
15 In OrdinaryCallBindThis, _thisArgument_ is always bound as the this-value in
16 strict mode (_F_.[[ThisMode]] is ~strict~, where _F_ is the function object.)
17 flags: [async, onlyStrict]
18 includes: [asyncHelpers.js]
19 features: [Array.fromAsync]
22 asyncTest(async () => {
23 await Array.fromAsync([1, 2, 3], async function () {
24 assert.sameValue(this, undefined, "undefined thisArg should be bound as the this-value of mapfn");
27 await Array.fromAsync([1, 2, 3], async function () {
28 assert.sameValue(this, null, "null thisArg should be bound as the this-value of mapfn");
31 await Array.fromAsync([1, 2, 3], async function () {
32 assert.sameValue(this, "string", "string thisArg should be bound as the this-value of mapfn");
35 await Array.fromAsync([1, 2, 3], async function () {
36 assert.sameValue(this, 3.1416, "number thisArg should be bound as the this-value of mapfn");
39 await Array.fromAsync([1, 2, 3], async function () {
40 assert.sameValue(this, 42n, "bigint thisArg should be bound as the this-value of mapfn");
43 await Array.fromAsync([1, 2, 3], async function () {
44 assert.sameValue(this, true, "boolean thisArg should be bound as the this-value of mapfn");
47 const symbolThis = Symbol("symbol");
48 await Array.fromAsync([1, 2, 3], async function () {
49 assert.sameValue(this, symbolThis, "symbol thisArg should be bound as the this-value of mapfn");