BurntSushi / quickcheck

Automated property based testing for Rust (with shrinking).
The Unlicense
2.4k stars 149 forks source link

Added lazy shrinking for Vec #74

Closed Marwes closed 9 years ago

Marwes commented 9 years ago

Adds lazy shrinking for Vec. I have not bench marked this implementation but considering that it does not additional work it should be roughly as fast when the entire iterator is used and significantly faster otherwise.

I added the behavior where the empty vector is added as the first element to the iterator though I could not find this behavior in quickcheck for haskell. Considering how the shrunk vectors actually looks I'd be partial to removing that special case in case I can update this PR.

Fixes #4.

BurntSushi commented 9 years ago

\o/

This. Is. Awesome!!

BurntSushi commented 9 years ago

RE empty vec: I can't remember precisely why I did this, I probably thought "check a common corner case first." I don't have a strong opinion about it, but it does seem like a sensible thing to do unless there are downsides that I'm not considering.

BurntSushi commented 9 years ago

I've uploaded this to crates.io in 0.2.14.

Marwes commented 9 years ago

I'm not entirely familiar with the inner workings of quickcheck but running verboseCheck in Haskell it seems that the empty list is naturally generated since it starts by testing small values. Not sure if you do this though.