FsCheck


Gen

Namespace: FsCheck

Combinators to build custom random generators for any type.

Functions and values

Function or valueDescription
apply f gn
Signature: f:Gen<('a -> 'b)> -> gn:Gen<'a> -> Gen<'b>
Type parameters: 'a, 'b Attributes:
[<CompiledName("Apply")>]

Apply the given Gen function to the given generator, aka the applicative <*> operator.

CompiledName: Apply

array2DOf(g)
Signature: g:Gen<'a> -> Gen<'a [,]>
Type parameters: 'a Attributes:
[<CompiledName("Array2DOf")>]

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

CompiledName: Array2DOf

array2DOfDim(rows, cols) g
Signature: (rows:int * cols:int) -> g:Gen<'a> -> Gen<'a [,]>
Type parameters: 'a Attributes:
[<CompiledName("Array2DOf")>]

Generates a 2D array of the given dimensions.

CompiledName: Array2DOf

arrayOf(g)
Signature: g:Gen<'a> -> Gen<'a []>
Type parameters: 'a Attributes:
[<CompiledName("ArrayOf")>]

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

CompiledName: ArrayOf

arrayOfLength n g
Signature: n:int -> g:Gen<'a> -> Gen<'a []>
Type parameters: 'a Attributes:
[<CompiledName("ArrayOf")>]

Generates an array of a specified length.

CompiledName: ArrayOf

choose(l, h)
Signature: (l:int * h:int) -> Gen<int>
Attributes:
[<CompiledName("Choose")>]

Generates an integer between l and h, inclusive.

CompiledName: Choose

constant(v)
Signature: v:'b -> Gen<'b>
Type parameters: 'b Attributes:
[<CompiledName("Constant")>]

Always generate the same instance v. See also fresh.

CompiledName: Constant

elements(xs)
Signature: xs:seq<'a> -> Gen<'a>
Type parameters: 'a Attributes:
[<CompiledName("Elements")>]

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

CompiledName: Elements

elementsArr(values)
Signature: values:'?202630 array -> Gen<'?202630>
Type parameters: '?202630 Attributes:
[<CompiledName("Elements")>]
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]

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

CompiledName: Elements

eval size seed arg3
Signature: size:int -> seed:StdGen -> Gen<'b> -> 'b
Type parameters: 'b Attributes:
[<CompiledName("Eval")>]

Generates a value of the give size with the given seed.

CompiledName: Eval

filter predicate generator
Signature: predicate:('a18 -> bool) -> generator:Gen<'a18> -> Gen<'a18>
Type parameters: 'a18 Attributes:
[<CompiledName("Filter")>]

Generates a value that satisfies a predicate. Contrary to tryFilter, this function keeps re-trying by increasing the size of the original generator ad infinitum. Make sure there is a high probability that the predicate is satisfied.

The filter function is an alias for the where function. These two functions are identical, but co-exist so that you can choose the word that makes your code most readable in your given context.

CompiledName: Filter

four(g)
Signature: g:Gen<'b> -> Gen<'b * 'b * 'b * 'b>
Type parameters: 'b Attributes:
[<CompiledName("Four")>]

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

CompiledName: Four

frequency(xs)
Signature: xs:seq<int * Gen<'a18>> -> Gen<'a18>
Type parameters: 'a18 Attributes:
[<CompiledName("Frequency")>]

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.

CompiledName: Frequency

frequencySeqWeightAndValue(...)
Signature: weightedValues:seq<WeightAndValue<Gen<'a>>> -> Gen<'a>
Type parameters: 'a Attributes:
[<CompiledName("Frequency")>]
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]

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.

CompiledName: Frequency

frequencyTupleArr(weightedValues)
Signature: weightedValues:(int * Gen<'a>) [] -> Gen<'a>
Type parameters: 'a Attributes:
[<CompiledName("Frequency")>]
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]

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.

CompiledName: Frequency

frequencyWeightAndValueArr(...)
Signature: weightedValues:WeightAndValue<Gen<'a>> [] -> Gen<'a>
Type parameters: 'a Attributes:
[<CompiledName("Frequency")>]
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]

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.

