Skip to content

Commit

Permalink
Add comma before ... in ,-separated colls
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhan0 authored and bbatsov committed Apr 13, 2021
1 parent 946320d commit 78584d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/orchard/inspect.clj
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
(safe-pr-seq value ", " "{ %s }"))

(defmethod inspect-value :map-long [value]
(safe-pr-seq (take *max-coll-size* value) ", " "{ %s ... }"))
(safe-pr-seq (take *max-coll-size* value) ", " "{ %s, ... }"))

(defmethod inspect-value :vector [value]
(safe-pr-seq value "[ %s ]"))
Expand Down Expand Up @@ -274,7 +274,7 @@

(defmethod inspect-value :array-long [value]
(let [ct (.getName (or (.getComponentType (class value)) Object))]
(safe-pr-seq (take *max-coll-size* value) ", " (str ct "[] { %s ... }"))))
(safe-pr-seq (take *max-coll-size* value) ", " (str ct "[] { %s, ... }"))))
(defmethod inspect-value java.lang.Class [value]
(pr-str value))

Expand Down
12 changes: 6 additions & 6 deletions test/orchard/inspect_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,13 @@
"#{ :a }" #{:a}
"( 1 1 1 1 1 ... )" (repeat 1)
"[ ( 1 1 1 1 1 ... ) ]" [(repeat 1)]
"{ :a { ( 0 1 2 3 4 ... ) 1, 2 3, 4 5, 6 7, 8 9 ... } }" {:a {(range 10) 1, 2 3, 4 5, 6 7, 8 9, 10 11}}
"{ :a { ( 0 1 2 3 4 ... ) 1, 2 3, 4 5, 6 7, 8 9, ... } }" {:a {(range 10) 1, 2 3, 4 5, 6 7, 8 9, 10 11}}
"( 1 2 3 )" (lazy-seq '(1 2 3))
"( 1 1 1 1 1 ... )" (java.util.ArrayList. (repeat 100 1))
"( 1 2 3 )" (java.util.ArrayList. [1 2 3])
"{ :a 1, :b 2 }" (java.util.HashMap. {:a 1 :b 2})
"long[] { 1, 2, 3, 4 }" (long-array [1 2 3 4])
"java.lang.Long[] { 0, 1, 2, 3, 4 ... }" (into-array Long (range 10))
"java.lang.Long[] { 0, 1, 2, 3, 4, ... }" (into-array Long (range 10))
"#<MyTestType test1>" (MyTestType. "test1")))

(testing "inspect-value adjust length and size"
Expand All @@ -279,12 +279,12 @@
"( :a :b )" '(:a :b)
"[ 1 2 ... ]" [1 2 3]
"{ :a 1, :b 2 }" {:a 1 :b 2}
"{ :a 1, :b 2 ... }" {:a 1 :b 2 :c 3}
"{ :a 1, :b 2 ... }" (sorted-map :d 4 :b 2 :a 1 :c 3)
"{ :a 1, :b 2, ... }" {:a 1 :b 2 :c 3}
"{ :a 1, :b 2, ... }" (sorted-map :d 4 :b 2 :a 1 :c 3)
"( 1 1 ... )" (repeat 1)
"[ ( 1 1 ... ) ]" [(repeat 1)]
"{ :a { ( 0 1 ... ) \"ab..., 2 3 ... } }" {:a {(range 10) "abcdefg", 2 3, 4 5, 6 7, 8 9, 10 11}}
"java.lang.Long[] { 0, 1 ... }" (into-array Long (range 10))))
"{ :a { ( 0 1 ... ) \"ab..., 2 3, ... } }" {:a {(range 10) "abcdefg", 2 3, 4 5, 6 7, 8 9, 10 11}}
"java.lang.Long[] { 0, 1, ... }" (into-array Long (range 10))))
(binding [inspect/*max-coll-size* 6]
(are [result form] (= result (inspect/inspect-value form))
"[ ( 1 1 1 1 1 1 ... ) ]" [(repeat 1)]
Expand Down

0 comments on commit 78584d2

Please sign in to comment.