testing 2023-03-08

Does anyone have any strategies they like to verify that a function returns an actually lazy sequence?

is realized? not working for your use case? https://clojuredocs.org/clojure.core/realized_q

I suppose I can hack it by using instance? for the lazy classes I expect

ish. stuff like (range) will bite you

some "things" are both lazy or not depending on what consumes them

I guess you can check for all these cases (impl of IReduceInit & co), but that seems quite convoluted. Maybe there's some other way

it's not unique to clj.core either, a few libs take advantage of that

I wonder if mocking would be appropriate here. This may be a terrible idea, but could you create a special class that implements ISeq but throws an exception if realized?