[#283] support writer arg in clojure.pprint

This commit is contained in:
Michiel Borkent 2020-03-04 21:14:53 +01:00
parent 35a2001ca8
commit f52b208b7e
3 changed files with 18 additions and 2 deletions

View file

@ -0,0 +1,12 @@
(ns babashka.impl.clojure.pprint
{:no-doc true}
(:require [fipp.edn :as fipp]))
(defn pprint
([edn]
(fipp/pprint edn))
([edn writer]
(fipp/pprint edn {:writer writer})))
(def pprint-namespace
{'pprint pprint})

View file

@ -9,6 +9,7 @@
[babashka.impl.clojure.java.io :refer [io-namespace]]
[babashka.impl.clojure.java.shell :refer [shell-namespace]]
[babashka.impl.clojure.main :refer [demunge]]
[babashka.impl.clojure.pprint :refer [pprint-namespace]]
[babashka.impl.clojure.stacktrace :refer [stacktrace-namespace print-stack-trace]]
[babashka.impl.common :as common]
[babashka.impl.csv :as csv]
@ -21,7 +22,6 @@
[clojure.edn :as edn]
[clojure.java.io :as io]
[clojure.string :as str]
[fipp.edn :as fipp]
[sci.addons :as addons]
[sci.core :as sci]
[sci.impl.interpreter :refer [eval-string*]]
@ -259,7 +259,7 @@ Everything after that is bound to *command-line-args*."))
'clojure.repl {'demunge demunge}
'clojure.test t/clojure-test-namespace
'babashka.classpath {'add-classpath add-classpath*}
'clojure.pprint {'pprint fipp/pprint}})
'clojure.pprint pprint-namespace})
(def bindings
{'java.lang.System/exit exit ;; override exit, so we have more control

View file

@ -342,6 +342,10 @@
(alter-var-root #'clojure.core/inc (constantly inc2))
res)")))))
(deftest pprint-test
(testing "writer"
(is (string? (bb nil "(let [sw (java.io.StringWriter.)] (clojure.pprint/pprint (range 10) sw) (str sw))")))))
;;;; Scratch
(comment