1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// |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: Array.fromAsync returns a Promise
info: |
5. Return _promiseCapability_.[[Promise]].
flags: [async]
includes: [asyncHelpers.js]
features: [Array.fromAsync]
---*/
asyncTest(async function () {
let p = Array.fromAsync([0, 1, 2]);
assert(p instanceof Promise, "Array.fromAsync returns a Promise");
assert.sameValue(
Object.getPrototypeOf(p),
Promise.prototype,
"Array.fromAsync returns an object with prototype Promise.prototype"
);
p = Array.fromAsync([0, 1, 2], () => {
throw new Test262Error("this will make the Promise reject");
})
assert(p instanceof Promise, "Array.fromAsync returns a Promise even on error");
assert.sameValue(
Object.getPrototypeOf(p),
Promise.prototype,
"Array.fromAsync returns an object with prototype Promise.prototype even on error"
);
await assert.throwsAsync(Test262Error, () => p, "Prevent unhandled rejection");
});
|