harness/asyncHelpers.js: Refactor assert.throwsAsync to be async function

This commit is contained in:
Cam Tenny 2022-12-05 12:29:43 -08:00 committed by Philip Chimento
parent 0294bea997
commit 98952c3c51
1 changed files with 5 additions and 5 deletions

View File

@ -29,7 +29,7 @@ function asyncTest(testFunc) {
} }
} }
assert.throwsAsync = function ( assert.throwsAsync = async function (
expectedErrorConstructor, expectedErrorConstructor,
funcOrThenable, funcOrThenable,
message message
@ -52,14 +52,14 @@ assert.throwsAsync = function (
"Expected to obtain an inner promise that would reject with a" + "Expected to obtain an inner promise that would reject with a" +
expectedErrorConstructor.name + expectedErrorConstructor.name +
" but result was not a thenable"; " but result was not a thenable";
return Promise.reject(new Test262Error(message)); throw new Test262Error(message);
} }
} catch (thrown) { } catch (thrown) {
message += message +=
"Expected a " + "Expected a " +
expectedErrorConstructor.name + expectedErrorConstructor.name +
" to be thrown asynchronously but an exception was thrown synchronously while obtaining the inner promise"; " to be thrown asynchronously but an exception was thrown synchronously while obtaining the inner promise";
return Promise.reject(new Test262Error(message)); throw new Test262Error(message);
} }
} else if ( } else if (
funcOrThenable === null || funcOrThenable === null ||
@ -68,7 +68,7 @@ assert.throwsAsync = function (
) { ) {
message += message +=
"assert.throwsAsync called with an argument that is neither a function nor a thenable"; "assert.throwsAsync called with an argument that is neither a function nor a thenable";
return Promise.reject(new Test262Error(message)); throw new Test262Error(message);
} else { } else {
innerThenable = funcOrThenable; innerThenable = funcOrThenable;
} }
@ -117,6 +117,6 @@ assert.throwsAsync = function (
thrown.constructor.name + thrown.constructor.name +
" was thrown synchronously"; " was thrown synchronously";
} }
return Promise.reject(new Test262Error(message)); throw new Test262Error(message);
} }
}; };