add cl-format tests for nil and Writer args (#931)

This commit is contained in:
Bob 2021-07-10 15:39:23 -04:00 committed by GitHub
parent 6a76a73e18
commit b6e65c08a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -462,8 +462,16 @@
(clojure.pprint/pprint (range 10) sw)) (str sw))"))))
(testing "print-table writes to sci/out"
(is (str/includes? (test-utils/bb "(with-out-str (clojure.pprint/print-table [{:a 1} {:a 2}]))") "----")))
(testing "cl-format writes to sci/out"
(is (= "[1, 2, 3]" (bb nil "(with-out-str (clojure.pprint/cl-format true \"~<[~;~@{~w~^, ~:_~}~;]~:>\" [1,2,3]))"))))
(testing "cl-format outputs"
(testing "cl-format true writes to sci/out"
(is (= "[1, 2, 3]" (bb nil "(with-out-str (clojure.pprint/cl-format true \"~<[~;~@{~w~^, ~:_~}~;]~:>\" [1,2,3]))"))))
(testing "cl-format nil returns a string"
(is (= "forty-two" (bb nil "(clojure.pprint/cl-format nil \"~R\" 42)"))))
(testing "cl-format with a writer uses the writer"
(is (= "1,234,567 " (bb nil "
(let [sw (java.io.StringWriter.)]
(clojure.pprint/cl-format sw \"~15@<~:d~>\" 1234567)
(str sw))")))))
(testing "formatter-out"
(is (= "[1, 2, 3]\n"
(bb nil (pr-str '(do (require '[clojure.pprint :as pprint])