// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std_facade::{fmt, Arc, Box, Vec};
+use crate::std_facade::{fmt, Arc, Box, Vec};
-use strategy::traits::*;
-use strategy::unions::float_to_weight;
-use test_runner::*;
+use crate::strategy::traits::*;
+use crate::strategy::unions::float_to_weight;
+use crate::test_runner::*;
/// Return type from `Strategy::prop_recursive()`.
#[must_use = "strategies do nothing unless used"]
}
}
-impl<T : fmt::Debug + 'static,
- R : Strategy<Value = T> + 'static,
- F : Fn (BoxedStrategy<T>) -> R>
-Recursive<T, F> {
- pub(super) fn new
- (base: impl Strategy<Value = T> + 'static,
- depth: u32, desired_size: u32, expected_branch_size: u32,
- recurse: F)
- -> Self
- {
+impl<
+ T: fmt::Debug + 'static,
+ R: Strategy<Value = T> + 'static,
+ F: Fn(BoxedStrategy<T>) -> R,
+ > Recursive<T, F>
+{
+ pub(super) fn new(
+ base: impl Strategy<Value = T> + 'static,
+ depth: u32,
+ desired_size: u32,
+ expected_branch_size: u32,
+ recurse: F,
+ ) -> Self {
Self {
base: base.boxed(),
recurse: Arc::new(recurse),
- depth, desired_size, expected_branch_size,
+ depth,
+ desired_size,
+ expected_branch_size,
}
}
}
-impl<T : fmt::Debug + 'static,
- R : Strategy<Value = T> + 'static,
- F : Fn (BoxedStrategy<T>) -> R>
-Strategy for Recursive<T, F> {
+impl<
+ T: fmt::Debug + 'static,
+ R: Strategy<Value = T> + 'static,
+ F: Fn(BoxedStrategy<T>) -> R,
+ > Strategy for Recursive<T, F>
+{
type Tree = Box<dyn ValueTree<Value = T>>;
type Value = T;
mod test {
use std::cmp::max;
- use strategy::just::Just;
use super::*;
+ use crate::strategy::just::Just;
#[derive(Clone, Debug, PartialEq)]
enum Tree {
let mut max_depth = 0;
let mut max_count = 0;
- let strat = Just(Tree::Leaf).prop_recursive(4, 64, 16,
- |element| ::collection::vec(element, 8..16).prop_map(Tree::Branch));
+ let strat = Just(Tree::Leaf).prop_recursive(4, 64, 16, |element| {
+ crate::collection::vec(element, 8..16).prop_map(Tree::Branch)
+ });
- let mut runner = TestRunner::default();
+ let mut runner = TestRunner::deterministic();
for _ in 0..65536 {
let tree = strat.new_tree(&mut runner).unwrap().current();
let (depth, count) = tree.stats();
#[test]
fn simplifies_to_non_recursive() {
- let strat = Just(Tree::Leaf).prop_recursive(4, 64, 16,
- |element| ::collection::vec(element, 8..16).prop_map(Tree::Branch));
+ let strat = Just(Tree::Leaf).prop_recursive(4, 64, 16, |element| {
+ crate::collection::vec(element, 8..16).prop_map(Tree::Branch)
+ });
- let mut runner = TestRunner::default();
+ let mut runner = TestRunner::deterministic();
for _ in 0..256 {
let mut value = strat.new_tree(&mut runner).unwrap();
- while value.simplify() { }
+ while value.simplify() {}
assert_eq!(Tree::Leaf, value.current());
}