Header menu logo testify

Arbitraries Module

Helpers for assembling custom FsCheck arbitraries used by Testify checks.

Functions and values

Function or value Description

Arbitraries.arrayOf

Full Usage: Arbitraries.arrayOf

Returns: Arbitrary<'T array>
Returns: Arbitrary<'T array>

Arbitraries.convert toValue fromValue arbitrary

Full Usage: Arbitraries.convert toValue fromValue arbitrary

Parameters:
    toValue : 'T1 -> 'T2 - Converts source arbitrary values into the target representation.
    fromValue : 'T2 -> 'T1 - Converts target values back to the source representation for shrinking.
    arbitrary : Arbitrary<'T1> - The source arbitrary.

Returns: Arbitrary<'T2> A mapped arbitrary for the target type.

Maps an arbitrary from one type to another using reversible conversion functions.

toValue : 'T1 -> 'T2

Converts source arbitrary values into the target representation.

fromValue : 'T2 -> 'T1

Converts target values back to the source representation for shrinking.

arbitrary : Arbitrary<'T1>

The source arbitrary.

Returns: Arbitrary<'T2>

A mapped arbitrary for the target type.

Arbitraries.filter predicate arbitrary

Full Usage: Arbitraries.filter predicate arbitrary

Parameters:
    predicate : 'T -> bool - The predicate that candidate values must satisfy.
    arbitrary : Arbitrary<'T> - The arbitrary to filter.

Returns: Arbitrary<'T> An arbitrary that only keeps values satisfying predicate.

Filters the generated values of an arbitrary with the supplied predicate.

predicate : 'T -> bool

The predicate that candidate values must satisfy.

arbitrary : Arbitrary<'T>

The arbitrary to filter.

Returns: Arbitrary<'T>

An arbitrary that only keeps values satisfying predicate.

Arbitraries.from

Full Usage: Arbitraries.from

Returns: Arbitrary<'T> The resolved arbitrary for 'T from CheckConfig.defaultConfig.

Looks up the arbitrary for a type from the neutral CheckConfig.defaultConfig.

Returns: Arbitrary<'T>

The resolved arbitrary for 'T from CheckConfig.defaultConfig.

Example

 let intArb = Arbitraries.from<int>
val intArb: obj
Multiple items
val int: value: 'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int

Arbitraries.fromConfig config

Full Usage: Arbitraries.fromConfig config

Parameters:
    config : Config - The configuration whose arbitrary map should be queried.

Returns: Arbitrary<'T> The resolved arbitrary for 'T from config.

Looks up the arbitrary for a type from the supplied configuration.

config : Config

The configuration whose arbitrary map should be queried.

Returns: Arbitrary<'T>

The resolved arbitrary for 'T from config.

Arbitraries.fromGen generator

Full Usage: Arbitraries.fromGen generator

Parameters:
    generator : Gen<'T> - The generator that should produce values.

Returns: Arbitrary<'T> An arbitrary that uses generator and FsCheck's default empty shrinker.

Creates an arbitrary from a generator without a custom shrinker.

generator : Gen<'T>

The generator that should produce values.

Returns: Arbitrary<'T>

An arbitrary that uses generator and FsCheck's default empty shrinker.

Example

 let digitArb =
     Arbitraries.fromGen (Generators.elements [ '0' .. '9' ])
val digitArb: obj

Arbitraries.fromGenShrink generator shrinker

Full Usage: Arbitraries.fromGenShrink generator shrinker

Parameters:
    generator : Gen<'T> - The generator that should produce values.
    shrinker : 'T -> 'T seq - The shrinker used to reduce failing counterexamples.

Returns: Arbitrary<'T> An arbitrary that uses the supplied generator and shrinker.

Creates an arbitrary from a generator and an explicit shrinker.

generator : Gen<'T>

The generator that should produce values.

shrinker : 'T -> 'T seq

The shrinker used to reduce failing counterexamples.

Returns: Arbitrary<'T>

An arbitrary that uses the supplied generator and shrinker.

Arbitraries.listOf

Full Usage: Arbitraries.listOf

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

Arbitraries.pairOf

Full Usage: Arbitraries.pairOf

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

Arbitraries.seqOf

Full Usage: Arbitraries.seqOf

Returns: Arbitrary<'T seq>
Returns: Arbitrary<'T seq>

Arbitraries.tripleOf

Full Usage: Arbitraries.tripleOf

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

Arbitraries.tuple2 arbitrary1 arbitrary2

Full Usage: Arbitraries.tuple2 arbitrary1 arbitrary2

Parameters:
    arbitrary1 : Arbitrary<'T1> - The arbitrary for the first tuple component.
    arbitrary2 : Arbitrary<'T2> - The arbitrary for the second tuple component.

Returns: Arbitrary<'T1 * 'T2> An arbitrary that generates and shrinks pairs.

Builds an arbitrary that generates and shrinks pairs from two arbitraries.

arbitrary1 : Arbitrary<'T1>

The arbitrary for the first tuple component.

arbitrary2 : Arbitrary<'T2>

The arbitrary for the second tuple component.

Returns: Arbitrary<'T1 * 'T2>

An arbitrary that generates and shrinks pairs.

Example

 let pairArb =
     Arbitraries.tuple2
         (Arbitraries.from<int>)
         (Arbitraries.from<string>)
val pairArb: obj
Multiple items
val int: value: 'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int
Multiple items
val string: value: 'T -> string

--------------------
type string = System.String

Arbitraries.tuple3 arbitrary1 arbitrary2 arbitrary3

Full Usage: Arbitraries.tuple3 arbitrary1 arbitrary2 arbitrary3

Parameters:
    arbitrary1 : Arbitrary<'T1> - The arbitrary for the first tuple component.
    arbitrary2 : Arbitrary<'T2> - The arbitrary for the second tuple component.
    arbitrary3 : Arbitrary<'T3> - The arbitrary for the third tuple component.

Returns: Arbitrary<'T1 * 'T2 * 'T3> An arbitrary that generates and shrinks triples.

Builds an arbitrary that generates and shrinks triples from three arbitraries.

arbitrary1 : Arbitrary<'T1>

The arbitrary for the first tuple component.

arbitrary2 : Arbitrary<'T2>

The arbitrary for the second tuple component.

arbitrary3 : Arbitrary<'T3>

The arbitrary for the third tuple component.

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

An arbitrary that generates and shrinks triples.

Type something to start searching.