proptest-rs / proptest

Hypothesis-like property testing for Rust
Apache License 2.0
1.74k stars 161 forks source link

Finite state machines #446

Open mirosval opened 7 months ago

mirosval commented 7 months ago

Both examples in https://github.com/proptest-rs/proptest/tree/master/proptest-state-machine/examples seem to be infinite state machines.

I'm trying to use proptest for a finite state machine, but I'm having trouble finding a way to express that. I have 2 problems:

  1. Explaining to the strategy that it found the terminal state and should stop a. If I always return false from preconditions I get the error below b. It doesn't seem to be possible to create an empty Strategy, that just wouldn't produce new states from transitions
  2. I have a transition function in my STM that returns Result<Self, Error> when the supplied transition was not valid for the current state, this is not possible in the current ReferenceStateMachine, though I guess it could be worked around by implementing ReferenceStateMachine for a wrapper type
Test aborted: Too many local rejects
        successes: 1
        local rejects: 65536
                65536 times at Pre-conditions were not satisfied
        global rejects: 0
matthew-russo commented 5 months ago

Thanks for the feedback and sorry for the delay.

Taking a step back from the current status of proptest-state-machine what would be the ideal situation you're looking for? Are you trying to emulate something you've done with other lanaguages/libraries? If so can you share examples? If not, could you describe how you would have expected things to work from an interface perspective. proptest-state-machine is a pre-1.0 release where we're trying to figure out the right things to offer so I don't want to get stuck too much in its current interfaces when thinking about new use cases.