2 ms·
The idea of Smallcheck is to start with minimal values. If we're going to shrink big values to small ones, why not just start with small values in the first pla
by massysett 10y ago
The idea of Smallcheck is to start with minimal values. If we're going to shrink big values to small ones, why not just start with small values in the first place. Smallcheck tests the small values exhaustively rather than randomly.
To be fair though, QuickCheck is not completely random. It has a "size" parameter that starts small and grows, thus allowing small values to be tested first.
- kahnpro 10y agoBecause you're not going to check every small value, it's still random.
- dllthomas 10y ago> If we're going to shrink big values to small ones, why not just start with small values in the first place. Because you want to test things in the order that will most quickly find you a small error. This winds up being a trade-off, and as you say QuickCheck doesn't start with arbitrarily large inputs. But just testing all small inputs in order is often not the best choice. For example, if your function takes an unsigned 32 bit integer, and you've tested inputs 0 through 15161, do you expect you're more likely to find an error next testing 15162, or 4294967295?