Skip to content

Commit 990ed92

Browse files
committed
CLJS-3356: halt-when not usable within #'c.c/into
1 parent 573790c commit 990ed92

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/main/cljs/cljs/core.cljs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5262,7 +5262,11 @@ reduces them without incurring seq initialization"
52625262
(reduce conj to from)))
52635263
([to xform from]
52645264
(if (implements? IEditableCollection to)
5265-
(-with-meta (persistent! (transduce xform conj! (transient to) from)) (meta to))
5265+
(let [tm (meta to)
5266+
rf (fn
5267+
([coll] (-> (persistent! coll) (-with-meta tm)))
5268+
([coll v] (conj! coll v)))]
5269+
(transduce xform rf (transient to) from))
52665270
(transduce xform conj to from))))
52675271

52685272
(defn mapv

src/test/cljs/cljs/core_test.cljs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,15 @@
387387
(testing "CLJS-2258"
388388
(is (= ["1"] (sequence (map str) (eduction [1]))))))
389389

390+
(deftest test-into+halt-when
391+
(is (= :anomaly (into [] (comp (filter some?) (halt-when #{:anomaly}))
392+
[1 2 3 :anomaly 4])))
393+
(is (= {:anomaly :oh-no!,
394+
:partial-results [1 2]}
395+
(into []
396+
(halt-when :anomaly #(assoc %2 :partial-results %1))
397+
[1 2 {:anomaly :oh-no!} 3 4]))))
398+
390399
(deftest test-obj-equiv
391400
(testing "Object equiv method"
392401
(is (.equiv :foo :foo))
@@ -1282,7 +1291,7 @@
12821291
[5 4]))
12831292
(is (= (transduce (halt-when #{1} (fn [ret input] (conj ret input))) conj [] [5 4 1 2 3])
12841293
[5 4 1]))
1285-
(is (= (into [] (halt-when #{1} (fn [ret in] (conj! ret in))) [2 3 1])
1294+
(is (= (into [] (halt-when #{1} (fn [ret in] (conj ret in))) [2 3 1])
12861295
[2 3 1]))))
12871296

12881297
(deftest test-cljs-1839

0 commit comments

Comments
 (0)