The QuickCheckVariant package

[maintain]

Generator of valid and invalid data in a type class


[Skip to ReadMe]

Properties

Versions0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.1.1.0, 0.1.1.0, 0.2.0.0
Dependenciesbase (>4.6 && <5), QuickCheck [details]
LicenseGPL-3
AuthorJorge Santiago Alvarez Cuadros
Maintainersanjorgek@ciencias.unam.mx
CategoryTesting
Home pagehttps://github.com/sanjorgek/QuickCheckVariant
Bug trackerhttps://github.com/sanjorgek/QuickCheckVariant/issues
Source repositoryhead: git clone git@github.com:sanjorgek/QuickCheckVariant.git
UploadedWed Jul 27 23:49:22 UTC 2016 by sanjorgek

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for QuickCheckVariant-0.1.1.0

QuickCheckVariant

Generator of "valid" and "invalid" data in a type class

For example, if you created

data Person = Anonymous { getId::String } | Client { getUsername::String, getName::String, getEmail::String} deriving(Show,Eq)

We can provide means to generate valid and invalid data, like:

instance Variant Person where
  valid = do
    id <- alternative
    username <- alternative
    name <- alternative
    domain <- alternative
    ext <- alternative
    (oneof . return) [Anonymous id, Client username name (username++"@"++domain++ext)]
  invalid = do
    username <- alternative
    name <- alternative
    return $ Client username name ""

See this post for more details