packages feed

QuickCheckVariant 0.1.0.4 → 0.1.1.0

raw patch · 3 files changed

+46/−1 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Test.QuickCheck.Variant: class VarTesteable prop
+ Test.QuickCheck.Variant: instance (Test.QuickCheck.Arbitrary.Arbitrary a, Test.QuickCheck.Variant.Variant a, GHC.Show.Show a, Test.QuickCheck.Property.Testable prop) => Test.QuickCheck.Variant.VarTesteable (a -> prop)
+ Test.QuickCheck.Variant: instance Test.QuickCheck.Variant.VarTesteable GHC.Types.Bool
+ Test.QuickCheck.Variant: propertyInvalid :: VarTesteable prop => prop -> Property
+ Test.QuickCheck.Variant: propertyValid :: VarTesteable prop => prop -> Property

Files

QuickCheckVariant.cabal view
@@ -2,7 +2,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             0.1.0.4+version:             0.1.1.0 synopsis:            Generator of "valid" and "invalid" data in a type class description:         Generator of "valid" and "invalid" data in a type class homepage:            https://github.com/sanjorgek/QuickCheckVariant
README.md view
@@ -1,4 +1,26 @@ # QuickCheckVariant Generator of "valid" and "invalid" data in a type class +For example, if you created+~~~haskell+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:+~~~haskell+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](https://wiki.haskell.org/QuickCheck_as_a_test_set_generator) for more details
src/Test/QuickCheck/Variant.hs view
@@ -109,3 +109,26 @@     y <- valid     z <- valid         return (x, y, z)++{-|+The class of things wich can be tested with invalid or valid input.+-}+class VarTesteable prop where+  -- |Property for valid input+  propertyValid::prop -> Property+  -- |Property for invalid input  +  propertyInvalid::prop -> Property++{-|+Same as Testeable+-}+instance VarTesteable Bool where+  propertyValid = property+  propertyInvalid = property++{-|+Instead of variant we use valid or invalid generators+-}+instance (Arbitrary a, Variant a, Show a, Testable prop) => VarTesteable (a->prop) where+  propertyValid = forAllShrink valid shrink+  propertyInvalid = forAllShrink invalid shrink