- Fix that regex-based string generation could transpose the order of a literal and a non-literal component.
-
Macros which previously accepted
pattern in strategy
syntax to specify arguments now also acceptpattern: type
syntax as shorthand forpattern in any::<type>()
. -
Closure-style
proptest!
invocation no longer requires the body to use block syntax. -
Closure-style
proptest!
invocation now accepts custom configurations.
proptest!
now has form that accepts a closure. See the documentation for the macro for more details.
-
Fix spurious warning about corrupt regression files. The files were not corrupt but the parser was failing to handle the blank line at the end.
-
The
multiplex_alloc!
andmultiplex_core!
macros which were unintentionally exported in 0.8.0 are no longer exported. This is not considered a breaking change since they were not supposed to be accessible, and in any case would not have expanded into valid code in most other crates.
-
A combinator
.prop_filter_map
has been added toStrategy
. It is similar to.filter_map
forIterator
in that it is the combination of.prop_filter
and.prop_map
. -
i128
andu128
are now supported without any feature flags and on stable. -
More implementations of
Arbitrary
are supported foralloc
+no_std
users. -
size_range
now accepts inclusive ranges of formlow..=high
and..=high
. Thus, you can construct avec
strategy as:vec(elt_strategy, low..=high)
andvec(elt_strategy, ..=high)
. This also applies to other functions acceptingInto<SizeRange>
. -
..= high
is now a valid strategy. Please note that..= 1
will naturally include numbers lower than0
for sized types. -
low..=high
is also a valid strategy. -
Arbitrary
is implemented forRangeInclusive<Idx>
,RangeToInclusive
, andDecodeUtf16
on stable. -
Bitset strategies and
subsequence
now accept all range syntaxes.
- Fix a race condition where a test failing due to running ever so slightly over the set timeout could cause the test harness to converge to the incorrect failing value, a non-failing value, or panic.
- The type alias
ValueFor<S>
is now deprecated and will be removed in version 0.9. You should just useS::Value
instead.
-
A minimum version of 1.27 of Rust is now required.
-
regex-syntax
version 0.6 is now used. -
rand
version 0.5 is now used. -
As a consequence, the
FailurePersistence
trait will now use[u8; 16]
seeds instead of[u32; 4]
. However, the stored failure persistence files using the defaultFileFailurePersistence
will still use[u32; 4]
so your old failure persistence files should still work. -
The RNG used by proptest has been changed to a PRNG
TestRng
which proptest exposes. This is currently a simple new-type wrapper aroundXorShiftRng
. In the future, this will give us more freedom to make changes without breakage. -
The feature flag
i128_support
has been removed. The features it added are now always supported. -
The associated type
Value
ofStrategy
has been renamed toTree
. A new associated typeValue
has been added toStrategy
which always refers to the same type as<S::Tree as ValueTree>::Value
for some strategyS
. This change allows you to write-> impl Strategy<Value = T>
for functions returning aStrategy
generatingT
s. This is more ergonomic to use than-> impl Strategy<Value = impl ValueTree<Value = T>>
. -
The method
new_value
inStrategy
has been renamed tonew_tree
to mirror the renaming ofValue
toTree
. -
As a consequence change, the associated type
ValueTree
has been removed fromArbitrary
. -
The methods
run
andrun_one
onTestRunner
now takes a function-under-test that accepts the generated type by value instead of by reference instead. This means that you don't need to writeref value in my_strategy
and can writevalue in my_strategy
instead even iftypeof(value)
doesn't implementCopy
. This is also a step in the direction of allowing strategies to generate references when generic associated types (GATs) land. However,ref value in my_strategy
will still be accepted, so not a lot of breakage should come of this if you've usedproptest! { .. }
. -
prop_compose!
no longer applies.boxed()
to the strategy produced. Therefore,-> BoxedStrategy<T>
is no longer the correct type. The new return type is-> impl Strategy<Value = T>
. If you want the old behaviour, you can use.boxed()
yourself. -
Arbitrary
forSizeRange
changed its associated type to useRangeInclusive
. Same applies forCString
. -
Many APIs now use
impl Trait
in argument position, which could affect code using turbofishes to specify types explicitly. -
char
APIs which formerly represented a range as(start, end)
now requirestart..=end
.
- As
std::io::{Chars, CharsError}
have been deprecated on nightly, theirArbitrary
implementations have been removed.
- Fix that
bool
would not shrink correctly, leading to hangs when tests takingbool
parameters would fail in certain circumstances.
-
It is now possible to run test cases in sub-processes. This allows using proptest to test functions which may cause the test process to terminate abruptly, such as by calling
abort()
or even suffering a segmentation fault. This requires the "fork" feature, enabled by default. -
Added support for setting a timeout which applies on a per-test-case (i.e., single input rather than the whole test) basis. This allows using proptest to find inputs which cause code to get stuck in infinite loops or exhibit other pathological performance behaviour. This requires the "timeout" feature (and transitively, the "fork" feature), enabled by default.
See also the documentation for these features.
-
Fix that failure persistence file would be written to the incorrect location in projects using workspaces. See #24 for more details and instructions on how to migrate any persistence files that had been written to the wrong location.
-
Fix a case where
any::<ArgsOs>()
orany::<VarsOs>()
could panic on Windows.
- Support for the
hashmap_core
crate is removed pending Amanieu/hashmap_core#3.
-
The persistence system has been refactored to allow for non-file-system based persistence.
FailurePersistence
is now a trait, and the prior file-based enum which fulfilled that purpose is now calledFileFailurePersistence
and implements the generic trait. The default behavior has not changed. -
Reflecting the change to persistence,
Config.failure_persistence
is now of typeOption<Box<FailurePersistence>>
. -
The
source_file
used as an optional reference point to the location of the calling test is now tracked on theConfig
struct rather than theTestRunner
.
- Experimental support on nightly for working in
#![no_std]
environments has been added. To use it, one must disable the default-features for proptest and use the new "alloc" and "nightly" features. Currently access to a heap allocator is still required.
- There is a small change of breakage if you've relied on
Recursive
using anArc<BoxedStrategy<T>>
asRecursive
now internally usesBoxedStrategy<T>
instead as well as expecting aFn(BoxedStrategy<T>) -> R
instead ofFn(Arc<BoxedStrategy<T>>) -> R
. In addition, the type of recursive strategies has changed fromRecursive<BoxedStrategy<T>, F>
to justRecursive<T, F>
.
-
Reduced indirections and heap allocations inside
Recursive<T, F>
somewhat. -
BoxedStrategy<T>
andSBoxedStrategy<T>
now useArc
internally instead of usingBox
. While this has marginal overhead, it also reduces the overhead inRecursive<T, F>
. The upside to this change is also that you can very cheaply clone strategies. -
Filter
is marginally faster.
-
Removed
impl Arbitrary for LocalKeyState
sinceLocalKeyState
no longer exists in the nightly compiler. -
Unstable features compile on latest nightly again.
-
proptest::strategy::Union
andproptest::strategy::TupleUnion
now work with weighted strategies even if the sum of the weights overflows au32
. -
Added
SIGNALING_NAN
strategy to generate signalling NaNs if supported by the platform. Note that this is not included inANY
.
-
Fixed values produced via
prop_recursive()
not shrinking from the recursive to the non-recursive case. -
Fix that
QUIET_NAN
would generate signalling NaNs on most platforms on Rust 1.24.0 and later.
-
There is a small chance of breakage if you've relied on the constraints put on type inference by the closure in
leaf.prop_recursive(..)
having a fixed output type. The output type is now any strategy that generates the same type asleaf
. This change is intended to make working with recursive types a bit easier as you no longer have to use.boxed()
inside the closure you pass to.prop_recursive(..)
. -
There is a small chance of breakage wrt. type inference due to the introduction of
SizeRange
. -
There is a small chance of breakage wrt. type inference due to the introduction of
Probability
. -
BoxedStrategy
andSBoxedStrategy
are now newtypes instead of being type aliases. You will only experience breaking changes if you've directly used.boxed()
and not(S)BoxedStrategy<T>
but ratherBox<Strategy<Value = Box<ValueTree<Value = T>>>>
. The probability of breakage is very small, but still possible. The benefit of this change is that calling.boxed()
or.sboxed()
twice only boxes once. This can happen in situations where you have functionsStrategy -> BoxedStrategy
or with code generation. -
proptest::char::ANY
has been removed. Any remaining uses must be replaced byproptest::char::any()
. -
proptest::strategy::Singleton
has been removed. Any remaining uses must be replaced byproptest::strategy::Just
.
-
Proptest now has an
Arbitrary
trait inproptest::arbitrary
and re-exported in theproptest::prelude
.Arbitrary
has also beenimpl
emented for most of the standard library. The trait provides a mechanism to define a canonicalStrategy
for a given type just likeArbitrary
in Haskell's QuickCheck. Deriving for this trait will also be provided soon in the crateproptest_derive
. To use the canonical strategy for a certain typeT
, you can simply useany::<T>()
. This is the major new addition of this release. -
The
any_with
,arbitrary
,arbitrary_with
free functions in the moduleproptest::arbitrary
. -
The
ArbitraryF1
andArbitraryF2
traits inproptest::arbitrary::functor
. These are "higher order"Arbitrary
traits that correspond to theArbitrary1
andArbitrary2
type classes in Haskell's QuickCheck. They are mainly provided to support a common set of container-like types in custom deriving self-recursive types inproptest_derive
. More on this later releases. -
The strategies in
proptest::option
andproptest::result
now accept a typeProbability
which is a wrapper aroundf64
. Convertions from types such asf64
are provided to make the interface ergonomic to use. Users may also use theproptest::option::prob
function to explicitly construct the type. -
The strategies in
proptest::collections
now accept a typeSizeRange
which is a wrapper aroundRange<usize>
. Convertions from types such asusize
andRange<usize>
are provided to make the interface ergonomic to use. Users may also use theproptest::collections::size_bounds
function to explicitly construct the type. -
A
.prop_map_into()
operation on all strategies that map usingInto<OutputType>
. This is a clerarer and cheaper operation than using.prop_map(OutputType::from)
. -
A nonshrinking
LazyJust
strategy that can be used instead ofJust
when you have non-Clone
types. -
Anything that can be coerced to
fn() -> T
whereT: Debug
is aStrategy
whereValueFor<fn() -> T> == T
. This is intended to make it easier to reuse proptest for unit tests with manual input space partition wherefn() -> T
provides fixtures.
-
Relaxed the constraints of
btree_map
removing'static
. -
Reduced the heap allocation inside
Recursive
somewhat.
- The
unstable
feature now works again.
- The
proptest::num::f32
andproptest::num::f64
modules now have additional constants (e.g.,POSITIVE
,SUBNORMAL
,INFINITE
) which can be used to generate subsets of the floating-point domain by class and sign.
proptest::num::f32::ANY
andproptest::num::f64::ANY
now actually produce arbitrary values. Previously, they had the same effect as0.0..1.0
. While this fix is a very substantial change in behaviour, it was not considered a breaking change since (a) the new behaviour is consistent with the documentation and expectations, (b) it's quite unlikely anyone was depending on the old behaviour since anyone who wanted that range would have written it out, and (c) Proptest isn't generally a transitive dependency so the chance of this update happening "by surprise" is low.
-
proptest::char::ANY
replaced withproptest::char::any()
.proptest::char::ANY
is present but deprecated, and will be removed in proptest 0.5.0. -
Instead of returning
-> Result<Self::Value, String>
, strategies are expected to return-> Result<Self::Value, Reason>
instead.Reason
reduces the amount of heap allocations, especially for.prop_filter(..)
where you may now also pass in&'static str
. You will only experience breaks if you've written your own strategy types or if you've usedTestCaseError::Reject
orTestCaseError::Fail
explicitly. -
Update of externally-visible crate
rand
to0.4.2
.
-
Added
proptest::test_runner::Reason
which allows you to avoid heap allocation in some places and may be used to make the API richer in the future without incurring more breaking changes. -
Added a type alias
proptest::strategy::NewTree<S>
whereS: Strategy
defined as:type NewTree<S> = Result<<S as Strategy>::Value, Rejection>
.
- Cases where
file!()
returns a relative path, such as on Windows, are now handled more reasonably. See #24 for more details and instructions on how to migrate any persistence files that had been written to the wrong location.
Boxing Day Special
-
Added support for
i128
andu128
. Since this is an unstable feature in Rust, this is hidden behind the featureunstable
which you have to explicitly opt into in yourCargo.toml
file. -
Failing case persistence. By default, when a test fails, Proptest will now save the seed for the failing test to a file, and later runs will test the persisted failing cases before generating new ones.
-
Added
UniformArrayStrategy
and helper functions to simplify generating homogeneous arrays with non-Copy
inner strategies. -
Trait
rand::Rng
and structrand::XorShiftRng
are now included inproptest::prelude
.
- Fix a case where certain combinations of strategies, like two
prop_shuffle()
s in close proximity, could result in low-quality randomness.
-
Added
SampledBitSetStrategy
to generate bit sets based on size distribution. -
Added
Strategy::sboxed()
andSBoxedStrategy
to makeSend + Sync
boxed strategies. -
RegexGeneratorStrategy
is nowSend
andSync
. -
Added a type alias
ValueFor<S>
whereS: Strategy
. This is a shorter way to refer to:<<S as Strategy>::Value as ValueTree>::Value
. -
Added a type alias
type W<T> = (u32, T)
for a weighted strategyT
in the context of union strategies. -
TestRunner
now implementsDefault
. -
Added
Config::with_cases(number_of_cases: u32) -> Config
for simpler construction of aConfig
that only differs by the number of test cases. -
All default fields of
Config
can now be overridden by setting environment variables. See the docs of that struct for more details. -
Bumped dependency
rand = "0.3.18"
. -
Added
proptest::sample::subsequence
which returns a strategy generating subsequences, of the sourceVec
, with a size within the givenRange
. -
Added
proptest::sample::select
which returns a strategy selecting exactly one value from another collection. -
Added
prop_perturb
strategy combinator. -
Added
strategy::check_strategy_sanity()
function to do sanity checks on the shrinking implementation of a strategy. -
Added
prop_shuffle
strategy combinator. -
Added
strategy::Fuse
adaptor.
-
Fix bug where
Vec
, array and tuple shrinking could corrupt the state of their inner values, for example leading to out-of-range integers. -
Fix bug where
Flatten
(a.k.a. theprop_flat_map
combinator) could fail to converge to a failing test case during shrinking. -
Fix
TupleUnion
sometimes panicking during shrinking if there were more than two choices.
- Added
CharStrategy::new_borrowed
.
-
Union
now supports weighting viaUnion::new_weighted
. Corresponding syntax to specify weights is also available inprop_oneof!
. -
Added
TupleUnion
, which works likeUnion
but permits doing static dispatch even with heterogeneous delegate strategies. -
prop_oneof!
is smarter about how it combines the input strategies. -
Added
option
module to generate weighted or unweightedOption
types. -
Added
result
module to generate weighted or unweightedResult
types. -
All
bits
submodules now have amasked
function to create a strategy for generating subsets of an arbitrary bitmask.
-
Union::new
now has a generic argument type which could impact type inference. -
The concrete types produced by
prop_oneof!
have changed. -
API functions which used to return
BoxedStrategy
now return a specific type. -
BitSetStrategy<T>
is no longerCopy
for non-Copy
typesT
norDebug
for non-Debug
typesT
. -
BitSetLike::max
has been renamed toBitSetLike::len
.
-
Added
prop_assert!
macro family to assert without panicking, for quieter test failure modes. -
New
prelude
module for easier importing of important things. -
Renamed
Singleton
toJust
. (The old name is still available.) -
Failure messages produced by
proptest!
are now much more readable. -
Added in-depth tutorial.
Strategy
now requiresstd::fmt::Debug
.
-
Strategy
now has a family ofprop_flat_map()
combinators for producing dynamic and higher-order strategies. -
Strategy
has aprop_recursive()
combinator which allows generating recursive structures. -
Added
proptest::bool::weighted()
to pull booleans from a weighted distribution. -
New
prop_oneof!
macro makes it easier to select from one of several strategies. -
New
prop_compose!
macro to simplify writing most types of custom strategies.
Add strategy::NoShrink
, Strategy::no_shrink()
.