Debian Codegraph @

js/src/tests/test262/built-ins/Promise/try/throws.js

raw
1 // |reftest| shell-option(--enable-promise-try) skip-if(!Promise.try||!xulRuntime.shell) async -- promise-try is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2024 Jordan Harband. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 description: Promise.try returns a Promise that rejects when the function throws
7 esid: sec-promise.try
8 features: [promise-try]
9 flags: [async]
10 includes: [asyncHelpers.js]
11 ---*/
12
13 asyncTest(function () {
14 return assert.throwsAsync(
15 Test262Error,
16 function () {
17 return Promise.try(function () { throw new Test262Error(); })
18 },
19 "error thrown from callback must become a rejection"
20 );
21 });