Skip to main content

Sequential

Struct Sequential 

Source
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.

  1. 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.
  2. 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)..
  3. 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.
  4. 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,

Source

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>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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>

The value tree generated by this Strategy.
Source§

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>

Generate a new value tree from the given runner. Read more
Source§

fn prop_map<O, F>(self, fun: F) -> Map<Self, F>
where O: Debug, F: Fn(Self::Value) -> O, Self: Sized,

Returns a strategy which produces values transformed by the function fun. Read more
Source§

fn prop_map_into<O>(self) -> MapInto<Self, O>
where O: Debug, Self: Sized, Self::Value: Into<O>,

Returns a strategy which produces values of type O by transforming Self with Into<O>. Read more
Source§

fn prop_perturb<O, F>(self, fun: F) -> Perturb<Self, F>
where O: Debug, F: Fn(Self::Value, TestRng) -> O, Self: Sized,

Returns a strategy which produces values transformed by the function fun, which is additionally given a random number generator. Read more
Source§

fn prop_flat_map<S, F>(self, fun: F) -> Flatten<Map<Self, F>>
where S: Strategy, F: Fn(Self::Value) -> S, Self: Sized,

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>>
where S: Strategy, F: Fn(Self::Value) -> S, Self: Sized,

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>
where S: Strategy, F: Fn(Self::Value) -> S, Self: Sized,

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 more
Source§

fn prop_filter<R, F>(self, whence: R, fun: F) -> Filter<Self, F>
where R: Into<Reason>, F: Fn(&Self::Value) -> bool, Self: Sized,

Returns a strategy which only produces values accepted by fun. Read more
Source§

fn prop_filter_map<F, O>( self, whence: impl Into<Reason>, fun: F, ) -> FilterMap<Self, F>
where F: Fn(Self::Value) -> Option<O>, O: Debug, Self: Sized,

Returns a strategy which only produces transformed values where fun returns Some(value) and rejects those where fun returns None. Read more
Source§

fn prop_union(self, other: Self) -> Union<Self>
where Self: Sized,

Returns a strategy which picks uniformly from self and other. Read more
Source§

fn prop_recursive<R, F>( self, depth: u32, desired_size: u32, expected_branch_size: u32, recurse: F, ) -> Recursive<Self::Value, F>
where R: Strategy<Value = Self::Value> + 'static, F: Fn(BoxedStrategy<Self::Value>) -> R, Self: Sized + 'static,

Generate a recursive structure with self items as leaves. Read more
Source§

fn prop_shuffle(self) -> Shuffle<Self>
where Self: Sized, Self::Value: Shuffleable,

Shuffle the contents of the values produced by this strategy. Read more
Source§

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 more
Source§

fn sboxed(self) -> SBoxedStrategy<Self::Value>
where Self: Sized + Send + Sync + 'static,

Erases the type of this Strategy so it can be passed around as a simple trait object. Read more
Source§

fn no_shrink(self) -> NoShrink<Self>
where Self: Sized,

Wraps this strategy to prevent values from being subject to shrinking. Read more

Auto 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V