]> zoso.dev Git - libnemo.git/commitdiff
Compare only real values with equals and notEqual. Use ok with strict equality compar...
authorChris Duncan <chris@zoso.dev>
Fri, 6 Dec 2024 20:48:02 +0000 (12:48 -0800)
committerChris Duncan <chris@zoso.dev>
Fri, 6 Dec 2024 20:48:02 +0000 (12:48 -0800)
GLOBALS.mjs

index dd8b76f83994fd65dbc7015043edef52fbf3c162..dea5a8c40cc3db72575810eab2152512dac7743f 100644 (file)
@@ -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}`)
                }