hedgehogqa / haskell-hedgehog

Release with confidence, state-of-the-art property testing for Haskell.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question regarding list generation

rndnoise opened this issue · comments

I'm reading some of the code to better understand how this library works, and I saw this definition of Gen.list. Can you explain the use of ensure (atLeast ...) here?

From what I can tell, it is checking that the generated list is at least as big as the lower bound of the (potentially) size-dependent range. Is that not guaranteed by the way the list is constructed though? To generate the list you have n <- integral_ range which should pick a number no less than the lower bound of that range, then you generate n items.

Thanks for publishing this library. I've used QuickCheck for a long time, so being able to automatically minimize test cases without having to write a definition for shrink is really great!

Eventually I figured it out. That bit ensures shrunken lists aren't smaller than the given lower bound.