This commit is contained in:
Nathan Marz 2016-06-04 17:19:39 -04:00
parent 86f05b3cbe
commit a4857a9d57
2 changed files with 18 additions and 1 deletions

View file

@ -607,6 +607,15 @@
))
(extend-protocol AllTransformProtocol
;; in cljs they're PersistentVector so don't need a special case
#+clj clojure.lang.MapEntry
#+clj
(all-transform [structure next-fn]
(let [newk (next-fn (key structure))
newv (next-fn (val structure))]
(clojure.lang.MapEntry. newk newv)
))
#+clj clojure.lang.PersistentVector #+cljs cljs.core/PersistentVector
(all-transform [structure next-fn]
(mapv next-fn structure))

View file

@ -1017,3 +1017,11 @@
(is (= false (transform (s/nil->val true) identity false)))
(is (= false (select-one! (s/nil->val true) false)))
)
#+clj
(deftest all-map-entry
(let [e (transform s/ALL inc (first {1 3}))]
(is (instance? clojure.lang.MapEntry e))
(is (= 2 (key e)))
(is (= 4 (val e)))
))