Crate proptest_arbitrary [] [src]

NOTE: This version is still WIP; don't use yet, just reserving at crates.io.

Proptest is a property testing framework (i.e., the QuickCheck family) inspired by the Hypothesis framework for Python.

This crate, proptest-arbitrary, additionally provides an Arbitrary trait which allows you to have a canonical Strategy per type. This is the equivalent of Haskell QuickCheck's implementation of Arbitrary. In this interpretation of Arbitray, Strategy is the equivalent of the Gen monad.

Arbitrary is currently implemented as:


/// Arbitrary determines a canonical Strategy for the implementing type.
///
/// ...
pub trait Arbitrary : Sized + Debug {
    /// Generates a Strategy for producing arbitrary values of type the
    /// implementing type (Self).
    fn arbitrary() -> Self::Strategy;

    /// The type of ValueTree used for Self's Strategy.
    ///
    /// NOTE:
    /// This type should NOT be relied upon outside of this crate other than
    /// for implementing Arbitrary for other types.
    type ValueTree: ValueTree<Value = Self>;

    /// The type of Strategy used to generate values of type Self.
    ///
    /// NOTE:
    /// This type should NOT be relied upon outside of this crate other than
    /// for implementing Arbitrary for other types.
    type Strategy: Strategy<Value = Self::ValueTree>;
}

Traits

Arbitrary

Arbitrary determines a canonical Strategy for the implementing type.

Functions

arbitrary

Generates a Strategy producing Arbitrary values of T. Works better with type inference than any::<T>().