diff --git a/proptest-state-machine/src/strategy.rs b/proptest-state-machine/src/strategy.rs index 15abfb44..d13c39c4 100644 --- a/proptest-state-machine/src/strategy.rs +++ b/proptest-state-machine/src/strategy.rs @@ -102,13 +102,13 @@ pub trait ReferenceStateMachine { BoxedStrategy, BoxedStrategy, > { - Sequential { - size: size.into(), - init_state: Self::init_state, - preconditions: Self::preconditions, - transitions: Self::transitions, - next: Self::apply, - } + Sequential::new( + size.into(), + Self::init_state, + Self::preconditions, + Self::transitions, + Self::apply, + ) } } @@ -146,6 +146,26 @@ pub struct Sequential { next: fn(state: State, transition: &Transition) -> State, } +impl + Sequential +{ + pub fn new( + size: SizeRange, + init_state: fn() -> StateStrategy, + preconditions: fn(state: &State, transition: &Transition) -> bool, + transitions: fn(state: &State) -> TransitionStrategy, + next: fn(state: State, transition: &Transition) -> State, + ) -> Self { + Self { + size, + init_state, + preconditions, + transitions, + next, + } + } +} + impl Debug for Sequential { diff --git a/proptest/src/strategy/flatten.rs b/proptest/src/strategy/flatten.rs index 63ac4160..89b8ebd9 100644 --- a/proptest/src/strategy/flatten.rs +++ b/proptest/src/strategy/flatten.rs @@ -261,7 +261,7 @@ impl R> Strategy mod test { use super::*; - use std::u32; + use std::u64; use crate::strategy::just::Just; use crate::test_runner::Config; @@ -276,7 +276,7 @@ mod test { let mut failures = 0; let mut runner = TestRunner::new_with_rng( Config { - max_shrink_iters: u32::MAX - 1, + max_shrink_iters: u64::MAX - 1, ..Config::default() }, TestRng::deterministic_rng(RngAlgorithm::default()), diff --git a/proptest/src/test_runner/config.rs b/proptest/src/test_runner/config.rs index 0a5dc1c8..8eec88ae 100644 --- a/proptest/src/test_runner/config.rs +++ b/proptest/src/test_runner/config.rs @@ -118,7 +118,7 @@ pub fn contextualize_config(mut result: Config) -> Config { MAX_SHRINK_ITERS => parse_or_warn( &value, &mut result.max_shrink_iters, - "u32", + "u64", MAX_SHRINK_ITERS, ), MAX_DEFAULT_SIZE_RANGE => parse_or_warn( @@ -170,7 +170,7 @@ fn default_default_config() -> Config { timeout: 0, #[cfg(feature = "std")] max_shrink_time: 0, - max_shrink_iters: u32::MAX, + max_shrink_iters: u64::MAX, max_default_size_range: 100, result_cache: noop_result_cache, #[cfg(feature = "std")] @@ -336,10 +336,10 @@ pub struct Config { /// Note that the type of this field will change in a future version of /// proptest to better accommodate its special values. /// - /// The default is `std::u32::MAX`, which can be overridden by setting the + /// The default is `std::u64::MAX`, which can be overridden by setting the /// `PROPTEST_MAX_SHRINK_ITERS` environment variable. (The variable is only /// considered when the `std` feature is enabled, which it is by default.) - pub max_shrink_iters: u32, + pub max_shrink_iters: u64, /// The default maximum size to `proptest::collection::SizeRange`. The default /// strategy for collections (like `Vec`) use collections in the range of @@ -512,9 +512,9 @@ impl Config { /// Returns the configured limit on shrinking iterations. /// /// This takes into account the special "automatic" behaviour. - pub fn max_shrink_iters(&self) -> u32 { - if u32::MAX == self.max_shrink_iters { - self.cases.saturating_mul(4) + pub fn max_shrink_iters(&self) -> u64 { + if u64::MAX == self.max_shrink_iters { + (self.cases as u64).saturating_mul(4) } else { self.max_shrink_iters }