pubgrub-rs / pubgrub

PubGrub version solving algorithm implemented in Rust
https://pubgrub-rs.github.io/pubgrub/pubgrub/
Mozilla Public License 2.0
337 stars 30 forks source link

Better tools for testing `Ord` and `VersionSet` #113

Open Eh2406 opened 2 years ago

Eh2406 commented 2 years ago

Mostly a follow-up to this comment: https://github.com/pubgrub-rs/pubgrub/pull/108#issuecomment-1038437430

But we should provide some way for a user to run "all the tests we can think of" on their types. Not only that we should be using those tests on our types. And they should be documented in the user guide.

May be functions like tests_on_a_version<VS: VersionSet>(v: VS::V) , tests_on_two_versions<VS: VersionSet>(v1: VS::V, v2: VS::V), tests_on_a_set<VS: VersionSet>(vs: VS), etc. that panic if they find a property that doesn't hold. On the other hand that doesn't give a good error message about which property didn't hold.

So maybe a set of functions not_contained_in_empty<VS: VersionSet>(v: VS::V), contained_in_full<VS: VersionSet>(v: VS::V), etc. that panic if a particular property is violated. But then it can be annoying for our users to make one test per property. Maybe we can solve this with a macro somehow?