FsCheck


Gen Type

Namespace: FsCheck.Fluent

Assembly: FsCheck.dll

Base Type: obj

Table of contents

Other module members

Static members

Static member Description

Gen.Array2DOf(elementGen)

Full Usage: Gen.Array2DOf(elementGen)

Parameters:
    elementGen : Gen<'T>

Returns: Gen<'T[,]>

Generates a 2D array. The square root of the size is the maximum number of rows and columns.

elementGen : Gen<'T>
Returns: Gen<'T[,]>

Gen.Array2DOf(elementGen, rows, cols)

Full Usage: Gen.Array2DOf(elementGen, rows, cols)

Parameters:
    elementGen : Gen<'T>
    rows : int
    cols : int

Returns: Gen<'T[,]>

Generates a 2D array of the given dimensions.

elementGen : Gen<'T>
rows : int
cols : int
Returns: Gen<'T[,]>

Gen.ArrayOf(elementGen)

Full Usage: Gen.ArrayOf(elementGen)

Parameters:
    elementGen : Gen<'T>

Returns: Gen<'T[]>

Generates an array using the specified generator. The maximum length is size+1.

elementGen : Gen<'T>
Returns: Gen<'T[]>

Gen.ArrayOf(elementGen, length)

Full Usage: Gen.ArrayOf(elementGen, length)

Parameters:
    elementGen : Gen<'T>
    length : int

Returns: Gen<'T[]>

Generates an array of a specified length.

elementGen : Gen<'T>
length : int
Returns: Gen<'T[]>

Gen.Cast(gen)

Full Usage: Gen.Cast(gen)

Parameters:
    gen : Gen<'T>

Returns: Gen<'T>

No-op, added to allow type annotations in LINQ expressions, e.g. from T x in e

gen : Gen<'T>
Returns: Gen<'T>

Gen.Choose(l, h)

Full Usage: Gen.Choose(l, h)

Parameters:
    l : int
    h : int

Returns: Gen<int>

Generates integers between l and h, inclusive.

l : int
h : int
Returns: Gen<int>

Gen.Constant(value)

Full Usage: Gen.Constant(value)

Parameters:
    value : 'T

Returns: Gen<'T>

Always generate the same given value. See also Fresh.

value : 'T
Returns: Gen<'T>

Gen.Elements(elements)

Full Usage: Gen.Elements(elements)

Parameters:
    elements : 'T[]

Returns: Gen<'T>

Build a generator that randomly generates one of the values in the given non-empty array.

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

Gen.Elements(elements)

Full Usage: Gen.Elements(elements)

Parameters:
    elements : seq<'T>

Returns: Gen<'T>

Build a generator that randomly generates one of the values in the given non-empty, finite sequence.

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

Gen.Four(g)

Full Usage: Gen.Four(g)

Parameters:
Returns: Gen<'T * 'T * 'T * 'T>

Build a generator that generates a 4-tuple of the values generated by the given generator.

g : Gen<'T>
Returns: Gen<'T * 'T * 'T * 'T>

Gen.Frequency(dist)

Full Usage: Gen.Frequency(dist)

