pub trait Testable<S>: 'static
where S: Sample,
{ // Required method fn result(&self, v: S::Output) -> TestResult; // Provided methods fn test_once(&self, s: &mut S, rng: &mut Random) -> TestResult where S::Output: Clone + Debug { ... } fn shrink(&self, s: &S, r: TestResult, v: S::Output) -> TestResult where S::Output: Clone + Debug { ... } }
Expand description

Testable describes types (e.g., a function) whose values can be tested.

Anything that can be tested must be capable of producing a TestResult from the output of an instance of Sample.

It’s unlikely that you’ll have to implement this trait yourself.

Required Methods§

source

fn result(&self, v: S::Output) -> TestResult

Report a TestResult from a given value.

Provided Methods§

source

fn test_once(&self, s: &mut S, rng: &mut Random) -> TestResult
where S::Output: Clone + Debug,

Convenience function for running this Testable once on a random value, and shrinking any failures.

source

fn shrink(&self, s: &S, r: TestResult, v: S::Output) -> TestResult
where S::Output: Clone + Debug,

Iteratively shrink the given test result until the iteration limit is reached or no further shrinkage is possible.

Implementations on Foreign Types§

source§

impl<T: 'static, S, A> Testable<S> for fn(_: A) -> T
where TestResult: From<T>, S: Sample<Output = (A,)>, (A,): Clone, A: Debug + 'static,

source§

fn result(&self, v: S::Output) -> TestResult

source§

impl<T: 'static, S, A, B> Testable<S> for fn(_: A, _: B) -> T
where TestResult: From<T>, S: Sample<Output = (A, B)>, (A, B): Clone, A: Debug + 'static, B: Debug + 'static,

source§

fn result(&self, v: S::Output) -> TestResult

source§

impl<T: 'static, S, A, B, C> Testable<S> for fn(_: A, _: B, _: C) -> T
where TestResult: From<T>, S: Sample<Output = (A, B, C)>, (A, B, C): Clone, A: Debug + 'static, B: Debug + 'static, C: Debug + 'static,

source§

fn result(&self, v: S::Output) -> TestResult

source§

impl<T: 'static, S, A, B, C, D> Testable<S> for fn(_: A, _: B, _: C, _: D) -> T
where TestResult: From<T>, S: Sample<Output = (A, B, C, D)>, (A, B, C, D): Clone, A: Debug + 'static, B: Debug + 'static, C: Debug + 'static, D: Debug + 'static,

source§

fn result(&self, v: S::Output) -> TestResult

source§

impl<T: 'static, S, A, B, C, D, E> Testable<S> for fn(_: A, _: B, _: C, _: D, _: E) -> T
where TestResult: From<T>, S: Sample<Output = (A, B, C, D, E)>, (A, B, C, D, E): Clone, A: Debug + 'static, B: Debug + 'static, C: Debug + 'static, D: Debug + 'static, E: Debug + 'static,

source§

fn result(&self, v: S::Output) -> TestResult

source§

impl<T: 'static, S, A, B, C, D, E, F> Testable<S> for fn(_: A, _: B, _: C, _: D, _: E, _: F) -> T
where TestResult: From<T>, S: Sample<Output = (A, B, C, D, E, F)>, (A, B, C, D, E, F): Clone, A: Debug + 'static, B: Debug + 'static, C: Debug + 'static, D: Debug + 'static, E: Debug + 'static, F: Debug + 'static,

source§

fn result(&self, v: S::Output) -> TestResult

source§

impl<T: 'static, S, A, B, C, D, E, F, G> Testable<S> for fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G) -> T
where TestResult: From<T>, S: Sample<Output = (A, B, C, D, E, F, G)>, (A, B, C, D, E, F, G): Clone, A: Debug + 'static, B: Debug + 'static, C: Debug + 'static, D: Debug + 'static, E: Debug + 'static, F: Debug + 'static, G: Debug + 'static,

source§

fn result(&self, v: S::Output) -> TestResult

source§

impl<T: 'static, S, A, B, C, D, E, F, G, H> Testable<S> for fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H) -> T
where TestResult: From<T>, S: Sample<Output = (A, B, C, D, E, F, G, H)>, (A, B, C, D, E, F, G, H): Clone, A: Debug + 'static, B: Debug + 'static, C: Debug + 'static, D: Debug + 'static, E: Debug + 'static, F: Debug + 'static, G: Debug + 'static, H: Debug + 'static,

source§

fn result(&self, v: S::Output) -> TestResult

Implementors§