Fork me on GitHub
#testing
<
2023-03-08
>
arohner13:03:48

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

arohner13:03:12

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

mpenet13:03:07

ish. stuff like (range) will bite you

mpenet13:03:24

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

mpenet13:03:08

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

mpenet13:03:41

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

Alys Brooks05:03:13

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?