From 970d49d1aba857e16f4b0266f237388bf3e1dfb0 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Fri, 6 Dec 2024 12:48:02 -0800 Subject: [PATCH] Compare only real values with equals and notEqual. Use ok with strict equality comparison instead. --- GLOBALS.mjs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/GLOBALS.mjs b/GLOBALS.mjs index dd8b76f..dea5a8c 100644 --- a/GLOBALS.mjs +++ b/GLOBALS.mjs @@ -114,12 +114,18 @@ export const assert = { return a != null }, equals: (a, b) => { + if (a == null || b == null) { + throw new Error(`assert.equals() will not compare null or undefined`) + } if (a !== b) { throw new Error(`${a} not equal to ${b}`) } return a === b }, notEqual: (a, b) => { + if (a == null || b == null) { + throw new Error(`assert.notEqual() will not compare null or undefined`) + } if (a === b) { throw new Error(`${a} equals ${b}`) } -- 2.34.1