FsCheck
FsCheck copied to clipboard
Generate built-in `Range`
Hi! 👋
Was thinking of adding a built-in generator of the System.Range
struct, as this would expand the default generator functionality.
Am currently using this:
let range = gen {
let! min = Gen.choose (0, Int32.MaxValue)
let! max = Gen.choose (min, Int32.MaxValue)
return Range (min, max) }
To make sure that the minimum is always lower than the maximum. But, with some additional options, one could include Range.StartAt
and Range.EndAt
too.
Just a suggestion when using the awesome FsCheck library 😉 .
Related: there's also Interval
Ah, shoot, didn't see that one. Maybe that would be ok, too. I'll try that. Thx!
Aha, found everything I needed. Thx for this! 👍
Maybe an idea to create an extra generator that generate the built-in System.Range
from an Interval
?
But that may be overdoing it.
Maybe an idea to create an extra generator that generate the built-in System.Range from an Interval?
Yeah I think that makes sense. Or even extract the code and parametrize the contructor, could be slightly faster without creating an intermediate type.
For standard types like System.Range
I think it certainly makes sense to have them built-in.
Great! Happy to pick this up, but the supported frameworks on the main project are still not in the range where the System.Range
is supported (net452;netstandard2.0;netstandard1.6;netstandard1.0
) so maybe this could be set up on-hold till we update FsCheck towards .NET 6.