diff options
| author | Stuart Halloway <stu@thinkrelevance.com> | 2010-04-23 16:50:45 -0400 |
|---|---|---|
| committer | Stuart Halloway <stu@thinkrelevance.com> | 2010-04-24 14:29:09 -0400 |
| commit | c487e48a65ee7cef66ef017c87a754fc88ba57e0 (patch) | |
| tree | 8271d576ef08b0ed23a0ba43b55db42e333ca1d2 /test | |
| parent | e0e0b6a2f192bf743e3629dff0b23a39ccf4f8db (diff) | |
java.util.Map for defrecord, #313
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
Diffstat (limited to 'test')
| -rw-r--r-- | test/clojure/test_clojure/protocols.clj | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/clojure/test_clojure/protocols.clj b/test/clojure/test_clojure/protocols.clj index 7f678234..a98994f3 100644 --- a/test/clojure/test_clojure/protocols.clj +++ b/test/clojure/test_clojure/protocols.clj @@ -30,6 +30,7 @@ (map #(.getName %)) (sort))) +(defrecord EmptyRecord []) (defrecord TestRecord [a b]) (defn r ([a b] (TestRecord. a b)) @@ -157,6 +158,26 @@ (is (= (r 1 3 {} {:c 4}) (merge rec {:b 3 :c 4}))))) (deftest defrecord-interfaces-test + (testing "java.util.Map" + (let [rec (r 1 2)] + (is (= 2 (.size rec))) + (is (= 3 (.size (assoc rec :c 3)))) + (is (not (.isEmpty rec))) + (is (.isEmpty (EmptyRecord.))) + (is (.containsKey rec :a)) + (is (not (.containsKey rec :c))) + (is (.containsValue rec 1)) + (is (not (.containsValue rec 3))) + (is (= 1 (.get rec :a))) + (is (thrown? UnsupportedOperationException (.put rec :a 1))) + (is (thrown? UnsupportedOperationException (.remove rec :a))) + (is (thrown? UnsupportedOperationException (.putAll rec {}))) + (is (thrown? UnsupportedOperationException (.clear rec))) + (is (= #{:a :b} (.keySet rec))) + (is (= #{1 2} (set (.values rec)))) + (is (= #{[:a 1] [:b 2]} (.entrySet rec))) + + )) (testing "IPersistentCollection" (testing ".cons" (let [rec (r 1 2)] |
