The QuickCheckVariant package

[ Tags: gpl, library, testing ] [ Propose Tags ]

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


[Skip to Readme]

Properties

Versions 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.1.1.0, 0.2.0.0
Dependencies base (>4.6 && <5), QuickCheck [details]
License GPL-3
Author Jorge Santiago Alvarez Cuadros
Maintainer sanjorgek@ciencias.unam.mx
Category Testing
Home page https://github.com/sanjorgek/QuickCheckVariant
Bug tracker https://github.com/sanjorgek/QuickCheckVariant/issues
Source repository head: git clone git@github.com:sanjorgek/QuickCheckVariant.git
Uploaded Mon Jan 23 08:12:02 UTC 2017 by sanjorgek
Distributions NixOS:0.2.0.0
Downloads 629 total (173 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-01-23 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for QuickCheckVariant-0.2.0.0

[back to package description]

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