Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions proptest-state-machine/src/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ pub trait ReferenceStateMachine {
BoxedStrategy<Self::State>,
BoxedStrategy<Self::Transition>,
> {
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,
)
}
}

Expand Down Expand Up @@ -146,6 +146,26 @@ pub struct Sequential<State, Transition, StateStrategy, TransitionStrategy> {
next: fn(state: State, transition: &Transition) -> State,
}

impl<State, Transition, StateStrategy, TransitionStrategy>
Sequential<State, Transition, StateStrategy, TransitionStrategy>
{
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<State, Transition, StateStrategy, TransitionStrategy> Debug
for Sequential<State, Transition, StateStrategy, TransitionStrategy>
{
Expand Down
4 changes: 2 additions & 2 deletions proptest/src/strategy/flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ impl<S: Strategy, R: Strategy, F: Fn(S::Value) -> R> Strategy
mod test {
use super::*;

use std::u32;
use std::u64;

use crate::strategy::just::Just;
use crate::test_runner::Config;
Expand All @@ -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()),
Expand Down
14 changes: 7 additions & 7 deletions proptest/src/test_runner/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down