From: Chris Duncan Date: Fri, 6 Dec 2024 06:09:44 +0000 (-0800) Subject: Get message from failure errors. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=decff38f97f5535d0d67f0a315751ba01b5ce1b6;p=libnemo.git Get message from failure errors. --- diff --git a/GLOBALS.mjs b/GLOBALS.mjs index 1b60059..a9c6c39 100644 --- a/GLOBALS.mjs +++ b/GLOBALS.mjs @@ -24,17 +24,17 @@ export function test (name, fn) { if (fn instanceof Promise) { try { fn.then(() => console.log(`PASS: ${name}`)) - .catch((err) => console.error(`FAIL: ${name}`)) + .catch((err) => console.error(`FAIL: ${name}: ${err.message}`)) } catch (err) { - console.error(`FAIL: ${name}`) + console.error(`FAIL: ${name}: ${err.message}`) console.error(err) } } else if (fn.constructor.name === 'AsyncFunction') { try { fn().then(() => console.log(`PASS: ${name}`)) - .catch((err) => console.error(`FAIL: ${name}`)) + .catch((err) => console.error(`FAIL: ${name}: ${err.message}`)) } catch (err) { - console.error(`FAIL: ${name}`) + console.error(`FAIL: ${name}: ${err.message}`) console.error(err) } } else { @@ -42,7 +42,7 @@ export function test (name, fn) { fn() console.log(`PASS: ${name}`) } catch (err) { - console.error(`FAIL: ${name}`) + console.error(`FAIL: ${name}: ${err.message}`) console.error(err) } } @@ -59,11 +59,10 @@ export const assert = { return true }, exists: (a) => { - let b = a || null - if (b == null) { + if (!!a === false) { throw new Error(`argument is ${typeof a}`) } - return b != null + return a != null }, equals: (a, b) => { if (a !== b) {