Skip to content

Commit

Permalink
LJS-1590: split, split-lines differs from Clojure on empty string
Browse files Browse the repository at this point in the history
Only discard training if split generates more than one element
  • Loading branch information
spinningtopsofdoom authored and dnolen committed Mar 14, 2016
1 parent c31e91f commit c3899ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/cljs/clojure/string.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@

(defn- discard-trailing-if-needed
[limit v]
(if (== 0 limit)
(if (and (== 0 limit) (< 1 (count v)))
(pop-last-while-empty v)
v))

Expand Down
6 changes: 6 additions & 0 deletions src/test/cljs/cljs/core_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3132,6 +3132,12 @@
(is (= (hash-set Infinity -Infinity 0 1 2 3 4 5 6 7 8)
(set (keys (zipmap [Infinity -Infinity 0 1 2 3 4 5 6 7 8] (repeat nil)))))))

(deftest test-cljs-1590
(is (= [""] (s/split "" #"\n")))
(is (= [] (s/split "\n\n\n" #"\n")))
(is (= [""] (s/split-lines "")))
(is (= [] (s/split-lines "\n\n\n"))))

(comment
;; ObjMap
;; (let [ks (map (partial str "foo") (range 500))
Expand Down

0 comments on commit c3899ac

Please sign in to comment.