diff --git a/harness/asyncHelpers.js b/harness/asyncHelpers.js index ebc9f09ca7..5bde3d2c2c 100644 --- a/harness/asyncHelpers.js +++ b/harness/asyncHelpers.js @@ -34,20 +34,16 @@ function asyncTest(testFunc) { } } -assert.throwsAsync = async function ( - expectedErrorConstructor, - funcOrThenable, - message -) { +assert.throwsAsync = async function (expectedErrorConstructor, func, message) { var innerThenable; if (message === undefined) { message = ""; } else { message += " "; } - if (typeof funcOrThenable === "function") { + if (typeof func === "function") { try { - innerThenable = funcOrThenable(); + innerThenable = func(); if ( innerThenable === null || typeof innerThenable !== "object" || @@ -66,16 +62,10 @@ assert.throwsAsync = async function ( " to be thrown asynchronously but an exception was thrown synchronously while obtaining the inner promise"; throw new Test262Error(message); } - } else if ( - funcOrThenable === null || - typeof funcOrThenable !== "object" || - typeof funcOrThenable.then !== "function" - ) { - message += - "assert.throwsAsync called with an argument that is neither a function nor a thenable"; - throw new Test262Error(message); } else { - innerThenable = funcOrThenable; + message += + "assert.throwsAsync called with an argument that is not a function"; + throw new Test262Error(message); } try { diff --git a/test/harness/asyncHelpers-throwsAsync-custom.js b/test/harness/asyncHelpers-throwsAsync-custom.js index db009d07a1..70a3f74a38 100644 --- a/test/harness/asyncHelpers-throwsAsync-custom.js +++ b/test/harness/asyncHelpers-throwsAsync-custom.js @@ -11,7 +11,9 @@ includes: [asyncHelpers.js] function MyError() {} (async function () { - const p = assert.throwsAsync(MyError, Promise.reject(new MyError())); + const p = assert.throwsAsync(MyError, function () { + return Promise.reject(new MyError()); + }); assert(p instanceof Promise); await p; })().then($DONE, $DONE); diff --git a/test/harness/asyncHelpers-throwsAsync-incorrect-ctor.js b/test/harness/asyncHelpers-throwsAsync-incorrect-ctor.js index 7ed83e3da6..62b30b138d 100644 --- a/test/harness/asyncHelpers-throwsAsync-incorrect-ctor.js +++ b/test/harness/asyncHelpers-throwsAsync-incorrect-ctor.js @@ -11,7 +11,9 @@ includes: [asyncHelpers.js] (async function () { var caught = false; - const p = assert.throwsAsync(Error, Promise.reject(new TypeError())); + const p = assert.throwsAsync(Error, function () { + return Promise.reject(new TypeError()); + }); assert(p instanceof Promise); try { await p;