// GENERATED, DO NOT EDIT // file: asyncHelpers.js // Copyright (C) 2022 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- description:| Acollectionofassertionandwrapperfunctionsfortestingasynchronousbuilt-ins. defines:[asyncTest,assert.throwsAsync]
---*/
/** *Definesthe**sole**asynchronoustestofafile. *@see{@link../docs/rfcs/async-helpers.md}forbackground. * *@param{Function}testFuncacallbackwhosereturnedpromiseindicatestestresults *(fulfillmentforsuccess,rejectionforfailure) *@returns{void}
*/ function asyncTest(testFunc) { if (!Object.prototype.hasOwnProperty.call(globalThis, "$DONE")) { thrownew Test262Error("asyncTest called without async flag");
} if (typeof testFunc !== "function") {
$DONE(new Test262Error("asyncTest called with non-function argument")); return;
} try {
testFunc().then( function () {
$DONE();
}, function (error) {
$DONE(error);
}
);
} catch (syncError) {
$DONE(syncError);
}
}
/** *Assertsthatacallbackasynchronouslythrowsaninstanceofaparticular *error(i.e.,returnsapromisewhoserejectionvalueisanobjectreferencing *theconstructor). * *@param{Function}expectedErrorConstructortheexpectedconstructorofthe *rejectionvalue *@param{Function}functhecallback *@param{string}[message]theprefixtouseforfailuremessages *@returns{Promise<void>}fulfillsiftheexpectederroristhrown, *otherwiserejects
*/ assert.throwsAsync = function (expectedErrorConstructor, func, message) { returnnew Promise(function (resolve) { var fail = function (detail) { if (message === undefined) { thrownew Test262Error(detail);
} thrownew Test262Error(message + " " + detail);
}; if (typeof expectedErrorConstructor !== "function") {
fail("assert.throwsAsync called with an argument that is not an error constructor");
} if (typeof func !== "function") {
fail("assert.throwsAsync called with an argument that is not a function");
} var expectedName = expectedErrorConstructor.name; var expectation = "Expected a " + expectedName + " to be thrown asynchronously"; var res; try {
res = func();
} catch (thrown) {
fail(expectation + " but the function threw synchronously");
} if (res === null || typeof res !== "object" || typeof res.then !== "function") {
fail(expectation + " but result was not a thenable");
} var onResFulfilled, onResRejected; var resSettlementP = new Promise(function (onFulfilled, onRejected) {
onResFulfilled = onFulfilled;
onResRejected = onRejected;
}); try {
res.then(onResFulfilled, onResRejected)
} catch (thrown) {
fail(expectation + " but .then threw synchronously");
}
resolve(resSettlementP.then( function () {
fail(expectation + " but no exception was thrown at all");
}, function (thrown) { var actualName; if (thrown === null || typeof thrown !== "object") {
fail(expectation + " but thrown value was not an object");
} elseif (thrown.constructor !== expectedErrorConstructor) {
actualName = thrown.constructor.name; if (expectedName === actualName) {
fail(expectation + " but got a different error constructor with the same name");
}
fail(expectation + " but got a " + actualName);
}
}
));
});
};
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.9 Sekunden
(vorverarbeitet am 2026-09-30)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.