-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
p2p-governor: Extend the shrinker tests: test that the shrinkers shrink!
Some shrinkers are tricky. One easy mistake is that a shrinker does not return a smaller value. This will likely cause the shrinking to cycle indefinately, which is annoying when you're trying to track down a failing test case! To do this properly would require an appropriate measure of size (which is specific to the shinker, not an existing notion of size). This is possible but needs quite a bit of additional infrastructure. We take a short cut by observing that most shrinker bugs are simple 1-cycles where the "shrunk" value is actually equal to the original. If we only detect these cases we should still get most of these bugs. This has the important advantage of only relying on equality and not on a size measure, so no extra infrastructure per type is needed. So we simply add: prop_shrink_nonequal = all (x /=) (shrink x) And we use that in existing shrinker tests (where we already check that invariants are preserved), and add shrinker tests for some types that did not have them already. In particular this test still catches the GovernorScripts bug that we had previously.
- Loading branch information
Showing
6 changed files
with
66 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters