asyncHelpers-throwsAsync-null.js (806B)
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 Thenables that reject with the `null` value do not satisfy the assertion. 7 flags: [async] 8 includes: [asyncHelpers.js] 9 ---*/ 10 11 asyncTest(async function () { 12 var caught = false; 13 14 const p = assert.throwsAsync(Error, async function () { 15 throw null; 16 }); 17 assert(p instanceof Promise); 18 try { 19 await p; 20 } catch (err) { 21 caught = true; 22 assert.sameValue( 23 err.constructor, 24 Test262Error, 25 "Expected a Test262Error, but a '" + 26 err.constructor.name + 27 "' was thrown." 28 ); 29 } finally { 30 assert( 31 caught, 32 "assert.throwsAsync did not reject when null was thrown" 33 ); 34 } 35 });