File tree Expand file tree Collapse file tree 2 files changed +23
-6
lines changed Expand file tree Collapse file tree 2 files changed +23
-6
lines changed Original file line number Diff line number Diff line change 650
650
651
651
(defprotocol IPending
652
652
" Protocol for types which can have a deferred realization. Currently only
653
- implemented by Delay."
654
- (^boolean -realized? [d ]
655
- " Returns true if a value for d has been produced, false otherwise." ))
653
+ implemented by Delay and LazySeq ."
654
+ (^boolean -realized? [x ]
655
+ " Returns true if a value for x has been produced, false otherwise." ))
656
656
657
657
(defprotocol IWatchable
658
658
" Protocol for types that can be watched. Currently only implemented by Atom."
@@ -3014,6 +3014,10 @@ reduces them without incurring seq initialization"
3014
3014
(set! fn nil )
3015
3015
s)))
3016
3016
3017
+ IPending
3018
+ (-realized? [x]
3019
+ (not fn ))
3020
+
3017
3021
IWithMeta
3018
3022
(-with-meta [coll meta] (LazySeq. meta fn s __hash))
3019
3023
@@ -9195,7 +9199,7 @@ reduces them without incurring seq initialization"
9195
9199
value)
9196
9200
9197
9201
IPending
9198
- (-realized? [d ]
9202
+ (-realized? [x ]
9199
9203
(not f)))
9200
9204
9201
9205
(defn ^boolean delay?
@@ -9211,8 +9215,8 @@ reduces them without incurring seq initialization"
9211
9215
9212
9216
(defn ^boolean realized?
9213
9217
" Returns true if a value has been produced for a delay or lazy sequence."
9214
- [d ]
9215
- (-realized? d ))
9218
+ [x ]
9219
+ (-realized? x ))
9216
9220
9217
9221
(defn- preserving-reduced
9218
9222
[rf]
Original file line number Diff line number Diff line change 1639
1639
(is (= '(2 3 ) (next (range 1 4 ))))
1640
1640
))
1641
1641
1642
+ (deftest test-lazy-seq-realized?
1643
+ (testing " Testing LazySeq IPending"
1644
+ (let [xs (lazy-seq
1645
+ (cons 1
1646
+ (lazy-seq
1647
+ (cons 2
1648
+ (lazy-seq (cons 3 nil ))))))]
1649
+ (is (not (realized? xs)))
1650
+ (is (not (realized? (rest xs))))
1651
+ (is (realized? xs))
1652
+ (is (not (realized? (nthrest xs 2 ))))
1653
+ (is (realized? (rest xs))))))
1654
+
1642
1655
(deftest test-chunked
1643
1656
(let [r (range 64 )
1644
1657
v (into [] r)]
You can’t perform that action at this time.
0 commit comments