Skip to content

Commit

Permalink
CLJS-2959: sort and sort-by should retain meta
Browse files Browse the repository at this point in the history
  • Loading branch information
namenu authored and mfikes committed Jul 11, 2020
1 parent 0ea117b commit 0efe8fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/cljs/cljs/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2457,7 +2457,7 @@ reduces them without incurring seq initialization"
(let [a (to-array coll)]
;; matching Clojure's stable sort, though docs don't promise it
(garray/stableSort a (fn->comparator comp))
(seq a))
(with-meta (seq a) (meta coll)))
())))

(defn sort-by
Expand Down
4 changes: 4 additions & 0 deletions src/test/cljs/cljs/core_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -1738,6 +1738,10 @@
(is (= (symbol (->Var nil 'bar/foo nil)) 'bar/foo))
(is (thrown? js/Error (symbol 1))))

(deftest test-cljs-2959
(is (= {:a true} (meta (sort (with-meta (range 10) {:a true})))))
(is (= {:a true} (meta (sort-by :a (with-meta (seq [{:a 5} {:a 2} {:a 3}]) {:a true}))))))

(deftest test-cljs-2991
(let [o (js-obj)]
(is (object? o))
Expand Down

0 comments on commit 0efe8fe

Please sign in to comment.