hedgehog-gen: Customizable Gen for ADT using Generics

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

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


[Skip to Readme]

Properties

Versions 0.1.0.0, 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:35:00Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


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"])