Permalink
Browse files

CLJS-346: Complete fix for CLJS-319 pr-str regression

  • Loading branch information...
1 parent 8355d1e commit b8fcdf0b1cffb1c0964b5ed34e849c81103c786e @brandonbloom brandonbloom committed with David Nolen Sep 3, 2012
Showing with 11 additions and 4 deletions.
  1. +8 −4 src/cljs/cljs/core.cljs
  2. +3 −0 test/cljs/cljs/core_test.cljs
View
12 src/cljs/cljs/core.cljs
@@ -6171,14 +6171,18 @@ reduces them without incurring seq initialization"
"Prints a sequence of objects to a string, observing all the
options given in opts"
[objs opts]
- (str (pr-sb objs opts)))
+ (if (empty? objs)
+ ""
+ (str (pr-sb objs opts))))
(defn prn-str-with-opts
"Same as pr-str-with-opts followed by (newline)"
[objs opts]
- (let [sb (pr-sb objs opts)]
- (.append sb \newline)
- (str sb)))
+ (if (empty? objs)
+ "\n"
+ (let [sb (pr-sb objs opts)]
+ (.append sb \newline)
+ (str sb))))
(defn pr-with-opts
"Prints a sequence of objects using string-print, observing all
View
3 test/cljs/cljs/core_test.cljs
@@ -232,6 +232,9 @@
(assert (= "asdf" (print-str "asdf")))
(assert (= "asdf\n" (println-str "asdf")))
+ (assert (= "" (pr-str)))
+ (assert (= "\n" (prn-str)))
+
;;this fails in v8 - why?
;(assert (= "symbol\"'string" (pr-str (str 'symbol \" \' "string"))))

0 comments on commit b8fcdf0

Please sign in to comment.