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

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

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

Generates a 2D array of the given dimensions.

CompiledName: Array2DOf

arrayOf g
Signature: g:Gen<'a> -> Gen<'a []>
Type parameters: 'a

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

Generates an array of a specified length.

CompiledName: ArrayOf

choose (l, h)
Signature: (l:int * h:int) -> Gen<int>

Generates an integer between l and h, inclusive.

CompiledName: Choose

constant v
Signature: v:'b -> Gen<'b>
Type parameters: 'b

Always generate the same instance v. See also fresh.

CompiledName: Constant

elements xs
Signature: xs:seq<'a> -> Gen<'a>
Type parameters: 'a

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

CompiledName: Elements

elementsArr values
Signature: values:'?74449 array -> Gen<'?74449>
Type parameters: '?74449

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

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

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

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

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

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

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

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 -> '?74431) -> Gen<'?74431>
Type parameters: '?74431

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

CompiledName: Fresh

freshFunc fv
Signature: fv:Func<'?74433> -> Gen<'?74433>
Type parameters: '?74433

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

CompiledName: Fresh

growingElements xs
Signature: xs:seq<'?74453> -> Gen<'?74453>
Type parameters: '?74453

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

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

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

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

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

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

CompiledName: Map3

map4 f a b c d
Signature: f:('?74482 -> '?74483 -> '?74484 -> '?74485 -> '?74486) -> a:Gen<'?74482> -> b:Gen<'?74483> -> c:Gen<'?74484> -> d:Gen<'?74485> -> Gen<'?74486>
Type parameters: '?74482, '?74483, '?74484, '?74485, '?74486

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:('?74490 -> '?74491 -> '?74492 -> '?74493 -> '?74494 -> '?74495) -> a:Gen<'?74490> -> b:Gen<'?74491> -> c:Gen<'?74492> -> d:Gen<'?74493> -> e:Gen<'?74494> -> Gen<'?74495>
Type parameters: '?74490, '?74491, '?74492, '?74493, '?74494, '?74495

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:('?74497 -> '?74498 -> '?74499 -> '?74500 -> '?74501 -> '?74502 -> '?74503) -> a:Gen<'?74497> -> b:Gen<'?74498> -> c:Gen<'?74499> -> d:Gen<'?74500> -> e:Gen<'?74501> -> g:Gen<'?74502> -> Gen<'?74503>
Type parameters: '?74497, '?74498, '?74499, '?74500, '?74501, '?74502, '?74503

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

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

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<'?74457> array -> Gen<'?74457>
Type parameters: '?74457

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 []>

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

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

Generates n values of the given size.

CompiledName: Sample

sequence l
Signature: l:seq<Gen<'a>> -> Gen<'a list>
Type parameters: 'a

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

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

CompiledName: Sequence

sequenceToSeq generators
Signature: generators:seq<Gen<'?74521>> -> Gen<seq<'?74521>>
Type parameters: '?74521

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

CompiledName: Sequence

shuffle xs
Signature: xs:seq<'?74529> -> Gen<'?74529 array>
Type parameters: '?74529

Generates a random permutation of the given sequence.

CompiledName: Shuffle

sized fgen
Signature: fgen:(int -> Gen<'b>) -> Gen<'b>
Type parameters: 'b

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<'?74440>> -> Gen<'?74440>
Type parameters: '?74440

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

CompiledName: Sized

subListOf l
Signature: l:seq<'?74548> -> Gen<'?74548 list>
Type parameters: '?74548

Generates sublists of the given sequence.

CompiledName: SubListOfToList

subListOfArr s
Signature: s:'?74552 array -> Gen<IList<'?74552>>
Type parameters: '?74552

Generates sublists of the given arguments.

CompiledName: SubListOf

subListOfToIList s
Signature: s:seq<'?74550> -> Gen<IList<'?74550>>
Type parameters: '?74550

Generates sublists of the given IEnumerable.

CompiledName: SubListOf

suchThat
Signature: ('?74541 -> bool) -> Gen<'?74541> -> Gen<'?74541>
Type parameters: '?74541

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: ('?74535 -> bool) -> Gen<'?74535> -> Gen<'?74535 option>
Type parameters: '?74535

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

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

CompiledName: Three

tryFilter predicate generator
Signature: predicate:('?74533 -> bool) -> generator:Gen<'?74533> -> Gen<'?74533 option>
Type parameters: '?74533

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

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

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

CompiledName: Two

unzip g
Signature: g:Gen<'?74512 * '?74513> -> Gen<'?74512> * Gen<'?74513>
Type parameters: '?74512, '?74513

Split a generator of pairs into a pair of generators.

unzip3 g
Signature: g:Gen<'?74515 * '?74516 * '?74517> -> Gen<'?74515> * Gen<'?74516> * Gen<'?74517>
Type parameters: '?74515, '?74516, '?74517

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

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<'?74505> -> g:Gen<'?74506> -> Gen<'?74505 * '?74506>
Type parameters: '?74505, '?74506

Combine two generators into a generator of pairs.

zip3 f g h
Signature: f:Gen<'?74508> -> g:Gen<'?74509> -> h:Gen<'?74510> -> Gen<'?74508 * '?74509 * '?74510>
Type parameters: '?74508, '?74509, '?74510

Combine three generators into a generator of 3-tuples.

Fork me on GitHub