Fork me on GitHub

@samedhi well... they're not equivalent, because a optional key is different to a required key which is a (possibly empty) map. it seems like the generator produced by map-of just doesn't produce empty maps often enough to avoid blowing the stack


you need to be able to reference something before it's defined in order to support recursive specs, which is an intended feature


Hmm, interesting. It appears that I am referring to ::posts from within ::post before ::posts actually exist…


yes, that's intended to be supported


I don't know enough about how generators work, I'm guessing it's more sophisticated than just random so that's why it's managing to find the pathological case of a very deeply nested tree every time


Yes, a lot of the complexity in generators comes from the feature of shrinking. When you get a test failure with a generator, test.check will try to shrink the possible data set to give you the smallest failing test. So instead of giving you "Failure when I tried: [123123121 55 3 9 5 23 4]" It may say: "Failure when I tried: [0 2]". And that tells you a lot about went wrong:


for example you know that the vector has to be at least two items long (it didn't fail when there was only one value in the vector). And that the second number has to be larger than one: (since 0 and 1 didn't cause it to fail).


That sort of information is very helpful in debugging, but requires a lot of backtracking in the generator, and that's what makes them so hard to write/understand.


I would love to know the "right" way to make the generators work for the recursive structure above