gopter
gopter copied to clipboard
Are there resources to learn about shrinking algorithms?
Property based tests are great tools to assert properties of an API. Though I haven't done it in Go, this package looks useful.
I'm more curious about the implementation and the algorithm. Do you know any references or papers I could read?
There is a blog article summing up the the interna of scalacheck: https://blog.ssanj.net/posts/2017-04-12-how-does-scalacheck-shrinking-work.html
And there are several some material about QuickCheck, though I haven't read those.
The tests for Int64Shrinker follow a different pattern to the examples in the linked article; is this intentional? I.e. the tests shrink 10 into 0, 5, -5, 8, -8, 9, -9; whereas I would have expected 5, -5, 3, -3, 2, -2, 1, -1, 0. That is to say that the test, like Zeno's tortoise, continually advance towards the shunk value but never reach it instead of exponentially decaying towards zero.
I have come across this article that seems to take a similar approach as gopter (at least in the ordering/direction of the shrinking values): https://deque.blog/2017/02/10/code-your-own-quickcheck-shrink/
Is this the kind of approach that gopter takes?