aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/test_clojure
diff options
context:
space:
mode:
Diffstat (limited to 'src/clojure/contrib/test_clojure')
-rw-r--r--src/clojure/contrib/test_clojure/for.clj6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/clojure/contrib/test_clojure/for.clj b/src/clojure/contrib/test_clojure/for.clj
index 5303013c..1e4d7063 100644
--- a/src/clojure/contrib/test_clojure/for.clj
+++ b/src/clojure/contrib/test_clojure/for.clj
@@ -82,6 +82,12 @@
[x y])
'([1 0] [3 0]))))
+(deftest While-and-When-Same-Binding
+ (is (= (for [x (only 6) :while (< x 5) :when (odd? x)] x) '(1 3)))
+ (is (= (for [x (only 6)
+ :while (< x 5) ; if :while is false, :when should not be evaled
+ :when (do (is (< x 5) (odd? x)))] x) '(1 3))))
+
(deftest Nesting
(is (= (for [x '(a b) y (interpose x '(1 2)) z (list x y)] [x y z])
'([a 1 a] [a 1 1] [a a a] [a a a] [a 2 a] [a 2 2]