#![doc(
issue_tracker_base_url = "https://github.com/jockbert/monkey_test/issues/"
)]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/jockbert/monkey_test/main/assets/doc/logo-256.png"
)]
#![doc(
html_favicon_url = "https://raw.githubusercontent.com/jockbert/monkey_test/main/assets/doc/logo.ico"
)]
#![warn(missing_docs)]
#![doc = include_str!("../DOCUMENTATION.md")]
mod config;
mod convenience_traits;
pub mod gens;
mod internal;
mod runner;
pub mod shrinks;
#[cfg(test)]
mod testing;
use std::ops::RangeInclusive;
pub use config::*;
pub use convenience_traits::*;
pub fn monkey_test() -> Conf {
Conf::default()
}
pub type BoxIter<E> = Box<dyn Iterator<Item = E>>;
pub type BoxShrink<E> = Box<dyn Shrink<E>>;
pub type BoxGen<E> = Box<dyn Gen<E>>;
pub type Property<E> = fn(E) -> bool;
pub type ExampleSize = RangeInclusive<usize>;
pub type Seed = u64;
impl<E> core::fmt::Debug for dyn Gen<E> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(std::any::type_name::<Self>())
}
}
pub trait Gen<E: Clone + 'static>: CloneGen<E> {
fn examples(&self, seed: Seed, size: ExampleSize) -> BoxIter<E>;
fn shrinker(&self) -> BoxShrink<E>;
fn with_shrinker(&self, other_shrink: BoxShrink<E>) -> BoxGen<E> {
gens::other_shrinker(self.clone_box(), other_shrink)
}
fn chain(&self, other_gen: BoxGen<E>) -> BoxGen<E> {
gens::chain(self.clone_box(), other_gen)
}
}
pub trait Shrink<E>: CloneShrink<E>
where
E: Clone,
{
fn candidates(&self, original: E) -> BoxIter<E>;
}
#[doc = include_str!("../README.md")]
#[cfg(doctest)]
pub struct ReadmeDoctests;