throws.js (563B)
1 // |reftest| async 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 });