throwsAsync, Promise.try: avoid unneeded syntax

Followup to #4086
This commit is contained in:
Jordan Harband 2024-05-17 09:13:21 -07:00
parent 57c7d06bf1
commit 5217ef396e
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
2 changed files with 75 additions and 73 deletions

View File

@ -28,7 +28,8 @@ function asyncTest(testFunc) {
}
}
assert.throwsAsync = async function (expectedErrorConstructor, func, message) {
assert.throwsAsync = function (expectedErrorConstructor, func, message) {
return new Promise(function (resolve) {
var innerThenable;
if (message === undefined) {
message = "";
@ -63,7 +64,7 @@ assert.throwsAsync = async function (expectedErrorConstructor, func, message) {
}
try {
return innerThenable.then(
resolve(innerThenable.then(
function () {
message +=
"Expected a " +
@ -91,7 +92,7 @@ assert.throwsAsync = async function (expectedErrorConstructor, func, message) {
throw new Test262Error(message);
}
}
);
));
} catch (thrown) {
if (typeof thrown !== "object" || thrown === null) {
message +=
@ -108,4 +109,5 @@ assert.throwsAsync = async function (expectedErrorConstructor, func, message) {
}
throw new Test262Error(message);
}
});
};

View File

@ -9,8 +9,8 @@ flags: [async]
includes: [asyncHelpers.js]
---*/
asyncTest(async function() {
await assert.throwsAsync(
asyncTest(function () {
return assert.throwsAsync(
Test262Error,
function () {
Promise.try(function () { throw new Test262Error(); })