Skip to content

Commit 8537ef4

Browse files
bronsadnolen
authored and
dnolen
committed
CLJS-1292: Add IPrintWithWriter implementation for TaggedLiteral
1 parent 635afae commit 8537ef4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9645,6 +9645,9 @@ Maps become Objects. Arbitrary keys are encoded to by key->js."
96459645

96469646

96479647
(deftype TaggedLiteral [tag form]
9648+
Object
9649+
(toString [coll]
9650+
(pr-str* coll))
96489651

96499652
IEquiv
96509653
(-equiv [this other]
@@ -9666,7 +9669,10 @@ Maps become Objects. Arbitrary keys are encoded to by key->js."
96669669
:form form
96679670
not-found))
96689671

9669-
)
9672+
IPrintWithWriter
9673+
(-pr-writer [o writer opts]
9674+
(-write writer (str "#" tag " "))
9675+
(pr-writer form writer opts)))
96709676

96719677
(defn tagged-literal?
96729678
"Return true if the value is the data representation of a tagged literal"

src/test/cljs/cljs/core_test.cljs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2812,7 +2812,8 @@
28122812
(is (= tl (tagged-literal 'x "y")))
28132813
(is (not= tl (tagged-literal 'z "y")))
28142814
(is (not= tl (tagged-literal 'x "z")))
2815-
(is (= (hash tl) (hash (tagged-literal 'x "y"))))))
2815+
(is (= (hash tl) (hash (tagged-literal 'x "y"))))
2816+
(is (= "#foo [1]" (str (tagged-literal 'foo [1]))))))
28162817

28172818
(defn- incme []
28182819
(let [incme (fn [a queue & args] (inc a))]

0 commit comments

Comments
 (0)