js-on-sx: harness $DONE/asyncTest/checkSequence stubs
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 33s

This commit is contained in:
2026-05-08 20:11:34 +00:00
parent 1bff28e99e
commit ecae58316f
2 changed files with 36 additions and 0 deletions

View File

@@ -146,6 +146,40 @@ var isConstructor = function (f) {
// Best-effort: built-in functions and arrows aren't; declared `function` decls are.
return false;
};
// $DONE / asyncTest — async-flag tests call $DONE(err) to signal completion.
// Since we drain microtasks synchronously, $DONE is just a final-assertion sink.
var $DONE = function (err) {
if (err) { throw new Test262Error((err && err.message) || err); }
};
var asyncTest = function (testFunc) {
Promise.resolve(testFunc()).then(function () { $DONE(); }, function (e) { $DONE(e); });
};
// promiseHelper.js include — used by Promise.all/race tests for ordering checks.
var checkSequence = function (arr, message) {
for (var i = 0; i < arr.length; i = i + 1) {
if (arr[i] !== (i + 1)) {
throw new Test262Error((message || "Sequence") + " expected " + (i+1) + " at index " + i + " but got " + arr[i]);
}
}
return true;
};
var checkSettledPromises = function (settleds, expected, message) {
var msg = message ? message + " " : "";
if (settleds.length !== expected.length) {
throw new Test262Error(msg + "lengths differ: " + settleds.length + " vs " + expected.length);
}
for (var i = 0; i < settleds.length; i = i + 1) {
if (settleds[i].status !== expected[i].status) {
throw new Test262Error(msg + "status[" + i + "]: " + settleds[i].status + " vs " + expected[i].status);
}
if (expected[i].status === "fulfilled" && settleds[i].value !== expected[i].value) {
throw new Test262Error(msg + "value[" + i + "]: " + settleds[i].value + " vs " + expected[i].value);
}
if (expected[i].status === "rejected" && settleds[i].reason !== expected[i].reason) {
throw new Test262Error(msg + "reason[" + i + "]: " + settleds[i].reason + " vs " + expected[i].reason);
}
}
};
// decimalToHexString.js include — used by URI/escape tests.
var decimalToHexString = function (n) {
var hex = "0123456789ABCDEF";