pub struct Sequential<State, Transition, StateStrategy, TransitionStrategy> { /* private fields */ }Expand description
In a sequential state machine strategy, we first generate an acceptable
sequence of transitions. That is a sequence that satisfies the given
pre-conditions. The acceptability of each transition in the sequence depends
on the current state of the state machine, which is updated by the
transitions with the next function.
The shrinking strategy is to iteratively apply Shrink::InitialState,
Shrink::DeleteTransition and Shrink::Transition.
- We start by trying to delete transitions from the back of the list that
were never seen by the test, if any. Note that because proptest expects
deterministic results in for reproducible issues, unlike the following
steps this step will not be undone on
complicate. If there were any unseen transitions, then the next step will start at trying to delete the transition before the last one seen as we know that the last transition cannot be deleted as it’s the one that has failed. - Then, we keep trying to delete transitions from the back of the list, until we can do so no further (reached the beginning of the list)..
- Then, we again iteratively attempt to shrink the individual transitions, but this time starting from the front of the list - i.e. from the first transition to be applied.
- Finally, we try to shrink the initial state until it’s not possible to shrink it any further.
For complicate, we attempt to undo the last shrink operation, if there was
any.
Implementations§
Source§impl<State, Transition, StateStrategy, TransitionStrategy> Sequential<State, Transition, StateStrategy, TransitionStrategy>where
State: 'static,
Transition: 'static,
StateStrategy: 'static,
TransitionStrategy: 'static,
impl<State, Transition, StateStrategy, TransitionStrategy> Sequential<State, Transition, StateStrategy, TransitionStrategy>where
State: 'static,
Transition: 'static,
StateStrategy: 'static,
TransitionStrategy: 'static,
pub fn new( size: SizeRange, init_state: impl Fn() -> StateStrategy + 'static + Send + Sync, preconditions: impl Fn(&State, &Transition) -> bool + 'static + Send + Sync, transitions: impl Fn(&State) -> TransitionStrategy + 'static + Send + Sync, next: impl Fn(State, &Transition) -> State + 'static + Send + Sync, ) -> Self
Trait Implementations§
Source§impl<State, Transition, StateStrategy, TransitionStrategy> Debug for Sequential<State, Transition, StateStrategy, TransitionStrategy>
impl<State, Transition, StateStrategy, TransitionStrategy> Debug for Sequential<State, Transition, StateStrategy, TransitionStrategy>
Source§impl<State: Clone + Debug, Transition: Clone + Debug, StateStrategy: Strategy<Value = State>, TransitionStrategy: Strategy<Value = Transition>> Strategy for Sequential<State, Transition, StateStrategy, TransitionStrategy>
impl<State: Clone + Debug, Transition: Clone + Debug, StateStrategy: Strategy<Value = State>, TransitionStrategy: Strategy<Value = Transition>> Strategy for Sequential<State, Transition, StateStrategy, TransitionStrategy>
Source§type Tree = SequentialValueTree<State, Transition, <StateStrategy as Strategy>::Tree, <TransitionStrategy as Strategy>::Tree>
type Tree = SequentialValueTree<State, Transition, <StateStrategy as Strategy>::Tree, <TransitionStrategy as Strategy>::Tree>
The value tree generated by this
Strategy.Source§type Value = (State, Vec<Transition>, Option<Arc<Atomic<usize>>>)
type Value = (State, Vec<Transition>, Option<Arc<Atomic<usize>>>)
The type of value used by functions under test generated by this Strategy. Read more
Source§fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>
fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>
Generate a new value tree from the given runner. Read more
Source§fn prop_map<O, F>(self, fun: F) -> Map<Self, F>
fn prop_map<O, F>(self, fun: F) -> Map<Self, F>
Returns a strategy which produces values transformed by the function
fun. Read moreSource§fn prop_map_into<O>(self) -> MapInto<Self, O>
fn prop_map_into<O>(self) -> MapInto<Self, O>
Source§fn prop_perturb<O, F>(self, fun: F) -> Perturb<Self, F>
fn prop_perturb<O, F>(self, fun: F) -> Perturb<Self, F>
Returns a strategy which produces values transformed by the function
fun, which is additionally given a random number generator. Read moreSource§fn prop_flat_map<S, F>(self, fun: F) -> Flatten<Map<Self, F>>
fn prop_flat_map<S, F>(self, fun: F) -> Flatten<Map<Self, F>>
Maps values produced by this strategy into new strategies and picks
values from those strategies. Read more
Source§fn prop_ind_flat_map<S, F>(self, fun: F) -> IndFlatten<Map<Self, F>>
fn prop_ind_flat_map<S, F>(self, fun: F) -> IndFlatten<Map<Self, F>>
Maps values produced by this strategy into new strategies and picks
values from those strategies while considering the new strategies to be
independent. Read more
Source§fn prop_ind_flat_map2<S, F>(self, fun: F) -> IndFlattenMap<Self, F>
fn prop_ind_flat_map2<S, F>(self, fun: F) -> IndFlattenMap<Self, F>
Similar to
prop_ind_flat_map(), but produces 2-tuples with the input
generated from self in slot 0 and the derived strategy in slot 1. Read moreSource§fn prop_filter<R, F>(self, whence: R, fun: F) -> Filter<Self, F>
fn prop_filter<R, F>(self, whence: R, fun: F) -> Filter<Self, F>
Returns a strategy which only produces values accepted by
fun. Read moreSource§fn prop_filter_map<F, O>(
self,
whence: impl Into<Reason>,
fun: F,
) -> FilterMap<Self, F>
fn prop_filter_map<F, O>( self, whence: impl Into<Reason>, fun: F, ) -> FilterMap<Self, F>
Returns a strategy which only produces transformed values where
fun
returns Some(value) and rejects those where fun returns None. Read moreSource§fn prop_union(self, other: Self) -> Union<Self>where
Self: Sized,
fn prop_union(self, other: Self) -> Union<Self>where
Self: Sized,
Source§fn prop_recursive<R, F>(
self,
depth: u32,
desired_size: u32,
expected_branch_size: u32,
recurse: F,
) -> Recursive<Self::Value, F>
fn prop_recursive<R, F>( self, depth: u32, desired_size: u32, expected_branch_size: u32, recurse: F, ) -> Recursive<Self::Value, F>
Generate a recursive structure with
self items as leaves. Read moreSource§fn prop_shuffle(self) -> Shuffle<Self>
fn prop_shuffle(self) -> Shuffle<Self>
Shuffle the contents of the values produced by this strategy. Read more
Source§fn boxed(self) -> BoxedStrategy<Self::Value>where
Self: Sized + 'static,
fn boxed(self) -> BoxedStrategy<Self::Value>where
Self: Sized + 'static,
Erases the type of this
Strategy so it can be passed around as a
simple trait object. Read moreAuto Trait Implementations§
impl<State, Transition, StateStrategy, TransitionStrategy> Freeze for Sequential<State, Transition, StateStrategy, TransitionStrategy>
impl<State, Transition, StateStrategy, TransitionStrategy> !RefUnwindSafe for Sequential<State, Transition, StateStrategy, TransitionStrategy>
impl<State, Transition, StateStrategy, TransitionStrategy> Send for Sequential<State, Transition, StateStrategy, TransitionStrategy>
impl<State, Transition, StateStrategy, TransitionStrategy> Sync for Sequential<State, Transition, StateStrategy, TransitionStrategy>
impl<State, Transition, StateStrategy, TransitionStrategy> Unpin for Sequential<State, Transition, StateStrategy, TransitionStrategy>
impl<State, Transition, StateStrategy, TransitionStrategy> UnsafeUnpin for Sequential<State, Transition, StateStrategy, TransitionStrategy>
impl<State, Transition, StateStrategy, TransitionStrategy> !UnwindSafe for Sequential<State, Transition, StateStrategy, TransitionStrategy>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more