packages feed

registry-hedgehog 0.7.0.0 → 0.7.0.1

raw patch · 5 files changed

+22/−8 lines, 5 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Test.Tasty.Hedgehogx: Rec :: K1 R a x -> Rec p a (x :: k)
+ Test.Tasty.Hedgehogx: [unRec] :: Rec p a (x :: k) -> K1 R a x
+ Test.Tasty.Hedgehogx: bmap :: FunctorB b => (forall (a :: k). () => f a -> g a) -> b f -> b g
+ Test.Tasty.Hedgehogx: btraverse :: (TraversableB b, Applicative e) => (forall (a :: k). () => f a -> e (g a)) -> b f -> e (b g)
+ Test.Tasty.Hedgehogx: class FunctorB (b :: k -> Type -> Type)
+ Test.Tasty.Hedgehogx: class FunctorB b => TraversableB (b :: k -> Type -> Type)
+ Test.Tasty.Hedgehogx: infix 4 ===
+ Test.Tasty.Hedgehogx: newtype Rec p a (x :: k)
- Test.Tasty.Hedgehogx: type family GenBase (m :: Type -> Type) :: Type -> Type
+ Test.Tasty.Hedgehogx: type family GenBase (m :: Type -> Type) :: Type -> Type;

Files

registry-hedgehog.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: a80c02532509f28abbb98896582e06adf5292368eac375ffda75cac41fbdb195+-- hash: acce66172a41b60e03857399cb636ac8f5c638cc949f9f2c1ee4263a9962e129  name:           registry-hedgehog-version:        0.7.0.0+version:        0.7.0.1 synopsis:       utilities to work with Hedgehog generators and `registry` description:    This library provides some functions to extract generators from a "Registry" and make stateful modifications of that Registry to precisely control the generation of data category:       Control
src/Data/Registry/Hedgehog/TH.hs view
@@ -22,12 +22,18 @@ makeGenerators genType = do   info <- reify genType   case info of+    TyConI (NewtypeD _context _name _typeVars _kind constructor _deriving) -> do+      constructorType <- nameOf constructor+      app (genFunOf (conE constructorType)) (varE (mkName "emptyRegistry"))+    TyConI (DataD _context _name _typeVars _kind [constructor] _deriving) -> do+      constructorType <- nameOf constructor+      app (genFunOf (conE constructorType)) (varE (mkName "emptyRegistry"))     TyConI (DataD _context name _typeVars _kind constructors _deriving) -> do       selector <- makeSelectGenerator name constructors       generators <- traverse makeConstructorGenerator constructors       assembleGeneratorsToRegistry selector generators     other -> do-      qReport True ("can only create generators for an ADT, got: " <> show other)+      qReport True ("can not create generators for this kind of data type at the moment. Got: " <> show other)       fail "generators creation failed"  emptyRegistry :: Registry '[] '[]
test/Test/Data/Registry/Company.hs view
@@ -10,17 +10,23 @@   deriving (Eq, Show)  data Department = Department-  { departmentName :: Text,+  { departmentName :: DepartmentName,     employees :: [Employee]   }   deriving (Eq, Show) +newtype DepartmentName = DepartmentName { _departmentName :: Text }+  deriving (Eq, Show)+ data Employee = Employee-  { employeeName :: Text,+  { employeeName :: EmployeeName,     employeeStatus :: EmployeeStatus,     salary :: Int,     bonus :: Maybe Int   }+  deriving (Eq, Show)++newtype EmployeeName = EmployeeName Text   deriving (Eq, Show)  -- | Note that this is an ADT with several constructors
test/Test/Data/Registry/Generators.hs view
@@ -21,9 +21,11 @@     <: fun (listOfMinMax @Department 1 5)     <: genFun Department     <: fun (listOf @Employee)-    <: genFun Employee-    -- we can generate data for different constructors in an ADT with some Template Haskell+    -- we can generate data for constructors of various types+    <: $(makeGenerators ''Employee)     <: $(makeGenerators ''EmployeeStatus)+    <: $(makeGenerators ''DepartmentName)+    <: $(makeGenerators ''EmployeeName)     <: fun (maybeOf @Int)     -- we can generate Lists or Maybe of elements     <: genVal genInt
test/Test/Data/Registry/HedgehogSpec.hs view
@@ -93,7 +93,7 @@   -- uncomment to print the department names and inspect them   -- print company   let Just d = head $ departments company-  (T.length (departmentName d) <= 5) === True+  (T.length (_departmentName $ departmentName d) <= 5) === True  -- | Generate a value with a modified list of generators forallWith :: forall a b c. (HasCallStack, Show a, Typeable a) => (Registry _ _ -> Registry b c) -> PropertyT IO a