CompiledName: Frequency

fresh(fv)
Signature: fv:(unit -> '?202612) -> Gen<'?202612>
Type parameters: '?202612 Attributes:
[<CompiledName("Fresh")>]

Generate a fresh instance every time the generator is called. Useful for mutable objects. See also constant.

CompiledName: Fresh

freshFunc(fv)
Signature: fv:Func<'?202614> -> Gen<'?202614>
Type parameters: '?202614 Attributes:
[<CompiledName("Fresh")>]
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]

Generate a fresh instance every time the generatoris called. Useful for mutable objects. See also constant.

CompiledName: Fresh

growingElements(xs)
Signature: xs:seq<'?202634> -> Gen<'?202634>
Type parameters: '?202634 Attributes:
[<CompiledName("GrowingElements")>]

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 runtime size into account.

CompiledName: GrowingElements

listOf(gn)
Signature: gn:Gen<'a> -> Gen<'a list>
Type parameters: 'a Attributes:
[<CompiledName("ListOf")>]

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

CompiledName: ListOf

listOfLength n arb
Signature: n:int -> arb:Gen<'a18> -> Gen<'a18 list>
Type parameters: 'a18 Attributes:
[<CompiledName("ListOf")>]

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

CompiledName: ListOf

map f gen
Signature: f:('a -> 'b) -> gen:Gen<'a> -> Gen<'b>
Type parameters: 'a, 'b Attributes:
[<CompiledName("Map")>]

Apply the function f to the value in the generator, yielding a new generator.

CompiledName: Map

