Skip to content

Commit

Permalink
[proptest-state-machine] Introduce Sequential::new ctor (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaseizinger authored Sep 22, 2024
1 parent a3cc4a5 commit 52d3a38
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions proptest-state-machine/src/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ pub trait ReferenceStateMachine {
BoxedStrategy<Self::State>,
BoxedStrategy<Self::Transition>,
> {
Sequential {
size: size.into(),
init_state: Self::init_state,
preconditions: Self::preconditions,
transitions: Self::transitions,
next: Self::apply,
}
Sequential::new(
size.into(),
Self::init_state,
Self::preconditions,
Self::transitions,
Self::apply,
)
}
}

Expand Down Expand Up @@ -146,6 +146,26 @@ pub struct Sequential<State, Transition, StateStrategy, TransitionStrategy> {
next: fn(state: State, transition: &Transition) -> State,
}

impl<State, Transition, StateStrategy, TransitionStrategy>
Sequential<State, Transition, StateStrategy, TransitionStrategy>
{
pub fn new(
size: SizeRange,
init_state: fn() -> StateStrategy,
preconditions: fn(state: &State, transition: &Transition) -> bool,
transitions: fn(state: &State) -> TransitionStrategy,
next: fn(state: State, transition: &Transition) -> State,
) -> Self {
Self {
size,
init_state,
preconditions,
transitions,
next,
}
}
}

impl<State, Transition, StateStrategy, TransitionStrategy> Debug
for Sequential<State, Transition, StateStrategy, TransitionStrategy>
{
Expand Down

0 comments on commit 52d3a38

Please sign in to comment.