API
Function Index
The entries written on this page are automatically generated and DO NOT represent the currently supported API surface. PropCheck.jl is currently in a 0.x release; feel free to use anything you can find here, but know that (for now) only symbols that are exported are expected to stick around (they too may change, but I don't expect the underlying functionality to vanish entirely).
Nevertheless, I don't really expect things to change too much - the package is already complicated as is.
PropCheck.AbstractIntegrated
PropCheck.ExtentIntegrated
PropCheck.FiniteIntegrated
PropCheck.Flatten
PropCheck.InfiniteIntegrated
PropCheck.Integrated
PropCheck.IntegratedChain
PropCheck.IntegratedConst
PropCheck.IntegratedFiniteIterator
PropCheck.IntegratedLengthBounded
PropCheck.IntegratedOnce
PropCheck.IntegratedRange
PropCheck.IntegratedUnique
PropCheck.IntegratedVal
PropCheck.Tree
PropCheck.UniqueIterator
Base.Iterators.map
Base.filter
Base.filter
Base.map
PropCheck.array
PropCheck.assemble
PropCheck.check
PropCheck.extent
PropCheck.freeze
PropCheck.generate
PropCheck.iconst
PropCheck.ifloat
PropCheck.ifloatinf
PropCheck.ifloatinfnan
PropCheck.ifloatnan
PropCheck.inegint
PropCheck.iposint
PropCheck.isample
PropCheck.isample
PropCheck.itype
PropCheck.iunique
PropCheck.ival
PropCheck.nanHash
PropCheck.noshrink
PropCheck.root
PropCheck.shrink
PropCheck.shrinkTowards
PropCheck.str
PropCheck.subtrees
PropCheck.tear
PropCheck.tuple
PropCheck.unfold
PropCheck.vector
Function reference
Base.Iterators.map
— Methodmap(f, ::Tree)
Maps the function f
over the nodes of the given Tree
, returning a new true.
The subtrees of the tree returned by map
are guaranteed to be unique.
Base.filter
— Methodfilter(p, i::AbstractIntegrated[, trim=false]) -> AbstractIntegrated
Filters i
lazily such that all elements contained fulfill the predicate p
, i.e. all elements for which p
is false
are removed.
trim
controls whether subtrees are removed completely when the root doesn't fulfill the predicate or whether only that root should be skipped, still trying to shrink its subtrees. This trades performance (less shrinks to check) for quality (fewer/less diverse shrink values tried).
Base.filter
— Methodfilter(pred, ::Tree, trim=false)
Filters the given Tree
by applying the predicate pred
to each root.
Filtering is done lazily for subtrees.
trim
controls whether subtrees that don't match the predicate should be pruned entirely, or only their roots should be removed from the resulting Tree
. If trim
is true
, subtrees of subtrees that don't match the predicate are moved to the parent.
Base.map
— Methodmap(f, i::AbstractIntegrated) -> AbstractIntegrated
Maps f
lazily over all elements in i
, producing an AbstractIntegrated
generating the mapped values.
PropCheck.array
— MethodPropCheck.array(genSize::AbstractIntegrated, genA::AbstractIntegrated{Tree{T}}) where T
A utility function for creating an integrated shrinker producing Array{T, N}
, with its size controlled by the tuple generated from genLen
and its elements created by genA
. If genSize
produces an integer instead of a tuple of integers, this function will produce a Vector
instead.
This is generally the best way to create a shrinkable array, as it takes shrinking both size & elements into account, irrespective of shrinking order.
Using a FiniteIntegrated{T}
for the elements will cause the array to have Union{Nothing, T}
as its eltype
, because they may stop generating T
at any point!
PropCheck.assemble
— Methodassemble(::T, sign::I, expo::I, frac::I) where {I, T <: Union{Float16, Float32, Float64}} -> T
Assembles sign
, expo
and frac
arguments into the floating point number of type T
it represents. sizeof(T)
must match sizeof(I)
.
PropCheck.check
— Methodcheck(p, i::AbstractIntegrated[, rng::AbstractRNG=Random.default_rng()];
ntests::Int=PropCheck.numTest[], show_initial=true, transform=identity)
Checks whether the boolean predicate function p
returns true
for all values generated by i
.
Keyword arguments:
ntests
: How many values to generate & checkshow_initial
: Whether to show the initial failing example in the printed@info
messagetransform
: an optional transforming function to apply before returning a failure case- This can be used to make a given value, like a floating point
NaN
, easier to inspect & reproduce
- This can be used to make a given value, like a floating point
PropCheck.extent
— Methodextent(::ExtentIntegrated) -> Tuple{T,T} where T
Gives a tuple of the upper & lower bound of this ExtentIntegrated
.
PropCheck.freeze
— Methodfreeze(::T) where T <: AbstractIntegrated -> T
"Freezes" an AbstractIntegrated
by returning a new object that has a generate
method, and can be wrapped in a new integrated shrinker.
PropCheck.iconst
— Methodiconst(x) -> AbstractIntegrated
A convenience constructor for creating an integrated shrinker.
Trees created by this do not shrink, and generate
on the returned AbstractIntegrated
will always produce x
.
PropCheck.ifloat
— Methodifloat(::T) where T <: Union{Float16, Float32, Float64}
An integrated shrinker producing floating point values, except NaN
s and Inf
s.
There are multiple valid bitpatterns for both NaN
- and Inf
-like values. This shrinker is guaranteed not to produce any of them of its own volition. However, functions running on the values produced by this shrinker may still result in NaN
or Inf
to be produced. For example, if this shrinker produces a 0.0
and that number is passed to x -> 1.0/x
, you'll still get a Inf
. This can be important for map
ping over this shrinker.
PropCheck.ifloatinf
— Methodifloatinf(::Type{T}) where T <: Union{Float16, Float32, Float64}
An integrated shrinker producing nothing but valid Inf
s.
See also ifloatnan
, ifloatinfnan
.
PropCheck.ifloatinfnan
— Methodifloatinfnan(::Type{T}) where T <: Union{Float16, Float32, Float64}
An integrated shrinker producing nothing but valid NaN
s and Inf
s.
Implemented more efficiently than naive combining of ifloatnan
and ifloatinf
.
PropCheck.ifloatnan
— Methodifloatnan(::T) where T <: Union{Float16, Float32, Float64}
An integrated shrinker producing nothing but valid NaN
s.
See also ifloatinf
, ifloatinfnan
.
PropCheck.inegint
— Methodinegint(::Type{T}) where T <: Union{Int8, Int16, Int32, Int64, Int128}
An integrated shrinker producing negative values of type T
.
PropCheck.iposint
— Methodiposint(::Type{T}) where T <: Union{Int8, Int16, Int32, Int64, Int128}
An integrated shrinker producing positive values of type T
.
PropCheck.isample
— Functionisample(x::AbstractRange[, shrink=shrinkTowards(first(x))]) -> AbstractIntegrated
A convenience constructor for creating an integrated shrinker.
Trees created by this shrink towards the first element of the range by default.
PropCheck.isample
— Functionisample(x[, shrink=shrink]) -> AbstractIntegrated
A convenience constructor for creating an integrated shrinker.
Trees created by this shrink according to shrink
, and generate
on the returned Integrated
will always produce an element of the collection x
.
x
needs to be indexable.
PropCheck.iunique
— Methodiunique(x::Vector, shrink=shrink) -> AbstractIntegrated
A convenience constructor for creating an integrated shrinker.
This shrinker produces all unique values of x
before producing a value it has produced before. The produced trees shrink according to shrink
.
PropCheck.ival
— Methodival(x::T[, shrink=shrink]) -> AbstractIntegrated
A convenience constructor for creating integrated shrinkers, generating their values from a starting value.
Trees created by this function will always initially have x
at their root, as well as shrink according to shrink
.
PropCheck.nanHash
— FunctionnanHash(x[, h=zero(UInt)])
Produces a hash for values, with special consideration for NaN
s, ensuring distinct bitpatterns in NaN
produce different hashes.
PropCheck.noshrink
— Methodnoshrink(_::T) -> T[]
A shrinker that doesn't shrink its arguments.
PropCheck.root
— MethodPropCheck.shrinkTowards
— FunctionshrinkTowards(to::T) -> (x::T -> T[...])
Constructs a shrinker function that shrinks given values towards to
.
PropCheck.str
— Functionstr(len::ExtentIntegrated[, alphabet::AbstractIntegrated])
Generates a string using the given genLen
as a generator for the length. The default alphabet is typemin(Char):"÷¿¿¿"[1]
, which is all representable Char
values.
PropCheck.subtrees
— MethodPropCheck.tear
— Methodtear(x::T) where T <: Union{Float16, Float32, Float64} -> Tuple{I, I, I}
Returns the sign, exponent and fractional parts of a floating point number. The returned tuple consists of three unsigned integer types I
of the same bitwidth as T
.
PropCheck.tuple
— Methodtuple(genLen::AbstractIntegrated, genA::AbstractIntegrated)
Generates a tuple of a generated length, using the elements produced by genA
.
Using a FiniteIntegrated{T}
will cause the tuple to have Union{Nothing, T}
as its eltype
, because they may stop generating T
at any point!
Due to the length produced by genLen
not being known until runtime, this function is by its very nature type unstable. Consider using interleave
and a fixed number of known generators instead.
PropCheck.unfold
— Methodunfold(f, root)
Unfolds root
into a Tree
, by applying f
to each root to create subtrees.
root
is the new root of the returned Tree
. f
must return an iterable object with eltype
egal to typeof(root)
.
PropCheck.vector
— MethodPropCheck.vector(genLen::ExtentIntegrated, genA::AbstractIntegrated{Tree{T}}) where T
A utility function for creating an integrated shrinker producing Vector{T}
, with its length controlled by the number generated from genLen
and its elements created by genA
.
This is generally the best way to create a shrinkable vector, as it takes shrinking both length & elements into account, irrespective of shrinking order.
Using a FiniteIntegrated{T}
for the elements will cause the vector to have Union{Nothing, T}
as its eltype
in the general case, because they may stop generating T
at any point!
PropCheck.Flatten
— TypeFlatten{Eltype}
An iterator like Base.flatten
, except with inferrable eltype
. Requires the given iterators to have the same eltype
.
The given Eltype
is used to assert the return type; a type mismatch there will throw.
PropCheck.Integrated
— TypeIntegrated{T} <: InfiniteIntegrated{T}
A naive integrated shrinker, only providing extremely basic functionality for generating and shrinking Tree
s. Default fallback if no other, more specialized type exists.
This type is likely going to be redesigned in the future. Methods constructing it are not stable, and may be removed at any point.
PropCheck.IntegratedChain
— TypeChainIntegrated(is::AbstractIntegrated...)
ChainIntegrated{Eltype, N, Is, Finite} where {Eltype, N,
Is <: NTuple{N, <:AbstractIntegrated}, Finite} <: AbstractIntegrated{Eltype}
An integrated shrinker chaining together a number of given integrated shrinkers, producing the values they generate one after another.
All except the last argument must have some finite length, meaning the integrated shrinker must subtype FiniteIntegrated
. Only the last integrated shrinker is allowed to be only <: InfiniteIntegrated
.
The values produced by this integrated shrinker shrink according to the shrinking function given to the shrinker that originally produce them.
The Finite
type parameter is a Bool
, indicating whether this IntegratedChain
is finite or not.
PropCheck.IntegratedConst
— TypeIntegratedConst{T,R,G} <: ExtentIntegrated{T}
An integrated shrinker describing a constant. The shrinker will always produce that value, which doesn't shrink.
PropCheck.IntegratedFiniteIterator
— TypeIntegratedFiniteIterator(itr[, shrink=shrink])
IntegratedFiniteIterator{T} <: FiniteIntegrated{T}
An integrated shrinker taking arbitrary iterables that have a length or a shape. Once the iterator is exhausted, the integrated shrinker produces nothing
.
The values produced by this integrated shrinker shrink according to the given shrinking function.
PropCheck.IntegratedLengthBounded
— TypeIntegratedLengthBounded(is::AI, bound::Integer) where {T, AI <: AbstractIntegrated{T}}
IntegratedLengthBounded{T, AbstractIntegrated{T}} <: FiniteIntegrated{T}
An integrated shrinker bounding the number of values generated by the passed integrated shrinker. This has the ability to transform any AbstractIntegrated
into a FiniteIntegrated
.
The given bound must be a positive value. If a fi::FiniteIntegrated
is given as the integrated shrinker, the bound is chosen to be min(length(fi), bound)
.
The values produced by this integrated shrinker shrink according to the shrinking function given to the original integrated shrinker wrapped by IntegratedLengthBounded
.
PropCheck.IntegratedOnce
— TypeIntegratedOnce(el[, shrink=shrink])
IntegratedOnce{T} <: FiniteIntegrated{T}
An integrated shrinker that produces a shrink tree with the value el
at its root exactly once. Afterwards, the integrated shrinker produces nothing
.
PropCheck.IntegratedRange
— TypeIntegratedRange{T,R,G,F} <: ExtentIntegrated{T}
An integrated shrinker describing a range of values.
The values created by this shrinker shrink according to the given shrinking function. The shrinking function must ensure that the produced values are always contained within the bounds of the given range.
PropCheck.IntegratedUnique
— TypeIntegratedUnique(vec::Vector{ElT}, shrink::S) where {ElT,S}
IntegratedUnique{T,ElT,S} <: InfiniteIntegrated{T}
An integrated shrinker, taking a vector vec
. The shrinker will produce all unique values of vec
in a random order before producing a value it returned before. The values produced by this shrinker shrink according to shrink
.
PropCheck.IntegratedVal
— TypeIntegratedVal(val::V, shrink::S) where {V,S}
IntegratedVal{T,V,S} <: InfiniteIntegrated{T}
An integrated shrinker, taking a value val
. The shrinker will always produce val
, which shrinks according to shrink
.
If V <: Number
, shrinking functions given to this must produce values in
[typemin(V), v]
ifv > zero(V)
[v, typemax(V)]
ifv < zero(V)
- no values if
iszero(v)
This shrinker supports extent
out of the box if V <: Number
. For other types, you need to define extent(::IntegratedVal{Tree{T}})
PropCheck.Tree
— TypeTree{T}
A tree of T
objects. The tree is inherently lazy; subtrees of subtrees are only generated on demand.
The subtrees
field is intentionally untyped, to allow for various kinds of lazy subtree representations.
PropCheck.UniqueIterator
— TypeUniqueIterator(itr, by=identity)
A lazy iterator over unique elements that have not been produced before.
This iterator treats distinct bitpatterns of NaN
as distinct values, unlike Base.hash
.