map2 f a b
Signature: f:('c -> 'd -> 'e) -> a:Gen<'c> -> b:Gen<'d> -> Gen<'e>
Type parameters: 'c, 'd, 'e Attributes:
[<CompiledName("Map2")>]

Map the given function over values to a function over generators of those values.

CompiledName: Map2

map3 f a b c
Signature: f:('a18 -> 'a19 -> 'a20 -> 'a21) -> a:Gen<'a18> -> b:Gen<'a19> -> c:Gen<'a20> -> Gen<'a21>
Type parameters: 'a18, 'a19, 'a20, 'a21 Attributes:
[<CompiledName("Map3")>]

Map the given function over values to a function over generators of those values.

CompiledName: Map3

map4 f a b c d
Signature: f:('?202663 -> '?202664 -> '?202665 -> '?202666 -> '?202667) -> a:Gen<'?202663> -> b:Gen<'?202664> -> c:Gen<'?202665> -> d:Gen<'?202666> -> Gen<'?202667>
Type parameters: '?202663, '?202664, '?202665, '?202666, '?202667 Attributes:
[<CompiledName("Map4")>]

Map the given function over values to a function over generators of those values.

CompiledName: Map4

map5 f a b c d e
Signature: f:('a18 -> 'a19 -> 'a20 -> 'a21 -> 'a22 -> 'a23) -> a:Gen<'a18> -> b:Gen<'a19> -> c:Gen<'a20> -> d:Gen<'a21> -> e:Gen<'a22> -> Gen<'a23>
Type parameters: 'a18, 'a19, 'a20, 'a21, 'a22, 'a23 Attributes:
[<CompiledName("Map5")>]

Map the given function over values to a function over generators of those values.

CompiledName: Map5

map6 f a b c d e g
Signature: f:('?202678 -> '?202679 -> '?202680 -> '?202681 -> '?202682 -> '?202683 -> '?202684) -> a:Gen<'?202678> -> b:Gen<'?202679> -> c:Gen<'?202680> -> d:Gen<'?202681> -> e:Gen<'?202682> -> g:Gen<'?202683> -> Gen<'?202684>
Type parameters: '?202678, '?202679, '?202680, '?202681, '?202682, '?202683, '?202684 Attributes:
[<CompiledName("Map6")>]

Map the given function over values to a function over generators of those values.

CompiledName: Map6

nonEmptyListOf(gn)
Signature: gn:Gen<'b> -> Gen<'b list>
Type parameters: 'b Attributes:
[<CompiledName("NonEmptyListOf")>]

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

CompiledName: NonEmptyListOf

oneof(gens)
Signature: gens:seq<Gen<'a>> -> Gen<'a>
Type parameters: 'a Attributes:
[<CompiledName("OneOf")>]

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

CompiledName: OneOf

oneOfArr(generators)
Signature: generators:Gen<'?202638> array -> Gen<'?202638>
Type parameters: '?202638 Attributes:
[<CompiledName("OneOf")>]
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]

Build a generator that generates a value from one of the given generators, with equal probability.

CompiledName: OneOf

optionOf(g)
Signature: g:Gen<'b> -> Gen<'b option>
Type parameters: 'b

Generate an option value that is 'None' 1/8 of the time.

piles k sum
Signature: k:int -> sum:int -> Gen<int []>
Attributes:
[<CompiledName("Piles")>]

Generates a random array of length k where the sum of all elements equals the given sum.

CompiledName: Piles

resize newSize arg2
Signature: newSize:int -> Gen<'b> -> Gen<'b>
Type parameters: 'b Attributes:
[<CompiledName("Resize")>]

Override the current size of the test. resize n g invokes generator g with size parameter n.

CompiledName: Resize

sample size n generator
Signature: size:int -> n:int -> generator:Gen<'b> -> 'b list
Type parameters: 'b Attributes:
[<CompiledName("Sample")>]

Generates n values of the given size.

CompiledName: Sample

sequence(l)
Signature: l:seq<Gen<'a>> -> Gen<'a list>
Type parameters: 'a Attributes:
[<CompiledName("SequenceToList")>]

Sequence the given enumerable of generators into a generator of a list.

CompiledName: SequenceToList

sequenceToArr(generators)
Signature: generators:Gen<'b> array -> Gen<'b []>
Type parameters: 'b Attributes:
[<CompiledName("Sequence")>]

Sequence the given array of generators into a generator of a array.

CompiledName: Sequence

sequenceToSeq(generators)
Signature: generators:seq<Gen<'?202702>> -> Gen<seq<'?202702>>
Type parameters: '?202702 Attributes:
[<CompiledName("Sequence")>]

Sequence the given enumerable of generators into a generator of an enumerable.

CompiledName: Sequence

shuffle(xs)
Signature: xs:seq<'?202710> -> Gen<'?202710 array>
Type parameters: '?202710 Attributes:
[<CompiledName("Shuffle")>]

Generates a random permutation of the given sequence.

CompiledName: Shuffle

sized(fgen)
Signature: fgen:(int -> Gen<'b>) -> Gen<'b>
Type parameters: 'b Attributes:
[<CompiledName("Sized")>]

Obtain the current size. sized g calls g, passing it the current size as a parameter.

CompiledName: Sized

sizedFunc(sizedGen)
Signature: sizedGen:Func<int,Gen<'?202621>> -> Gen<'?202621>
Type parameters: '?202621 Attributes:
[<CompiledName("Sized")>]
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]

Obtain the current size. sized g calls g, passing it the current size as a parameter.

CompiledName: Sized

subListOf(l)
Signature: l:seq<'?202729> -> Gen<'?202729 list>
Type parameters: '?202729 Attributes:
[<CompiledName("SubListOfToList")>]

Generates sublists of the given sequence.

CompiledName: SubListOfToList

subListOfArr(s)
Signature: s:'?202733 array -> Gen<IList<'?202733>>
Type parameters: '?202733 Attributes:
[<CompiledName("SubListOf")>]
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]

Generates sublists of the given arguments.

CompiledName: SubListOf

subListOfToIList(s)
Signature: s:seq<'?202731> -> Gen<IList<'?202731>>
Type parameters: '?202731 Attributes:
[<CompiledName("SubListOf")>]
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]

Generates sublists of the given IEnumerable.

CompiledName: SubListOf

