FsCheck


ArbitraryExtensions

Namespace: FsCheck

Extensons to transform Arbitrary instances into other Arbitrary instances.

Static members

Static memberDescription
Convert(arb, convertTo, convertFrom)
Signature: (arb:Arbitrary<'?72808> * convertTo:Func<'?72808,'?72809> * convertFrom:Func<'?72809,'?72808>) -> Arbitrary<'?72809>
Type parameters: '?72808, '?72809

Construct an Arbitrary instance for a type that can be mapped to and from another type (e.g. a wrapper), based on a Arbitrary instance for the source type and two mapping functions.

Filter(arb, filter)
Signature: (arb:Arbitrary<'?72811> * filter:Func<'?72811,bool>) -> Arbitrary<'?72811>
Type parameters: '?72811

Return an Arbitrary instance that is a filtered version of an existing arbitrary instance. The generator uses Gen.suchThat, and the shrinks are filtered using Seq.filter with the given predicate.

MapFilter(arb, map, filter)
Signature: (arb:Arbitrary<'?72813> * map:Func<'?72813,'?72813> * filter:Func<'?72813,bool>) -> Arbitrary<'?72813>
Type parameters: '?72813

Return an Arbitrary instance that is a mapped and filtered version of an existing arbitrary instance. The generator uses Gen.map with the given mapper and then Gen.suchThat with the given predicate, and the shrinks are filtered using Seq.filter with the given predicate. This is sometimes useful if using just a filter would reduce the chance of getting a good value from the generator - and you can map the value instead. E.g. PositiveInt.

Fork me on GitHub