4 ms·
If hypothesis can’t shrink a result further, shouldn’t I expect it to just return the failing result? There’s usually always a point where further shrinking is
by epgui 2y ago
If hypothesis can’t shrink a result further, shouldn’t I expect it to just return the failing result?
There’s usually always a point where further shrinking is not possible.
- kragen 2y agoyes, but if it's too hard to generate an instance your test will accept as a valid instance (not passing, valid), i'd instead expect it to tell you to fix your test, so you can get properly shrunk results, and that's what it did. did you try the different instance generation strategy suggested in the thread? how does clojure.spec.alpha handle this differently?
- epgui 2y agoOn the surface, clojure.spec.alpha seems to handle things more or less similarly (you get random results skewing heavily towards small/trivial/edge values), but the main difference is that it can be used and abused without problem. As long as you can write predicates and compose specs, it handles it for you and “just works”.
- kragen 2y agodid you try the different instance generation strategy suggested in the thread? you make it sound like clojure.spec.alpha doesn't do shrinking at all. possibly you don't know what shrinking is? shrinking keeps your results from looking "random" by simplifying them until all the simpler versions of the test case pass, so it finds the simplest failing case instead of a "random" one. this also enables hypothesis to be a lot more aggressive at looking for failing cases, for example by generating much larger test data sets than you would want to pore over, because if it finds one that fails, it will shrink it before showing it to you if i've misunderstood you and clojure.spec.alpha does do shrinking, what does it do in the case where your test case is written to reject all but an exponentially small fraction of shrunk cases? does it just take an exponentially long time to run your test suite? is that what you mean by 'just works'?
- kragen 2y agoi guess you didn't try the different instance generation strategy suggested in the thread, since i asked three times and you didn't answer three times