hedgehog-gen: Customizable Gen for ADT using Generics

[ bsd3, library, testing ] [ Propose Tags ] [ Report a vulnerability ]

Customizable Gen for ADT using Generics with the abilites to do type-based and field-based overrides of Gen.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.9 && <5), bytestring (>=0.10 && <0.11), hedgehog (>1.0 && <1.1), text (>=1.1 && <1.3), typerep-map (>=0.3.2) [details]
License BSD-3-Clause
Copyright © 2020 ByteAlly
Author Magesh
Maintainer magesh85@gmail.com
Category Testing
Home page https://github.com/byteally/hedgehog-gen
Bug tracker https://github.com/byteally/hedgehog-gen/issues
Uploaded by magesh at 2020-02-24T17:46:41Z
Distributions
Downloads 439 total (8 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for hedgehog-gen-0.1.0.0

[back to package description]

hedgehog-gen

Customizable Gen for ADT using Generics

Tutorial


import Hedgehog
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range
import Hedgehog.Gen.Generic
import Data.Function

data Gender = Male | Female | Other
  deriving (Show, Eq, Generic)

data User = User
  { name :: Text
  , age :: Word
  , gender :: Gender
  } deriving (Show, Eq, Generic)

userGen1 :: Hedgehog.Gen User
userGen1 = mkGen emptyGens


userGen2 :: Hedgehog.Gen User
userGen2 = mkGen $ emptyGens
           & byField @User @"age" (Gen.word (Range.constant 1 120))
           & byPos @User @1 (Gen.element ["foo", "bar", "baz"])