suchThat
Signature: ('?202722 -> bool) -> Gen<'?202722> -> Gen<'?202722>
Type parameters: '?202722 Attributes:
[<Obsolete("This function will be removed in a future version of FsCheck. Please use the synonyms where or filter instead.")>]
[<CompiledName("SuchThat")>]
WARNING: This API is obsolete

This function will be removed in a future version of FsCheck. Please use the synonyms where or filter instead.

Generates a value that satisfies a predicate. Contrary to suchThatOption, this function keeps re-trying by increasing the size of the original generator ad infinitum. Make sure there is a high probability that the predicate is satisfied.

CompiledName: SuchThat

suchThatOption
Signature: ('?202716 -> bool) -> Gen<'?202716> -> Gen<'?202716 option>
Type parameters: '?202716 Attributes:
[<Obsolete("This function will be removed in a future version of FsCheck. Please use the synonyms tryWhere or tryFilter instead.")>]
[<CompiledName("SuchThatOption")>]
[<EditorBrowsable(1)>]
WARNING: This API is obsolete

This function will be removed in a future version of FsCheck. Please use the synonyms tryWhere or tryFilter instead.

Tries to generate a value that satisfies a predicate. This function 'gives up' by generating None if the given original generator did not generate any values that satisfied the predicate, after trying to get values by increasing its size.

CompiledName: SuchThatOption

three(g)
Signature: g:Gen<'b> -> Gen<'b * 'b * 'b>
Type parameters: 'b Attributes:
[<CompiledName("Three")>]

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

CompiledName: Three

tryFilter predicate generator
Signature: predicate:('?202714 -> bool) -> generator:Gen<'?202714> -> Gen<'?202714 option>
Type parameters: '?202714 Attributes:
[<CompiledName("TryFilter")>]

Tries to generate a value that satisfies a predicate. This function 'gives up' by generating None if the given original generator did not generate any values that satisfied the predicate, after trying to get values by increasing its size.

The tryFilter function is an alias for the tryWhere function. These two functions are identical, but co-exist so that you can choose the word that makes your code most readable in your given context.

CompiledName: TryFilter

tryWhere predicate generator
Signature: predicate:('a -> bool) -> generator:Gen<'a> -> Gen<'a option>
Type parameters: 'a Attributes:
[<CompiledName("TryWhere")>]

Tries to generate a value that satisfies a predicate. This function 'gives up' by generating None if the given original generator did not generate any values that satisfied the predicate, after trying to get values by increasing its size.

The tryWhere function is also aliased as tryFilter. These two functions are identical, but co-exist so that you can choose the word that makes your code most readable in your given context.

CompiledName: TryWhere

two(g)
Signature: g:Gen<'a18> -> Gen<'a18 * 'a18>
Type parameters: 'a18 Attributes:
[<CompiledName("Two")>]

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

CompiledName: Two

unzip(g)
Signature: g:Gen<'?202693 * '?202694> -> Gen<'?202693> * Gen<'?202694>
Type parameters: '?202693, '?202694

Split a generator of pairs into a pair of generators.

unzip3(g)
Signature: g:Gen<'?202696 * '?202697 * '?202698> -> Gen<'?202696> * Gen<'?202697> * Gen<'?202698>
Type parameters: '?202696, '?202697, '?202698

Split a generator of 3-tuples into a 3-tuple of generators.

where predicate generator
Signature: predicate:('b -> bool) -> generator:Gen<'b> -> Gen<'b>
Type parameters: 'b Attributes:
[<CompiledName("Where")>]

Generates a value that satisfies a predicate. Contrary to tryWhere, this function keeps re-trying by increasing the size of the original generator ad infinitum. Make sure there is a high probability that the predicate is satisfied.

The where function is also aliased as filter. These two functions are identical, but co-exist so that you can choose the word that makes your code most readable in your given context.

CompiledName: Where

zip f g
Signature: f:Gen<'c> -> g:Gen<'d> -> Gen<'c * 'd>
Type parameters: 'c, 'd

Combine two generators into a generator of pairs.

zip3 f g h
Signature: f:Gen<'d> -> g:Gen<'e> -> h:Gen<'f> -> Gen<'d * 'e * 'f>
Type parameters: 'd, 'e, 'f

Combine three generators into a generator of 3-tuples.

Fork me on GitHub