Parameters:
    dist : (int * Gen<'T>) array - Sequence of tuples where each tuple contains a weight and a generator.

Returns: Gen<'T>

Build a generator that generates a value from one of the generators in the given non-empty arrat, with given probabilities. The sum of the probabilities must be larger than zero.

dist : (int * Gen<'T>) array

Sequence of tuples where each tuple contains a weight and a generator.

Returns: Gen<'T>
ArgumentException Thrown if the sum of the probabilities is less than or equal to 0.

Gen.Frequency(dist)

Full Usage: Gen.Frequency(dist)

Parameters:
    dist : seq<int * Gen<'T>> - Sequence of tuples where each tuple contains a weight and a generator.

Returns: Gen<'T>

Build a generator that generates a value from one of the generators in the given non-empty seq, with given probabilities. The sum of the probabilities must be larger than zero.

dist : seq<int * Gen<'T>>

Sequence of tuples where each tuple contains a weight and a generator.

Returns: Gen<'T>
ArgumentException Thrown if the sum of the probabilities is less than or equal to 0.

Gen.Fresh(create)

Full Usage: Gen.Fresh(create)

Parameters:
Returns: Gen<Gen<'T>>

Generate fresh instances by calling create every time the generator generates a new value. Useful for generating new instances of mutable objects. See also constant.

create : Func<Gen<'T>>
Returns: Gen<Gen<'T>>

Gen.GrowingElements(elements)

Full Usage: Gen.GrowingElements(elements)

Parameters:
    elements : 'T[]

Returns: Gen<'T>

Build a generator that takes a non-empty array and randomly generates one of the values among an initial segment of that array. The size of this initial segment increases with the size parameter. Essentially this generator is Gen.Elements but taking also the size into account.

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

Gen.GrowingElements(elements)

Full Usage: Gen.GrowingElements(elements)

Parameters:
    elements : seq<'T>

Returns: Gen<'T>

Build a generator that takes a non-empty sequence and randomly generates one of the values among an initial segment of that sequence. The size of this initial segment increases with the size parameter. Essentially this generator is Gen.Elements but taking also the size into account.

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

Gen.ListOf(elementGen)

Full Usage: Gen.ListOf(elementGen)

Parameters:
    elementGen : Gen<'T>

Returns: Gen<List<'T>>

Generates a list of random length. The maximum length depends on the size parameter.

elementGen : Gen<'T>
Returns: Gen<List<'T>>

Gen.ListOf(elementGen, nbOfElements)

Full Usage: Gen.ListOf(elementGen, nbOfElements)

Parameters:
    elementGen : Gen<'T>
    nbOfElements : int

Returns: Gen<List<'T>>

Generates a list of given length, containing values generated by the given generator.

elementGen : Gen<'T>
nbOfElements : int
Returns: Gen<List<'T>>

Gen.NonEmptyListOf(elementGen)

Full Usage: Gen.NonEmptyListOf(elementGen)

Parameters:
    elementGen : Gen<'T>

Returns: Gen<List<'T>>

Generates a non-empty list of random length. The maximum length depends on the size parameter.

elementGen : Gen<'T>
Returns: Gen<List<'T>>

Gen.OneOf(gens)

Full Usage: Gen.OneOf(gens)

Parameters:
    gens : Gen<'T> array

Returns: Gen<'T>

Build a generator that generates a value from one of the generators in the given non-empty array, with equal probability.

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

Gen.OneOf(gens)

Full Usage: Gen.OneOf(gens)

Parameters:
    gens : seq<Gen<'T>>

Returns: Gen<'T>

Build a generator that generates a value from one of the generators in the given non-empty sequence, with equal probability.

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

Gen.Or(generator, other)

Full Usage: Gen.Or(generator, other)

Parameters:
    generator : Gen<'T>
    other : Gen<'T>

Returns: Gen<'T>

Build a generator that generates a value from two generators with equal probability.

generator : Gen<'T>
other : Gen<'T>
Returns: Gen<'T>

Gen.OrNull(generator)

Full Usage: Gen.OrNull(generator)

Parameters:
    generator : Gen<'T>

Returns: Gen<'T>

Build a generator that generates a value or `null` 1/8th of the time.

generator : Gen<'T>
Returns: Gen<'T>

Gen.Piles(length, sum)

Full Usage: Gen.Piles(length, sum)

Parameters:
    length : int
    sum : int

Returns: Gen<int[]>

Generates random arrays of given length where the sum of all elements equals the given sum.

length : int
sum : int
Returns: Gen<int[]>

Gen.Resize(generator, newSize)

Full Usage: Gen.Resize(generator, newSize)

Parameters:
    generator : Gen<'T>
    newSize : int

Returns: Gen<'T>

Override the current size.

generator : Gen<'T>
newSize : int
Returns: Gen<'T>

Gen.Sample(generator, numberOfSamples, seed, size)

Full Usage: Gen.Sample(generator, numberOfSamples, seed, size)

Parameters:
    generator : Gen<'T>
    numberOfSamples : int
    seed : Rnd
    size : int

Returns: 'T[]

Generates numberOfSample values with the given seed and of the given size.

generator : Gen<'T>
numberOfSamples : int
seed : Rnd
size : int
Returns: 'T[]

Gen.Sample(generator, numberOfSamples, size)

Full Usage: Gen.Sample(generator, numberOfSamples, size)

Parameters:
    generator : Gen<'T>
    numberOfSamples : int
    size : int

Returns: 'T[]

Generates numberOfSample values with the given size.

generator : Gen<'T>
numberOfSamples : int
size : int
Returns: 'T[]

Gen.Sample(generator, numberOfSamples)

Full Usage: Gen.Sample(generator, numberOfSamples)

Parameters:
    generator : Gen<'T>
    numberOfSamples : int

Returns: 'T[]

Generates numberOfSample values with a new seed and size 50.

generator : Gen<'T>
numberOfSamples : int
Returns: 'T[]

Gen.ScaleSize(generator, scaleFunc)

Full Usage: Gen.ScaleSize(generator, scaleFunc)

Parameters:
    generator : Gen<'T>
    scaleFunc : Func<int, int>

Returns: Gen<'T>

Modify a size using the given function before passing it to the given generator.

generator : Gen<'T>
scaleFunc : Func<int, int>
Returns: Gen<'T>

Gen.Select(source, selector)

Full Usage: Gen.Select(source, selector)

Parameters:
    source : Gen<'T>
    selector : Func<'T, 'U>

Returns: Gen<'U>

Create a new generator by applying selector to each value in the given generator.

source : Gen<'T>
selector : Func<'T, 'U>
Returns: Gen<'U>

Gen.SelectMany(source, selector, resultSelector)

Full Usage: Gen.SelectMany(source, selector, resultSelector)

Parameters:
    source : Gen<'T>
    selector : Func<'T, Gen<'U>>
    resultSelector : Func<'T, 'U, 'TResult>

Returns: Gen<'TResult>

Creates a new generator that generates values from the source generator, applies the selector to them to get a new generator, and generates values by applying the resultSelector to the source value and the value from the second generator.

source : Gen<'T>
selector : Func<'T, Gen<'U>>
resultSelector : Func<'T, 'U, 'TResult>
Returns: Gen<'TResult>

Gen.SelectMany(source, selector)

Full Usage: Gen.SelectMany(source, selector)

Parameters:
Returns: Gen<'U>

Creates a new generator that generates values from the source generator, applies the selector to them, and generates values from the resulting generator.

source : Gen<'T>
selector : Func<'T, Gen<'U>>
Returns: Gen<'U>

Gen.Shuffle(source)

Full Usage: Gen.Shuffle(source)

Parameters:
    source : 'T array

Returns: Gen<'T array>

Generates random permutations of the given array.

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

Gen.Shuffle(source)

Full Usage: Gen.Shuffle(source)

Parameters:
    source : seq<'T>

Returns: Gen<'T array>

Generates random permutations of the given sequence.

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

Gen.Sized(createWithSize)

Full Usage: Gen.Sized(createWithSize)

Parameters:
    createWithSize : Func<int, Gen<'T>>

Returns: Gen<'T>

Obtain the current size. Sized(g) calls g, passing it the current size as a parameter.

createWithSize : Func<int, Gen<'T>>
Returns: Gen<'T>

Gen.SubListOf(source)

Full Usage: Gen.SubListOf(source)

Parameters:
    source : 'T array

Returns: Gen<List<'T>>

Generates sublists of the given array. For a given list of length n, each sublist has between 0 and n elements, and the order of the elements is the same as in the given sequence.

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

Gen.SubListOf(lst)

Full Usage: Gen.SubListOf(lst)

Parameters:
    lst : seq<'T>

Returns: Gen<List<'T>>

Generates sublists of the given sequence. For a given list of length n, each sublist has between 0 and n elements, and the order of the elements is the same as in the given sequence.

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

Gen.Three(g)

Full Usage: Gen.Three(g)

Parameters:
Returns: Gen<'T * 'T * 'T>

Build a generator that generates a 3-tuple of the values generated by the given generator.

g : Gen<'T>
Returns: Gen<'T * 'T * 'T>

Gen.Two(g)

Full Usage: Gen.Two(g)

Parameters:
Returns: Gen<'T * 'T>

Build a generator that generates a 2-tuple of the values generated by the given generator.

g : Gen<'T>
Returns: Gen<'T * 'T>

Gen.Where(source, predicate)

Full Usage: Gen.Where(source, predicate)

Parameters:
    source : Gen<'T>
    predicate : Func<'T, bool>

Returns: Gen<'T>

Generates only values from the source generator that satisfy the predicate. This function keeps re-trying by increasing the size of the original generator ad infinitum. Make sure there is a high chance that the predicate is satisfied.

source : Gen<'T>
predicate : Func<'T, bool>
Returns: Gen<'T>

Gen.Zip(first, second, resultSelector)

Full Usage: Gen.Zip(first, second, resultSelector)

Parameters:
    first : Gen<'T1>
    second : Gen<'T2>
    resultSelector : Func<'T1, 'T2, 'TResult>

Returns: Gen<'TResult>

Combine two generators into a new generator of the result of the given result selector.

first : Gen<'T1>
second : Gen<'T2>
resultSelector : Func<'T1, 'T2, 'TResult>
Returns: Gen<'TResult>

Gen.Zip(first, second)

Full Usage: Gen.Zip(first, second)

Parameters:
    first : Gen<'T1>
    second : Gen<'T2>

Returns: Gen<'T1 * 'T2>

Combine two generators into a generator of pairs.

first : Gen<'T1>
second : Gen<'T2>
Returns: Gen<'T1 * 'T2>

Create generators from generators

Static members

Static member Description

Gen.CollectToArray(source, createGen)

Full Usage: Gen.CollectToArray(source, createGen)

Parameters:
    source : seq<'T>
    createGen : Func<'T, Gen<'U>>

Returns: Gen<'U[]>

Transform the given sequence into a generator of an array using the given function to create a generator for each element of the sequence. [category: Create generators from generators]

source : seq<'T>
createGen : Func<'T, Gen<'U>>
Returns: Gen<'U[]>

Gen.CollectToArray(source)

Full Usage: Gen.CollectToArray(source)

Parameters:
    source : seq<Gen<'T>>

Returns: Gen<'T[]>

Transform the given sequence of generators into a generator of an array. [category: Create generators from generators]

source : seq<Gen<'T>>
Returns: Gen<'T[]>

Gen.CollectToList(source, createGen)

Full Usage: Gen.CollectToList(source, createGen)

Parameters:
    source : seq<'T>
    createGen : Func<'T, Gen<'U>>

Returns: Gen<List<'U>>

Transform the given sequence into a generator of a List using the given function to create a generator for each element of the sequence. [category: Create generators from generators]

source : seq<'T>
createGen : Func<'T, Gen<'U>>
Returns: Gen<List<'U>>

Gen.CollectToList(source)

Full Usage: Gen.CollectToList(source)

Parameters:
    source : seq<Gen<'T>>

Returns: Gen<List<'T>>

Transform the given sequence of generators into a generator of a List. [category: Create generators from generators]

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

Gen.CollectToSequence(source, createGen)

Full Usage: Gen.CollectToSequence(source, createGen)

Parameters:
    source : seq<'T>
    createGen : Func<'T, Gen<'U>>

Returns: Gen<seq<'U>>

Transform the given sequence into a generator of sequences using the given function to create a generator for each element of the sequence. Each sequence generated by the resulting generator can be infinite, if the source sequence is infinite. [category: Create generators from generators]

source : seq<'T>
createGen : Func<'T, Gen<'U>>
Returns: Gen<seq<'U>>

Gen.CollectToSequence(source)

Full Usage: Gen.CollectToSequence(source)

Parameters:
    source : seq<Gen<'T>>

Returns: Gen<seq<'T>>

Transform the given sequence of generators into a generator of an array. Each sequence generated by the resulting generator can be infinite, if the source sequence is infinite. [category: Create generators from generators]

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