Skip to content

Commit

Permalink
Fix (println 1 1) => "11\n" instead of "1 1\n"
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonbloom authored and David Nolen committed Jul 5, 2012
1 parent 0f2be41 commit 280ea95
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions src/cljs/cljs/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6146,11 +6146,11 @@ reduces them without incurring seq initialization"
:else (list "#<" (str obj) ">")))))

(defn- pr-sb [objs opts]
(let [first-obj (first objs)
sb (gstring/StringBuffer.)]
(doseq [obj objs]
(when-not (identical? obj first-obj)
(.append sb " "))
(let [sb (gstring/StringBuffer.)]
(doseq [string (pr-seq (first objs) opts)]
(.append sb string))
(doseq [obj (next objs)]
(.append sb " ")
(doseq [string (pr-seq obj opts)]
(.append sb string)))
sb))
Expand All @@ -6172,12 +6172,12 @@ reduces them without incurring seq initialization"
"Prints a sequence of objects using string-print, observing all
the options given in opts"
[objs opts]
(let [first-obj (first objs)]
(doseq [obj objs]
(when-not (identical? obj first-obj)
(string-print " "))
(doseq [string (pr-seq obj opts)]
(string-print string)))))
(doseq [string (pr-seq (first objs) opts)]
(string-print string))
(doseq [obj (next objs)]
(string-print " ")
(doseq [string (pr-seq obj opts)]
(string-print string))))

(defn newline [opts]
(string-print "\n")
Expand Down
2 changes: 1 addition & 1 deletion test/cljs/cljs/core_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
(assert (= (hash-map :foo 5)
(assoc (cljs.core.ObjMap. nil (array) (js-obj)) :foo 5)))

(assert (= "\"asdf\"" (pr-str "asdf")))
(assert (= "\"asdf\" \"asdf\"" (pr-str "asdf" "asdf")))
(assert (= "[1 true {:a 2, :b #\"x\\\"y\"} #<Array [3, 4]>]"
(pr-str [1 true {:a 2 :b #"x\"y"} (array 3 4)])))

Expand Down

0 comments on commit 280ea95

Please sign in to comment.