harness/asyncHelpers.js: Refactor assert.throwsAsync to fail fast

This commit is contained in:
Richard Gibson 2024-05-19 13:18:45 -04:00
parent 1b34a1c484
commit b22b500f24

View File

@ -56,7 +56,11 @@ assert.throwsAsync = function (expectedErrorConstructor, func, message) {
} else {
message += " ";
}
if (typeof func === "function") {
if (typeof func !== "function") {
message +=
"assert.throwsAsync called with an argument that is not a function";
throw new Test262Error(message);
}
try {
innerThenable = func();
if (
@ -77,11 +81,6 @@ 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);
}
} else {
message +=
"assert.throwsAsync called with an argument that is not a function";
throw new Test262Error(message);
}
try {
resolve(innerThenable.then(