4 ms·
If only your core logic had some straightforward invariants... QuickCheck can work effectively with complex data structures. For an example of a simple invari
by mbrock 10y ago
If only your core logic had some straightforward invariants...
QuickCheck can work effectively with complex data structures.
For an example of a simple invariant that can still uncover subtle and important bugs:
encode(decode(X)) = X
Where encode and decode are some domain specific blobs of protocol logic. It's pretty useful to have the computer verify that isomorphism with a huge number of generated inputs.
(There's also SmallCheck which is like QuickCheck but checking all possible values within some depth limit, instead of random values.)
And there's no reason you couldn't use QuickCheck to verify a performance law, by the way.
- dllthomas 10y ago> And there's no reason you couldn't use QuickCheck to verify a performance law, by the way. In fact, I've done something similar to this.
- taeric 10y agoI'd be interested in seeing how you did this.
- dllthomas 10y agoMore precisely what I did was minimization on an unusually slow example input, but I don't think I can share the code. The approach generalizes, though: To verify performance, you would set it up to benchmark the code in question (in Haskell, this would probably mean using Criterion) and then assert that it was "fast enough" (probably relative to the size of the input).
- taeric 10y agoMy complaint was less against quick check, and more against the examples. Pedagogically themed ideas make sense. Practical and visible results are better. By orders of magnitude.