FsCheck


Arb Module

Namespace: FsCheck.FSharp

Assembly: FsCheck.dll

Functions and values

Function or value Description

Arb.array elements

Full Usage: Arb.array elements

Parameters:
Returns: Arbitrary<'T[]>

Generates one-dimensional arrays. The length of the generated array is between 0 and size. The sum of the sizes of the elements is equal to the size of the generated array.

elements : Arbitrary<'T>
Returns: Arbitrary<'T[]>

Arb.convert convertTo convertFrom a

Full Usage: Arb.convert convertTo convertFrom a

Parameters:
    convertTo : 'T -> 'U
    convertFrom : 'U -> 'T
    a : Arbitrary<'T>

Returns: Arbitrary<'U>

Construct an Arbitrary instance for a type that can be mapped to and from another type (e.g. a wrapper), based on a Arbitrary instance for the source type and two mapping functions.

convertTo : 'T -> 'U
convertFrom : 'U -> 'T
a : Arbitrary<'T>
Returns: Arbitrary<'U>

Arb.filter pred a

Full Usage: Arb.filter pred a

Parameters:
Returns: Arbitrary<'T>

Return an Arbitrary instance that is a filtered version of an existing arbitrary instance. The generator uses Gen.where, and the shrinks are filtered using Seq.filter with the given predicate.

pred : 'T -> bool
a : Arbitrary<'T>
Returns: Arbitrary<'T>

Arb.fromGen gen

Full Usage: Arb.fromGen gen

Parameters:
    gen : Gen<'Value>

Returns: Arbitrary<'Value>

Construct an Arbitrary instance from a generator. Shrink is not supported for this type.

gen : Gen<'Value>
Returns: Arbitrary<'Value>

Arb.fromGenShrink (gen, shrinker)

Full Usage: Arb.fromGenShrink (gen, shrinker)

Parameters:
    gen : Gen<'Value>
    shrinker : 'Value -> seq<'Value>

Returns: Arbitrary<'Value>

Construct an Arbitrary instance from a generator and shrinker.

gen : Gen<'Value>
shrinker : 'Value -> seq<'Value>
Returns: Arbitrary<'Value>

Arb.list elements

Full Usage: Arb.list elements

Parameters:
Returns: Arbitrary<'T list>

Generates FSharp.Core list<'T> values. The length of the generated list is between 0 and size. The sum of the sizes of the elements is equal to the size of the generated list.

elements : Arbitrary<'T>
Returns: Arbitrary<'T list>

Arb.mapFilter mapper pred a

Full Usage: Arb.mapFilter mapper pred a

Parameters:
    mapper : 'T -> 'T
    pred : 'T -> bool
    a : Arbitrary<'T>

Returns: Arbitrary<'T>

Return an Arbitrary instance that is a mapped and filtered version of an existing arbitrary instance. The generator uses Gen.map with the given mapper and then Gen.where with the given predicate, and the shrinks are filtered using Seq.filter with the given predicate. This is sometimes useful if using just a filter would reduce the chance of getting a good value from the generator - and you can map the value instead. E.g. PositiveInt.

mapper : 'T -> 'T
pred : 'T -> bool
a : Arbitrary<'T>
Returns: Arbitrary<'T>

Arb.mapKV (keys, values)

Full Usage: Arb.mapKV (keys, values)

Parameters:
Returns: Arbitrary<Map<'TKey, 'TValue>>

Generates Map values. Not named `map` because that has other meanings.

keys : Arbitrary<'TKey>
values : Arbitrary<'TValue>
Returns: Arbitrary<Map<'TKey, 'TValue>>

Arb.nullable value

Full Usage: Arb.nullable value

Parameters:
Returns: Arbitrary<Nullable<'T>>

Generates nullable values that are null 1/8 of the time.

value : Arbitrary<'T>
Returns: Arbitrary<Nullable<'T>>

Arb.option value

Full Usage: Arb.option value

Parameters:
Returns: Arbitrary<'T option>

Generates option values that are None 1/8 of the time.

value : Arbitrary<'T>
Returns: Arbitrary<'T option>

Arb.pureFunction target

Full Usage: Arb.pureFunction target

Parameters:
Returns: Arbitrary<('T -> 'U)>

Generates pure functions that produce the given output values 'U. There is no shrinking for functions.

target : Arbitrary<'U>
Returns: Arbitrary<('T -> 'U)>

Arb.set elements

Full Usage: Arb.set elements

Parameters:
Returns: Arbitrary<Set<'T>>

Generates Set<'T> values.

elements : Arbitrary<'T>
Returns: Arbitrary<Set<'T>>

Arb.throwingFunction exceptions target

Full Usage: Arb.throwingFunction exceptions target

Parameters:
Returns: Arbitrary<('T -> 'U)>

Generates F# function values that generate an instance of the function result type about half the time. The other times it generate one of the given exceptions.

exceptions : seq<Exception>
target : Arbitrary<'U>
Returns: Arbitrary<('T -> 'U)>

Arb.toGen arb

Full Usage: Arb.toGen arb

Parameters:
Returns: Gen<'Value>

Get the Gen from the given Arbitary.

arb : Arbitrary<'Value>
Returns: Gen<'Value>

Arb.toShrink arb

Full Usage: Arb.toShrink arb

Parameters:
Returns: 'Value -> seq<'Value>

Get the shrinker function from the given Arbitrary.

arb : Arbitrary<'Value>
Returns: 'Value -> seq<'Value>

Arb.zip (t1, t2)

Full Usage: Arb.zip (t1, t2)

Parameters:
Returns: Arbitrary<'T1 * 'T2>

Generates 2-tuples.

t1 : Arbitrary<'T1>
t2 : Arbitrary<'T2>
Returns: Arbitrary<'T1 * 'T2>