Permalink
Browse files

CLJS-784: Fix *Map.-conj for map-entry seqs, that don't implement INext

  • Loading branch information...
1 parent 3d4405b commit c1a29f1eceae9d1f1f637d9c5f2fa132efa58c47 @bendlas bendlas committed with David Nolen May 6, 2014
Showing with 17 additions and 3 deletions.
  1. +3 −3 src/cljs/cljs/core.cljs
  2. +14 −0 test/cljs/cljs/core_test.cljs
View
@@ -4308,7 +4308,7 @@ reduces them without incurring seq initialization"
(let [e (first es)]
(if (vector? e)
(recur (-assoc ret (-nth e 0) (-nth e 1))
- (-next es))
+ (next es))
(throw (js/Error. "conj on a map takes map entries or seqables of map entries"))))))))
IEmptyableCollection
@@ -5141,7 +5141,7 @@ reduces them without incurring seq initialization"
(let [e (first es)]
(if (vector? e)
(recur (-assoc ret (-nth e 0) (-nth e 1))
- (-next es))
+ (next es))
(throw (js/Error. "conj on a map takes map entries or seqables of map entries"))))))))
IEmptyableCollection
@@ -5886,7 +5886,7 @@ reduces them without incurring seq initialization"
(let [e (first es)]
(if (vector? e)
(recur (-assoc ret (-nth e 0) (-nth e 1))
- (-next es))
+ (next es))
(throw (js/Error. "conj on a map takes map entries or seqables of map entries"))))))))
IEmptyableCollection
@@ -2179,6 +2179,20 @@
(assert (= {:foo 1} (conj m [:foo 1])))
(assert (= {:foo 1} (conj m {:foo 1})))
(assert (= {:foo 1} (conj m (list [:foo 1])))))
+
+ (doseq [mt [array-map hash-map sorted-map]]
+ (assert (= {:foo 1 :bar 2 :baz 3}
+ (conj (mt :foo 1)
+ ((fn make-seq [from-seq]
+ ;; this tests specifically for user defined seq's, that implement the bare minimum, i.e. no INext
+ (when (seq from-seq)
+ (reify
+ ISeqable
+ (-seq [this] this)
+ ISeq
+ (-first [this] (first from-seq))
+ (-rest [this] (make-seq (rest from-seq))))))
+ [[:bar 2] [:baz 3]])))))
:ok
)

0 comments on commit c1a29f1

Please sign in to comment.