From c8453577e99ff8723effe6e2744e3903d59d34da Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Thu, 18 May 2023 17:10:56 -0400 Subject: [PATCH] admin: tweaked gitignore for misc files --- .gitignore | 1 - misc/.gitignore | 3 +++ misc/test-browser/assert.js | 23 ++++++++++++----------- 3 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 misc/.gitignore diff --git a/.gitignore b/.gitignore index 1ce1b571e..1d109b372 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ node_modules/** output/** -misc/** **/*.swp **/*.tgz diff --git a/misc/.gitignore b/misc/.gitignore new file mode 100644 index 000000000..21a9a4919 --- /dev/null +++ b/misc/.gitignore @@ -0,0 +1,3 @@ +*.txt +tests/** +obsolete/** diff --git a/misc/test-browser/assert.js b/misc/test-browser/assert.js index 5357de376..3c197d1bd 100644 --- a/misc/test-browser/assert.js +++ b/misc/test-browser/assert.js @@ -2,22 +2,19 @@ function throwError(message, info) { const error = new Error(`AssertionError: ${ message }`); error.code = "ERR_ASSERTION"; - for (const key of info) { error[key] = info[key]; } + for (const key in info) { error[key] = info[key]; } throw error; } export function equal(actual, expected, reason) { - if (actual != expected) { - if (reason == null) { reason = `${ actual } == ${ expected }`; } + if (actual == expected) { return; } - throwError(reason, { actual, expected, operator: "==" }); - } + if (reason == null) { reason = `${ actual } == ${ expected }`; } + throwError(reason, { actual, expected, operator: "==" }); } function isDeepEqual(actual, expected, memo) { - if (actual === expected) { - return true; - } + if (actual === expected) { return true; } // One or both things aren't objects if (actual === null || typeof(expected) !== 'object') { @@ -70,7 +67,7 @@ export function throws(func, checkFunc, reason) { func(); } catch (e) { - if (checkFunc(e)) { return true; } + if (checkFunc(e)) { return; } throwError(`The expected exception validation function returned false`, { actual: e, @@ -86,7 +83,11 @@ export function throws(func, checkFunc, reason) { export async function rejects(func, checkFunc, reason) { try { - await func(); + if (func.then) { + await func; + } else { + await func(); + } } catch (e) { if (checkFunc(e)) { return true; } @@ -98,7 +99,7 @@ export async function rejects(func, checkFunc, reason) { } throwError("Missing rejection", { - operator: "rejects" + operation: "rejects" }); }