Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CLJS-376: `case` doesn't match symbols.

  • Loading branch information...
commit c8e301a9b058f81bb599026a07f97ccdf4441730 1 parent 5f20175
David Nolen authored
Showing with 33 additions and 3 deletions.
  1. +9 −3 src/clj/cljs/core.clj
  2. +24 −0 test/cljs/cljs/core_test.cljs
View
12 src/clj/cljs/core.clj
@@ -838,9 +838,15 @@
cljs.analyzer/*cljs-file*)))))
(assoc m test expr)))
pairs (reduce (fn [m [test expr]]
- (if (seq? test)
- (reduce #(assoc-test %1 %2 expr) m test)
- (assoc-test m test expr)))
+ (cond
+ (seq? test) (reduce (fn [m test]
+ (let [test (if (symbol? test)
+ (list 'quote test)
+ test)]
+ (assoc-test m test expr)))
+ m test)
+ (symbol? test) (assoc-test m (list 'quote test) expr)
+ :else (assoc-test m test expr)))
{} (partition 2 clauses))
esym (gensym)]
`(let [~esym ~e]
View
24 test/cljs/cljs/core_test.cljs
@@ -1464,6 +1464,30 @@
[:a :b] :ok)
:ok)))
+ (let [a 'a]
+ (assert (= (case a
+ nil nil
+ & :amp
+ :none)
+ :none)))
+
+ (let [a '&]
+ (assert (= (case a
+ nil nil
+ & :amp
+ :none)
+ :amp)))
+
+ (let [foo 'a]
+ (assert (= (case foo
+ (a b c) :sym
+ :none)
+ :sym))
+ (assert (= (case foo
+ (b c d) :sym
+ :none)
+ :none)))
+
;; IComparable
(assert (= 0 (compare false false)))
(assert (= -1 (compare false true)))
Please sign in to comment.
Something went wrong with that request. Please try again.