Permalink
Browse files

Fix dissoc implementation for Records

Included tests
  • Loading branch information...
1 parent 5c8e1d4 commit 0f73237dce2a1432a2da9760bdd925c45d84a407 @brentonashworth brentonashworth committed Jul 25, 2012
Showing with 10 additions and 1 deletion.
  1. +1 −1 src/clj/cljs/core.clj
  2. +9 −0 test/cljs/cljs/core_test.cljs
View
@@ -633,7 +633,7 @@
'IMap
`(~'-dissoc [this# k#] (if (contains? #{~@(map keyword base-fields)} k#)
(dissoc (with-meta (into {} this#) ~'__meta) k#)
- (new ~tagname ~@(remove #{'__extmap} fields)
+ (new ~tagname ~@(remove #{'__extmap '__hash} fields)
(not-empty (dissoc ~'__extmap k#))
nil)))
'ISeqable
@@ -1295,6 +1295,15 @@
(assert (= {:foo 'bar} (meta (with-meta (A.) {:foo 'bar}))))
(assert (= 'bar (:foo (assoc (A.) :foo 'bar))))
+ (defrecord C [a b c])
+ (def letters (C. "a" "b" "c"))
+ (assert (= (set (keys letters)) #{:a :b :c}))
+ (def more-letters (assoc letters :d "d" :e "e" :f "f"))
+ (assert (= (set (keys more-letters)) #{:a :b :c :d :e :f}))
+ (assert (= (set (keys (dissoc more-letters :d))) #{:a :b :c :e :f}))
+ (assert (= (set (keys (dissoc more-letters :d :e))) #{:a :b :c :f}))
+ (assert (= (set (keys (dissoc more-letters :d :e :f))) #{:a :b :c}))
+
;; ObjMap
(let [ks (map (partial str "foo") (range 500))
m (apply obj-map (interleave ks (range 500)))]

0 comments on commit 0f73237

Please sign in to comment.