4 ms·
QuickCheck generates its own test cases and possible shapes. More importantly, it tries all possible constructors of a type (or a reasonable number). So you're
by maweki 5y ago
QuickCheck generates its own test cases and possible shapes. More importantly, it tries all possible constructors of a type (or a reasonable number). So you're reasonably confident that you tried a lot of "shape-cases".
- eru 5y ago> it tries all possible constructors of a type It tries a 'reasonable' number. If you want to try everything, have a look at SmallCheck. I would imagine you would want to combine Beartype with tests, too. Perhaps written manually, or with test data generated via Hypothesis.
- More-nitors 5y agobut not all cases are generated.. for example, if I have an external api response that I'd like to validate, beartype fails to do so.
- chriswarbo 5y ago> If you want to try everything, have a look at SmallCheck. FYI my favourite approach is LazySmallCheck, which runs tests with an unevaluated input, and only generates data if the input gets forced; at which point it runs the test for each constructor. The original version lacked some useful generators, like functions; the "LazySmallCheck2012" fork added these (e.g. generating functions in terms of an input/output lookup table), but overall these libraries seem to be unmaintained :( IIRC there are also similar alternatives based around Prolog-like search.
- maweki 5y agoI'm pretty sure that SmallCheck also doesn't try out every constructor for Integer.
- eru 5y agoYes, and I carefully formulated my sentence not to say that. :)