Navigation Menu

Skip to content

Commit

Permalink
Fix bug in AbstractMap/entryAt
Browse files Browse the repository at this point in the history
Previously, this would cause an error to the tune of java.lang.Class
cannot be cast to clojure.lang.IFn.
  • Loading branch information
bcobb committed Feb 13, 2015
1 parent 35fa6ac commit 7ca8ca3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/potemkin/collections.clj
Expand Up @@ -143,7 +143,7 @@

(entryAt [this k]
(when (contains? (.keySet this) k)
(potemkin.LazyMapEntry this k)))
(potemkin.LazyMapEntry. this k)))

(assoc [this k v]
(potemkin.collections/assoc* this k v))
Expand Down
8 changes: 6 additions & 2 deletions test/potemkin/collections_test.clj
Expand Up @@ -37,14 +37,18 @@
(is (= (::meta-key (meta (with-meta m {::meta-key "value"})))
"value")))
(test-basic-map-functionality (->SimpleDerivedMap))
(test-basic-map-functionality (simple-map {} {})))
(test-basic-map-functionality (simple-map {} {}))
(is (= [:one "two"] (find (->SimpleMap {:one "two" :three "four"} {}) :one))))

(deftest test-derived-map
(let [m (->DerivedMap "AbC")]
(is (= {:string "AbC" :lower "abc" :upper "ABC"} m))
(is (= {:lower "abc" :upper "ABC"} (dissoc m :string)))
(is (= {:string "foo" :lower "abc" :upper "ABC" :bar "baz"}
(assoc m :string "foo" :bar "baz")))))
(assoc m :string "foo" :bar "baz")))
(is (= #{:lower :upper :string} (-> m keys set)))
(is (= [:lower "abc"] (find m :lower)))
(is (= {:lower "abc" :upper "ABC"} (select-keys m [:lower :upper])))))

(def-map-type LazyMap [m]
(get [_ k default-value]
Expand Down

0 comments on commit 7ca8ca3

Please sign in to comment.