Trait proptest::strategy::ValueTree
[−]
[src]
pub trait ValueTree { type Value: Debug; fn current(&self) -> Self::Value; fn simplify(&mut self) -> bool; fn complicate(&mut self) -> bool; }
A generated value and its associated shrinker.
Conceptually, a ValueTree
represents a spectrum between a "minimally
complex" value and a starting, randomly-chosen value. For values such as
numbers, this can be thought of as a simple binary search, and this is how
the ValueTree
state machine is defined.
The ValueTree
state machine notionally has three fields: low, current,
and high. Initially, low is the "minimally complex" value for the type, and
high and current are both the initially chosen value. It can be queried for
its current state. When shrinking, the controlling code tries simplifying
the value one step. If the test failure still happens with the simplified
value, further simplification occurs. Otherwise, the code steps back up
towards the prior complexity.
The main invariants here are that the "high" value always corresponds to a
failing test case, and that repeated calls to complicate()
will return
false
only once the "current" value has returned to what it was before
the last call to simplify()
.
Associated Types
Required Methods
fn current(&self) -> Self::Value
Returns the current value.
fn simplify(&mut self) -> bool
Attempts to simplify the current value. Notionally, this sets the "high" value to the current value, and the current value to a "halfway point" between high and low, rounding towards low.
Returns whether any state changed as a result of this call.
fn complicate(&mut self) -> bool
Attempts to partially undo the last simplification. Notionally, this sets the "low" value to one plus the current value, and the current value to a "halfway point" between high and the new low, rounding towards low.
Returns whether any state changed as a result of this call.
Implementors
impl<T: ValueTree + ?Sized> ValueTree for Box<T>
impl<S: ValueTree, O: Debug, F: Fn(S::Value) -> O> ValueTree for Map<S, F>
impl<S: ValueTree, F: Fn(&S::Value) -> bool> ValueTree for Filter<S, F>
impl<T: ValueTree> ValueTree for UnionValueTree<T>
impl<T: Clone + Debug> ValueTree for Singleton<T>
impl<T: ValueTree> ValueTree for NoShrink<T>
impl ValueTree for BoolValueTree
impl ValueTree for proptest::num::i8::BinarySearch
impl ValueTree for proptest::num::i16::BinarySearch
impl ValueTree for proptest::num::i32::BinarySearch
impl ValueTree for proptest::num::i64::BinarySearch
impl ValueTree for proptest::num::isize::BinarySearch
impl ValueTree for proptest::num::u8::BinarySearch
impl ValueTree for proptest::num::u16::BinarySearch
impl ValueTree for proptest::num::u32::BinarySearch
impl ValueTree for proptest::num::u64::BinarySearch
impl ValueTree for proptest::num::usize::BinarySearch
impl ValueTree for proptest::num::f32::BinarySearch
impl ValueTree for proptest::num::f64::BinarySearch
impl<T: BitSetLike> ValueTree for BitSetValueTree<T>
impl<A: ValueTree> ValueTree for TupleValueTree<(A,)>
impl<A: ValueTree, B: ValueTree> ValueTree for TupleValueTree<(A, B)>
impl<A: ValueTree, B: ValueTree, C: ValueTree> ValueTree for TupleValueTree<(A, B, C)>
impl<A: ValueTree, B: ValueTree, C: ValueTree, D: ValueTree> ValueTree for TupleValueTree<(A, B, C, D)>
impl<A: ValueTree, B: ValueTree, C: ValueTree, D: ValueTree, E: ValueTree> ValueTree for TupleValueTree<(A, B, C, D, E)>
impl<A: ValueTree, B: ValueTree, C: ValueTree, D: ValueTree, E: ValueTree, F: ValueTree> ValueTree for TupleValueTree<(A, B, C, D, E, F)>
impl<A: ValueTree, B: ValueTree, C: ValueTree, D: ValueTree, E: ValueTree, F: ValueTree, G: ValueTree> ValueTree for TupleValueTree<(A, B, C, D, E, F, G)>
impl<A: ValueTree, B: ValueTree, C: ValueTree, D: ValueTree, E: ValueTree, F: ValueTree, G: ValueTree, H: ValueTree> ValueTree for TupleValueTree<(A, B, C, D, E, F, G, H)>
impl<A: ValueTree, B: ValueTree, C: ValueTree, D: ValueTree, E: ValueTree, F: ValueTree, G: ValueTree, H: ValueTree, I: ValueTree> ValueTree for TupleValueTree<(A, B, C, D, E, F, G, H, I)>
impl<A: ValueTree, B: ValueTree, C: ValueTree, D: ValueTree, E: ValueTree, F: ValueTree, G: ValueTree, H: ValueTree, I: ValueTree, J: ValueTree> ValueTree for TupleValueTree<(A, B, C, D, E, F, G, H, I, J)>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 1]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 2]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 3]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 4]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 5]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 6]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 7]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 8]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 9]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 10]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 11]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 12]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 13]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 14]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 15]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 16]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 17]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 18]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 19]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 20]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 21]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 22]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 23]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 24]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 25]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 26]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 27]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 28]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 29]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 30]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 31]>
impl<T: ValueTree> ValueTree for ArrayValueTree<[T; 32]>
impl<T: ValueTree> ValueTree for VecValueTree<T>
impl ValueTree for CharValueTree