Debian Codegraph @

js/src/tests/test262/harness/asyncHelpers-asyncTest-returns-undefined.js

raw
1 // |reftest| async
2 // Copyright (C) 2022 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 description: |
6 The 'asyncTest' helper when called with async flag always returns undefined.
7 flags: [async]
8 includes: [asyncHelpers.js]
9 ---*/
10 var realDone = $DONE;
11 var doneCalls = 0;
12 globalThis.$DONE = function () {
13 doneCalls++;
14 };
15
16 (async function () {
17 assert.sameValue(undefined, asyncTest({}));
18 assert.sameValue(
19 undefined,
20 asyncTest(function () {
21 return "non-thenable";
22 })
23 );
24 assert.sameValue(
25 undefined,
26 asyncTest(function () {
27 return Promise.resolve(true);
28 })
29 );
30 assert.sameValue(
31 undefined,
32 asyncTest(function () {
33 return Promise.reject(new Test262Error("oh no"));
34 })
35 );
36 })()
37 .then(() => {
38 assert.sameValue(doneCalls, 4, "asyncTest must call $DONE");
39 })
40 .then(realDone, realDone);