Safe HaskellNone



Unittest helpers for TemplateHaskell components.



propPrefix :: String Source #

Test property prefix.

casePrefix :: String Source #

Test case prefix.

case2Pfx :: String Source #

Test case prefix without underscore.

simplifyName :: String -> String -> String Source #

Tries to drop a prefix from a string.

runProp :: Testable prop => String -> prop -> Test Source #

Builds a test from a QuickCheck property.

runCase :: String -> Assertion -> Test Source #

Builds a test for a HUnit test case.

run :: Name -> Q Exp Source #

Runs the correct test provider for a given test, based on its name (not very nice, but...).

mapSlashes :: String -> String Source #

Convert slashes in a name to underscores.

testSuite :: String -> [Name] -> Q [Dec] Source #

Builds a test suite.

mkConsArbitrary :: (Name, [a]) -> Exp Source #

Builds an arbitrary value for a given constructor. This doesn't use the actual types of the fields, since we expect arbitrary instances for all of the types anyway, we only care about the number of fields.

conInfo :: Con -> (Name, [Type]) Source #

Extracts the name and the types from a constructor.

mkRegularArbitrary :: Name -> [Con] -> Q [Dec] Source #

Builds an arbitrary instance for a regular data type (i.e. not Bounded).

genArbitrary :: Name -> Q [Dec] Source #

Builds a default Arbitrary instance for a type. This requires that all members are of types that already have Arbitrary instances, and that the arbitrary instances are well behaved (w.r.t. recursive data structures, or similar concerns). In that sense, this is not appropriate for all data types, just those that are simple but very repetitive or have many simple fields.