Write you some QuickCheck  Generating random long integers
This post is part of a series of posts on implementing a minimal version of QuickCheck from scratch. The source code is available on GitHub.
Two generators are required for this, which have been ported already on previous posts:
 a generator for integers (with absolute value bounded by the generation size)
 a generator that applies a function (in this case
Operators.int64<^T>
) to an existing generator
The long integers are going to be generated by the integer returned by the first generator and then multiplied by a 16bit^{1} integerâ€™s largest possible value.
Given the above, a long integer generator can be written as:
/// <summary>
/// Generates a 64bit integer (with absolute value bounded by the generation
/// size multiplied by 16bit integer's largest possible value).
/// </summary>
let int64 = Gen.int > Gen.map (fun n > Operators.int64 (n * 32767))
val int64 : Gen<int64>
Finally, here are some sample long integers:
> Gen.int64 > Gen.generate;;
val it : int64 = 294903L
> Gen.int64 > Gen.generate;;
val it : int64 = 32767L
> Gen.int64 > Gen.generate;;
val it : int64 = 163835L
> Gen.int64 > Gen.generate;;
val it : int64 = 131068L
> Gen.int64 > Gen.generate;;
val it : int64 = 65534L
> Gen.int64 > Gen.generate;;
val it : int64 = 229369L
> Gen.int64 > Gen.generate;;
val it : int64 = 393204L

To be more precise, I should use a 32bit integerâ€™s largest possible value, but then the generated numbers become very big and less interesting. ↩