Header menu logo testify

Generators Module

Helpers for building FsCheck generators used by Testify property checks.

Functions and values

Function or value Description

Generators.arrayOf

Full Usage: Generators.arrayOf

Returns: Gen<'T array>
Returns: Gen<'T array>

Generators.arrayOfWith arbitrary

Full Usage: Generators.arrayOfWith arbitrary

Parameters:
    arbitrary : Arbitrary<'T> - The arbitrary whose generator should populate the produced arrays.

Returns: Gen<'T array> A generator that creates arrays using arbitrary.

Creates an array generator from an explicit arbitrary.

arbitrary : Arbitrary<'T>

The arbitrary whose generator should populate the produced arrays.

Returns: Gen<'T array>

A generator that creates arrays using arbitrary.

Generators.elements values

Full Usage: Generators.elements values

Parameters:
    values : 'T seq - The candidate values that the generator may choose from.

Returns: Gen<'T> A generator that yields one value from values on each run.

Creates a generator that chooses from a fixed sequence of values.

values : 'T seq

The candidate values that the generator may choose from.

Returns: Gen<'T>

A generator that yields one value from values on each run.

Example

 let weekendGen = Generators.elements [ "Sat"; "Sun" ]
val weekendGen: obj

Generators.from

Full Usage: Generators.from

Returns: Gen<'T> The resolved generator for 'T from CheckConfig.defaultConfig.

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

Returns: Gen<'T>

The resolved generator for 'T from CheckConfig.defaultConfig.

Example

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

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

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

Generators.fromArb arbitrary

Full Usage: Generators.fromArb arbitrary

Parameters:
    arbitrary : Arbitrary<'T> - The arbitrary whose generator should be reused.

Returns: Gen<'T> The generator component of arbitrary.
Modifiers: inline
Type parameters: 'T

Extracts the generator portion of an arbitrary.

arbitrary : Arbitrary<'T>

The arbitrary whose generator should be reused.

Returns: Gen<'T>

The generator component of arbitrary.

Generators.fromConfig config

Full Usage: Generators.fromConfig config

Parameters:
    config : Config - The configuration whose arbitrary map should provide the generator.

Returns: Gen<'T> The resolved generator for 'T from config.

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

config : Config

The configuration whose arbitrary map should provide the generator.

Returns: Gen<'T>

The resolved generator for 'T from config.

Generators.listOf

Full Usage: Generators.listOf

Returns: Gen<'T list>
Returns: Gen<'T list>

Generators.listOfLength length

Full Usage: Generators.listOfLength length

Parameters:
    length : int

Returns: Gen<'T list>
length : int
Returns: Gen<'T list>

Generators.listOfLengthWith length arbitrary

Full Usage: Generators.listOfLengthWith length arbitrary

Parameters:
    length : int - The required list length.
    arbitrary : Arbitrary<'T> - The arbitrary whose generator should populate the produced lists.

Returns: Gen<'T list> A generator that creates lists of exactly length items.

Creates a fixed-length list generator from an explicit arbitrary.

length : int

The required list length.

arbitrary : Arbitrary<'T>

The arbitrary whose generator should populate the produced lists.

Returns: Gen<'T list>

A generator that creates lists of exactly length items.

Example

 let wordGen =
     Generators.listOfLengthWith
         5
         (Arbitraries.from<char>)
val wordGen: obj
Multiple items
val char: value: 'T -> char (requires member op_Explicit)

--------------------
type char = System.Char

Generators.listOfWith arbitrary

Full Usage: Generators.listOfWith arbitrary

Parameters:
    arbitrary : Arbitrary<'T> - The arbitrary whose generator should populate the produced lists.

Returns: Gen<'T list> A generator that creates lists using arbitrary.

Creates a list generator from an explicit arbitrary.

arbitrary : Arbitrary<'T>

The arbitrary whose generator should populate the produced lists.

Returns: Gen<'T list>

A generator that creates lists using arbitrary.

Generators.map mapping generator

Full Usage: Generators.map mapping generator

Parameters:
    mapping : 'T -> 'U - The projection applied to each generated value.
    generator : Gen<'T> - The source generator.

Returns: Gen<'U> A generator that maps each produced value through mapping.
Modifiers: inline
Type parameters: 'T, 'U

Maps generated values through the supplied projection.

mapping : 'T -> 'U

The projection applied to each generated value.

generator : Gen<'T>

The source generator.

Returns: Gen<'U>

A generator that maps each produced value through mapping.

Generators.seqOf

Full Usage: Generators.seqOf

Returns: Gen<'T seq>
Returns: Gen<'T seq>

Generators.seqOfWith arbitrary

Full Usage: Generators.seqOfWith arbitrary

Parameters:
    arbitrary : Arbitrary<'T> - The arbitrary whose generator should populate the produced sequences.

Returns: Gen<'T seq> A generator that creates sequences using arbitrary.

Creates a sequence generator from an explicit arbitrary.

arbitrary : Arbitrary<'T>

The arbitrary whose generator should populate the produced sequences.

Returns: Gen<'T seq>

A generator that creates sequences using arbitrary.

Generators.tuple2 generator1 generator2

Full Usage: Generators.tuple2 generator1 generator2

Parameters:
    generator1 : Gen<'T1> - The generator for the first tuple component.
    generator2 : Gen<'T2> - The generator for the second tuple component.

Returns: Gen<'T1 * 'T2> A generator that produces pairs by sampling both input generators.

Combines two generators into a generator of pairs.

generator1 : Gen<'T1>

The generator for the first tuple component.

generator2 : Gen<'T2>

The generator for the second tuple component.

Returns: Gen<'T1 * 'T2>

A generator that produces pairs by sampling both input generators.

Example

 let pairGen =
     Generators.tuple2
         Generators.from<int>
         Generators.from<string>
val pairGen: 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

Generators.tuple3 generator1 generator2 generator3

Full Usage: Generators.tuple3 generator1 generator2 generator3

Parameters:
    generator1 : Gen<'T1> - The generator for the first tuple component.
    generator2 : Gen<'T2> - The generator for the second tuple component.
    generator3 : Gen<'T3> - The generator for the third tuple component.

Returns: Gen<'T1 * 'T2 * 'T3> A generator that produces triples by sampling all three input generators.

Combines three generators into a generator of triples.

generator1 : Gen<'T1>

The generator for the first tuple component.

generator2 : Gen<'T2>

The generator for the second tuple component.

generator3 : Gen<'T3>

The generator for the third tuple component.

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

A generator that produces triples by sampling all three input generators.

Type something to start searching.