summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/harness/asyncHelpers-asyncTest-without-async-flag.js
blob: b7b0e4f733fb0197cb6f5d6f8952cf7152741712 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: |
    The 'asyncTest' helper checks that it is called with the 'async' flag.
includes: [asyncHelpers.js]
---*/
function makePromise() {
  return {
    then(res, rej) {
      // Throw a different error than Test262Error to avoid confusion about what is rejecting
      throw new Error("Should not be evaluated");
    },
  };
}
assert(
  !Object.hasOwn(globalThis, "$DONE"),
  "Without 'async' flag, $DONE should not be defined"
);
assert.throws(Test262Error, function () {
  asyncTest(makePromise);
});

reportCompare(0, 0);