Skip to content

Commit 5433967

Browse files
committed
Print java.util.UUIDs as #uuid literals
1 parent ecf8204 commit 5433967

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/lambdaisland/deep_diff/printer.clj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@
8787
(puget/format-doc printer v)]))))
8888

8989
'java.util.Date
90-
print-date})
90+
print-date
91+
92+
'java.util.UUID
93+
(puget/tagged-handler 'uuid str)})
9194

9295
(defn- print-handler-resolver [extra-handlers]
9396
(fn [^Class klz]

test/lambdaisland/deep_diff/printer_test.clj

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,19 @@
33
[lambdaisland.deep-diff.diff :as diff]
44
[lambdaisland.deep-diff.printer :as printer]))
55

6-
(deftest print-doc-test
6+
(defn- printed
7+
[diff]
78
(let [printer (printer/puget-printer {})]
9+
(with-out-str (-> diff
10+
(printer/format-doc printer)
11+
(printer/print-doc printer)))))
12+
13+
(deftest print-doc-test
14+
(testing "date"
815
(is (= "-#inst \"2019-04-09T14:57:46.128-00:00\" +#inst \"2019-04-10T14:57:46.128-00:00\"\n"
9-
(with-out-str (-> (diff/diff #inst "2019-04-09T14:57:46.128-00:00"
10-
#inst "2019-04-10T14:57:46.128-00:00")
11-
(printer/format-doc printer)
12-
(printer/print-doc printer)))))))
16+
(printed (diff/diff #inst "2019-04-09T14:57:46.128-00:00"
17+
#inst "2019-04-10T14:57:46.128-00:00")))))
18+
(testing "uuid"
19+
(is (= "-#uuid \"e41b325a-ce9d-4fdd-b51d-280d9c91314d\" +#uuid \"0400be9a-619f-4c6a-a735-6245e4955995\"\n"
20+
(printed (diff/diff #uuid "e41b325a-ce9d-4fdd-b51d-280d9c91314d"
21+
#uuid "0400be9a-619f-4c6a-a735-6245e4955995"))))))

0 commit comments

Comments
 (0)