Closed henriiik closed 3 months ago
thank you @henriiik, will take a look
Thanks for picking this up, let me know if you want me to help in any way :)
Thanks again @henriiik, I'd like to add the following changes:
seen_transitions_counter
from fn current
separately without wrapping the transitions in ObservedVec
and increment the counter from StateMachineTest::test_sequential
.fn complicate
. This is unlike the other Shrink
cases where we don't know if the shrinking will affect the result. Furthermore, we only need to count the seen transitions before shrinking as it shouldn't have any effect anymore when we're removing transitions 1-by-1.Remove the first panicking check in fn current
- it prevents multiple refs to seen_transitions_counter
which should not be necessary, we can allow multiple refs if needed for customization. I kept the second condition, but slightly changed the message.
The last 2 fixup commits make these changes, if you could pls check them over to make sure that this still works for your use-case.
I've opened #434 with the fixups squashed, I can push it back here if you're happy with the changes
@tzemanovic Looks good to me!
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 typeObservedVec<T>
. This new type contains a counter that is shared withSequentialValueTree
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 callcurrent
multiple times without callingsimplify
and/orcomplicate
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 tocurrent
which produces a value that is used in a test run and based on the test resultsimplify
orcomplicate
is called at least one time before the next iteration.Any feedback would be welcome!