Skip to content

Commit 52112c5

Browse files
committed
CLJS-2934: Enhanced delay printing
1 parent 0e3d4f1 commit 52112c5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10395,7 +10395,13 @@ reduces them without incurring seq initialization"
1039510395

1039610396
IPending
1039710397
(-realized? [x]
10398-
(not f)))
10398+
(not f))
10399+
10400+
IPrintWithWriter
10401+
(-pr-writer [x writer opts]
10402+
(-write writer "#object[cljs.core.Delay ")
10403+
(pr-writer {:status (if (nil? f) :ready :pending), :val value} writer opts)
10404+
(-write writer "]")))
1039910405

1040010406
(defn ^boolean delay?
1040110407
"returns true if x is a Delay created with delay"

src/test/cljs/cljs/core_test.cljs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,6 +1633,12 @@
16331633
(is (= "xyzzy" (str "x" "y" "z" "z" "y")))
16341634
(is (= "a1b2c3" (str "a" 1 "b" 2 "c" 3))))
16351635

1636+
(deftest test-cljs-2934
1637+
(let [x (delay 1)]
1638+
(is (= "#object[cljs.core.Delay {:status :pending, :val nil}]" (pr-str x)))
1639+
(force x)
1640+
(is (= "#object[cljs.core.Delay {:status :ready, :val 1}]" (pr-str x)))))
1641+
16361642
(deftest test-cljs-2943
16371643
(let [m1 {:a 2, :b 3, :c 5}
16381644
m2 {:a 7, :b 11, :d 13, :e 17}

0 commit comments

Comments
 (0)