mirror of https://github.com/tc39/test262.git
harness/asyncHelpers.js: Refactor assert.throwsAsync to be async function
This commit is contained in:
parent
0294bea997
commit
98952c3c51
|
@ -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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue