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 650650
651651(defprotocol IPending
652652 " 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." ))
656656
657657(defprotocol IWatchable
658658 " Protocol for types that can be watched. Currently only implemented by Atom."
@@ -3014,6 +3014,10 @@ reduces them without incurring seq initialization"
30143014 (set! fn nil )
30153015 s)))
30163016
3017+ IPending
3018+ (-realized? [x]
3019+ (not fn ))
3020+
30173021 IWithMeta
30183022 (-with-meta [coll meta] (LazySeq. meta fn s __hash))
30193023
@@ -9195,7 +9199,7 @@ reduces them without incurring seq initialization"
91959199 value)
91969200
91979201 IPending
9198- (-realized? [d ]
9202+ (-realized? [x ]
91999203 (not f)))
92009204
92019205(defn ^boolean delay?
@@ -9211,8 +9215,8 @@ reduces them without incurring seq initialization"
92119215
92129216(defn ^boolean realized?
92139217 " Returns true if a value has been produced for a delay or lazy sequence."
9214- [d ]
9215- (-realized? d ))
9218+ [x ]
9219+ (-realized? x ))
92169220
92179221(defn- preserving-reduced
92189222 [rf]
Original file line number Diff line number Diff line change 16391639 (is (= '(2 3 ) (next (range 1 4 ))))
16401640 ))
16411641
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+
16421655(deftest test-chunked
16431656 (let [r (range 64 )
16441657 v (into [] r)]
You can’t perform that action at this time.
0 commit comments