Fix #1149 - deep-not= should only return true/false.

Also improve perf at same time.
This commit is contained in:
Calvin Rose 2023-05-22 20:40:30 -05:00
parent 57b751b994
commit 41943746e4
2 changed files with 20 additions and 2 deletions

View File

@ -2114,8 +2114,24 @@
(or
(not= tx (type y))
(case tx
:tuple (or (not= (length x) (length y)) (some identity (map deep-not= x y)))
:array (or (not= (length x) (length y)) (some identity (map deep-not= x y)))
:tuple (or (not= (length x) (length y))
(do
(var ret false)
(forv i 0 (length x)
(def xx (in x i))
(def yy (in y i))
(if (deep-not= xx yy)
(break (set ret true))))
ret))
:array (or (not= (length x) (length y))
(do
(var ret false)
(forv i 0 (length x)
(def xx (in x i))
(def yy (in y i))
(if (deep-not= xx yy)
(break (set ret true))))
ret))
:struct (deep-not= (kvs x) (kvs y))
:table (deep-not= (table/to-struct x) (table/to-struct y))
:buffer (not= (string x) (string y))

View File

@ -329,6 +329,8 @@
(assert (deep= (map + [1 2 3 4] [10 20 30] [100 200]) @[111 222]))
(assert (deep= (map + [1 2 3 4] [10 20 30] [100 200] [1000]) @[1111]))
(assert (= false (deep-not= [1] [1])) "issue #1149")
# Sort function
(assert (deep=
(range 99)