Commit 4519f16 1 parent ebe962a commit 4519f16 Copy full SHA for 4519f16
File tree 2 files changed +17
-14
lines changed
src/cider/nrepl/middleware
test/clj/cider/nrepl/middleware
2 files changed +17
-14
lines changed Original file line number Diff line number Diff line change 68
68
first))))
69
69
70
70
(defn- print-object
71
- " Print `object` using pprint or a custom print-method, if available."
71
+ " Print `object` using println for matcher-combinators results and pprint
72
+ otherwise."
72
73
[object]
73
- (let [print-fn (if (= (get-method print-method (:type (meta object)))
74
- (get-method print-method :default ))
75
- pp/pprint
76
- println)]
74
+ (let [matcher-combinators-result? (= (:type (meta object))
75
+ :matcher-combinators.clj-test/mismatch )
76
+ print-fn (if matcher-combinators-result?
77
+ println
78
+ pp/pprint)]
77
79
(with-out-str (print-fn object))))
78
80
79
81
(def ^:dynamic *test-error-handler*
Original file line number Diff line number Diff line change 159
159
first
160
160
:message ))))))
161
161
162
- (defmethod clojure.core /print-method ::custom [_ out]
163
- (binding [*out* out]
164
- (print " custom-output" )))
165
-
166
162
(deftest print-object-test
167
- (testing " use an object's print-method when applicable, otherwise invoke pprint"
168
- (is (= " custom-output\n "
169
- (#'test/print-object (with-meta {:not :printed } {:type ::custom }))))
170
- (is (= " {:a :b, :c :d}\n "
171
- (#'test/print-object {:a :b :c :d })))))
163
+ (testing " uses println for matcher-combinators results, otherwise invokes pprint"
164
+ (is (= " {no quotes}\n "
165
+ (#'test/print-object (with-meta {" no" " quotes" } {:type :matcher-combinators.clj-test/mismatch })))
166
+ " println is chosen, as indicated by strings printed without quotes" )
167
+ (is (= " {:a\n (\" a-sufficiently-long-string\"\n \" a-sufficiently-long-string\"\n \" a-sufficiently-long-string\" )}\n "
168
+ (#'test/print-object {:a (repeat 3 " a-sufficiently-long-string" )}))
169
+ " pprint is chosen, as indicated by quoted strings and newlines" )
170
+ (is (= " {:a \" b\" , :c \" 42\" }\n "
171
+ (#'test/print-object (with-meta {:a " b" :c " 42" } {:type ::mismatch })))
172
+ " pprint is chosen, because :type does not match matchers-combinators keyword" )))
172
173
173
174
(deftest test-result-test
174
175
(testing " It passes `:error`s to `test/*test-error-handler*`"
You can’t perform that action at this time.
0 commit comments