1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:37:46 +00:00

LibJS/test-js: Clean up test-js code

This commit also exposes JSONObject's implementation of stringify to the
public, so that it can be used by test-js without having to go through
the interpreter's environment.
This commit is contained in:
Matthew Olsson 2020-07-04 11:37:50 -07:00 committed by Andreas Kling
parent 4c6fd49169
commit 26acc8ba88
5 changed files with 193 additions and 171 deletions

View file

@ -425,7 +425,7 @@ describe = (message, callback) => {
suiteMessage = defaultSuiteMessage;
}
test = (message, callback) => {
const getTestFunction = successMessage => (message, callback) => {
if (!__TestResults__[suiteMessage])
__TestResults__[suiteMessage] = {};
@ -437,13 +437,15 @@ test = (message, callback) => {
try {
callback();
suite[message] = {
passed: true,
result: successMessage,
};
} catch (e) {
suite[message] = {
passed: false,
result: "fail",
};
}
}
test = getTestFunction("pass");
})();