proptest-rs / proptest

Hypothesis-like property testing for Rust
Apache License 2.0
1.63k stars 152 forks source link

Delete unseen transitions in state machine test #388

Closed henriiik closed 3 months ago

henriiik commented 8 months ago

This PR adds a new shrinking step to proptest_state_machine::SequentialValueTree that deletes all transitions not seen by the test runner as the first step. This is related to #387.

To do that it changes the value type from a Vec<Transition> to a new wrapper type ObservedVec<T>. This new type contains a counter that is shared with SequentialValueTree and keeps track of how many transitions have been seen by the test runner.

The shared counter is reset on each call to simplify / complicate, therefore it is no longer valid to call current multiple times without calling simplify and/or complicate in between.

Given my (admittedly limited) understanding of how proptest works this is not an issue as the intention is for the value tree to be used in a loop where each iteration starts with a call to current which produces a value that is used in a test run and based on the test result simplify or complicate is called at least one time before the next iteration.

Any feedback would be welcome!

tzemanovic commented 8 months ago

thank you @henriiik, will take a look

tzemanovic commented 3 months ago

I've rebased the branch on proptest-state-machine-0.2.0 and added couple fix-ups (4c8696d and 0aa8087 - should be squashed before merging)

I've got some more changes that I'd like to add WIP, will update here soon

henriiik commented 3 months ago

Thanks for picking this up, let me know if you want me to help in any way :)

tzemanovic commented 3 months ago

Thanks again @henriiik, I'd like to add the following changes:

tzemanovic commented 3 months ago

I've opened #434 with the fixups squashed, I can push it back here if you're happy with the changes

henriiik commented 3 months ago

@tzemanovic Looks good to me!