diff options
author | Frantisek Sodomka <fsodomka@gmail.com> | 2009-05-14 20:57:37 +0000 |
---|---|---|
committer | Frantisek Sodomka <fsodomka@gmail.com> | 2009-05-14 20:57:37 +0000 |
commit | 710841407b7b2fbd24a0959fd121c662a5b1d2dd (patch) | |
tree | 1e0d10fb0a31e45d9c1bb6124ec850a4a13de937 /src/clojure/contrib/test_clojure | |
parent | c78f45d08b62f9b53b1503d1e9c83e6d7adca83f (diff) |
test-clojure: control: cond
Diffstat (limited to 'src/clojure/contrib/test_clojure')
-rw-r--r-- | src/clojure/contrib/test_clojure/control.clj | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/clojure/contrib/test_clojure/control.clj b/src/clojure/contrib/test_clojure/control.clj index 134711c8..15542bf6 100644 --- a/src/clojure/contrib/test_clojure/control.clj +++ b/src/clojure/contrib/test_clojure/control.clj @@ -63,7 +63,48 @@ ; [if (logic.clj)], if-not, if-let ; when, when-not, when-let, when-first -; cond, condp + +(deftest test-cond + (are (= _1 _2) + (cond) nil + + (cond nil true) nil + (cond false true) nil + + (cond true 1 true (exception)) 1 + (cond nil 1 false 2 true 3 true 4) 3 + (cond nil 1 false 2 true 3 true (exception)) 3 ) + + ; false + (are (= (cond _ :a true :b) :b) + nil false ) + + ; true + (are (= (cond _ :a true :b) :a) + true + 0 42 + 0.0 3.14 + 2/3 + 0M 1M + \c + "" "abc" + 'sym + :kw + () '(1 2) + [] [1 2] + {} {:a 1 :b 2} + #{} #{1 2} ) + + ; evaluation + (are (= _1 _2) + (cond (> 3 2) (+ 1 2) true :result true (exception)) 3 + (cond (< 3 2) (+ 1 2) true :result true (exception)) :result ) + + ; identity (= (cond true x) x) + (maintains-identity (fn [_] (cond true _))) ) + + +; condp ; [for, doseq (for.clj)] |