-
Notifications
You must be signed in to change notification settings - Fork 2
diff-containers: Test preconditions, invariants and postconditions for positivity and normality.
#16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
3c78927 to
65bd594
Compare
* Better explain unresolved sums and subtractions. * Better explain positivity and normality. * Remove duplicate module documentation. * Refactor `isNormalDiffHistory` to use `zip`. * Preserve invariants in shrinkers. * Be more explicit about normality/normal form.
|
@dnadales @jasagredo I have added tests for the generators/shrinkers. While writing them, I also realised that "positivity implies normality": a positive diff or diff history is by definition also normal. So I've added a test for that as well, and the documentation now also mentions this |
* Test generators * Remove implications that are no satisfied by generators. * New property: positivity implies normality
7d59dff to
47aaf2b
Compare
dnadales
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I'm really happy with the tests for the generators
Precursor reference: #15 (comment)
#15 brought back unsafe constructors in the
diff-containerspackage. A side-effect of this is that we can not hide the internals (Data.Map.Diff.Strict.Internal) behind a truly safe interface (Data.Map.Diff.Strict). Instead, downstream code now has the responsibility to use the semi-safe interface faithfully.What it means to use diffs in a safe way is now documented in the code, amongst others using PRECONDITION, INVARIANT and POSTCONDITION annotations. This PR also introduces tests for these properties.
The invariant for downstream code to uphold is to only ever apply diffs that are both "normal" and "positive". Faithful use of the API should prevent this from happening.
The README that will be added in resolving #8 will explain both the normality and positivity properties, and it will contain examples of use cases.