diff options
-rw-r--r-- | src/clj/clojure/core_deftype.clj | 6 | ||||
-rw-r--r-- | test/clojure/test_clojure/protocols.clj | 5 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/clj/clojure/core_deftype.clj b/src/clj/clojure/core_deftype.clj index b0604c9e..3b531f05 100644 --- a/src/clj/clojure/core_deftype.clj +++ b/src/clj/clojure/core_deftype.clj @@ -195,8 +195,8 @@ `(entryAt [this# k#] (let [v# (.valAt this# k# this#)] (when-not (identical? this# v#) (clojure.lang.MapEntry. k# v#)))) - `(seq [this#] (concat [~@(map #(list `new `clojure.lang.MapEntry (keyword %) %) base-fields)] - ~'__extmap)) + `(seq [this#] (seq (concat [~@(map #(list `new `clojure.lang.MapEntry (keyword %) %) base-fields)] + ~'__extmap))) `(assoc [this# k# ~gs] (condp identical? k# ~@(mapcat (fn [fld] @@ -212,7 +212,7 @@ (conj m `(size [this#] (.count this#)) `(isEmpty [this#] (= 0 (.count this#))) - `(containsValue [this# v#] (-> this# vals (.contains v#))) + `(containsValue [this# v#] (boolean (some #{v#} (vals this#)))) `(get [this# k#] (.valAt this# k#)) `(put [this# k# v#] (throw (UnsupportedOperationException.))) `(remove [this# k#] (throw (UnsupportedOperationException.))) diff --git a/test/clojure/test_clojure/protocols.clj b/test/clojure/test_clojure/protocols.clj index 257a73d8..d8d2ac7f 100644 --- a/test/clojure/test_clojure/protocols.clj +++ b/test/clojure/test_clojure/protocols.clj @@ -192,6 +192,11 @@ (is (= {:foo 1 :b 2} (set/rename-keys rec {:a :foo}))) (is (= {:a 11 :b 2 :c 10} (merge-with + rec {:a 10 :c 10}))))) +(deftest degenerate-defrecord-test + (let [empty (EmptyRecord.)] + (is (nil? (seq empty))) + (is (not (.containsValue empty :a))))) + (deftest defrecord-interfaces-test (testing "java.util.Map" (let [rec (r 1 2)] |