From 1b34a1c4847ef7b01a3899faed70729159b6002f Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Sun, 19 May 2024 12:43:58 -0400 Subject: [PATCH] harness/asyncHelpers.js: Add doc comments --- harness/asyncHelpers.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/harness/asyncHelpers.js b/harness/asyncHelpers.js index c8e58457fc..e7eac06a68 100644 --- a/harness/asyncHelpers.js +++ b/harness/asyncHelpers.js @@ -6,6 +6,14 @@ description: | defines: [asyncTest] ---*/ +/** + * Defines the **sole** asynchronous test of a file. + * @see {@link ../docs/rfcs/async-helpers.md} for background. + * + * @param {Function} testFunc a callback whose returned promise indicates test results + * (fulfillment for success, rejection for failure) + * @returns {void} + */ function asyncTest(testFunc) { if (!Object.hasOwn(globalThis, "$DONE")) { throw new Test262Error("asyncTest called without async flag"); @@ -28,6 +36,18 @@ function asyncTest(testFunc) { } } +/** + * Asserts that a callback asynchronously throws an instance of a particular + * error (i.e., returns a promise whose rejection value is an object referencing + * the constructor). + * + * @param {Function} expectedErrorConstructor the expected constructor of the + * rejection value + * @param {Function} func the callback + * @param {string} [message] the prefix to use for failure messages + * @returns {Promise} fulfills if the expected error is thrown, + * otherwise rejects + */ assert.throwsAsync = function (expectedErrorConstructor, func, message) { return new Promise(function (resolve) { var innerThenable;