QuickCheck will then attempt to generate a test case that falsifies the assertion. In order to do that, it needs to know which generator to use, to feed xs with random values.

A generator for lists of integers

Values for xs need to be generated by a generator. The following one is for lists of type integer:

letg=Gen.listGen.int;;valg:Gen<intlist>

QuickCheck Properties

Every possible value generated by the g generator must now be supplied to the assertion, as shown below:

funxs->List.rev(List.revxs)=xs|>Property.forAllg;;valit:Property

But what is forAll? This comes from predicate logic and essentially means that the assertion holds for all possible values generated by g:

letforAll(g:Gen<'a>)(f:('a->'b)):Property=Prop(gen{let!x=g(* Get 'a from the Gen<'a>. *)let!actual=fx(* Apply the value 'a to f. *)|>convert(* Turn it into a Property. *)|>evaluate(* Get the results from it. *)return{actualwithArguments=x.ToString()::result.Arguments}})

In its simplest form, Property is a generator of Result, (Gen<Result>)1, which means we can easily try out a Property just as we would do with a generator.