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
1 changed files with 11 additions and 11 deletions

View File

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