Skip to content

Commit

Permalink
Fix #1 nil vaues in equiv
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiesardo committed Jul 18, 2016
1 parent b381bc9 commit 0c50649
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/linked/map.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
(equiv [this o]
(and (instance? Map o)
(= (.count this) (count o))
(every? (fn [[k v]]
(= v (get o k)))
(every? (fn [[k v :as kv]]
(= kv (find o k)))
(.seq this))))

Seqable
Expand Down
6 changes: 4 additions & 2 deletions test/linked/map_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@
(is (= (hash {1 2}) (hash one-item))))
(testing "Does not blow up when give something different"
(is (not= one-item 'baz))
(is (not= 'baz one-item)))))
(is (not= 'baz one-item)))
(testing "nil values don't break .equiv"
(is (not= (linked/map :x nil) {:y 0})))))

(deftest ordering
(let [values [[:first 10]
Expand Down Expand Up @@ -126,4 +128,4 @@
(let [o (read-string (pr-str s))]
#?(:clj (is (= linked.map.LinkedMap (type o))))
(is (= '([1 9] [3 4] [5 6] [7 8])
(seq o))))))
(seq o))))))

0 comments on commit 0c50649

Please sign in to comment.