Parameterize generators with a Range
Clarification and motivation
Cleveland exposes many hedgehog generators.
For some types, like Mutez
, we provide two generators. One that generates an arbitrary value among all possible values (genMutez
) and another that lets the user specify the range (genMutez'
)
-- | Generates an arbitrary `Mutez` value using the data type's full range.
genMutez :: MonadGen m => m Mutez
genMutez = genMutez' Range.linearBounded
-- | Generates an arbitrary `Mutez` value constrained to the given range.
genMutez' :: MonadGen m => Range Mutez -> m Mutez
genMutez' range = unsafeMkMutez <$> Gen.word64 (unMutez <$> range)
We should do this across the board, where it makes sense.
For example, genTimestamp
generates a timestamp between 0
and 86399
. We should add a variation that lets users specify the range.
There may be other types that need this too, we should have a deep look at this.
Once we have this, we should take the time to update any relevant call sites. For example:
Acceptance criteria
- We have a function that lets users specify the range for
Timestamp
and any other types where this might seem appropriate. - The call sites where these new generators can be used have been updated.
Edited by Diogo Castro