harness/asyncHelpers.js: Isolate assert.throwsAsync failure conditions

This commit is contained in:
Richard Gibson 2024-05-19 13:26:31 -04:00
parent b22b500f24
commit 0631e2111b

View File

@ -63,6 +63,13 @@ assert.throwsAsync = function (expectedErrorConstructor, func, message) {
} }
try { try {
innerThenable = func(); innerThenable = func();
} catch (thrown) {
message +=
"Expected a " +
expectedErrorConstructor.name +
" to be thrown asynchronously but an exception was thrown synchronously while obtaining the inner promise";
throw new Test262Error(message);
}
if ( if (
innerThenable === null || innerThenable === null ||
typeof innerThenable !== "object" || typeof innerThenable !== "object" ||
@ -74,13 +81,6 @@ assert.throwsAsync = function (expectedErrorConstructor, func, message) {
" but result was not a thenable"; " but result was not a thenable";
throw new Test262Error(message); throw new Test262Error(message);
} }
} catch (thrown) {
message +=
"Expected a " +
expectedErrorConstructor.name +
" to be thrown asynchronously but an exception was thrown synchronously while obtaining the inner promise";
throw new Test262Error(message);
}
try { try {
resolve(innerThenable.then( resolve(innerThenable.then(