Safe Haskell | None |
---|
Helps you build tests that run against a series of items.
- type Name = Text
- data Verbosity
- = HideAll
- | ShowDefaults
- | ShowAll
- type TrueVerbosity = Verbosity
- type FalseVerbosity = Verbosity
- data ShowTest
- data TestVerbosity = TestVerbosity {}
- type Pass = Bool
- data Test a = Test {
- testName :: Name
- testPass :: [Result] -> Pass
- testFunc :: a -> Result
- testVerbosity :: TestVerbosity
- data TestResult a = TestResult {
- resultName :: Name
- resultPass :: Pass
- resultSubjects :: [(a, Result)]
- resultDefaultVerbosity :: TestVerbosity
- eachSubjectMustBeTrue :: Pdct a -> Name -> Test a
- nSubjectsMustBeTrue :: Pdct a -> Name -> Int -> Test a
- evalTest :: Test a -> [a] -> TestResult a
- showResult :: IndentAmt -> (a -> Text) -> Maybe TestVerbosity -> TestResult a -> [Chunk]
Test data types
How verbose to be when showing the results of running a Pdct on a single subject.
HideAll | Do not show any results from the Pdct |
ShowDefaults | Show results according to the default settings provided in the Result itself |
ShowAll | Show all Result |
type TrueVerbosity = VerbositySource
Use this verbosity for subjects that are True
type FalseVerbosity = VerbositySource
Use this verbosity for subjects that are False
Determines whether to show any of the results from a single test.
HideTest | Do not show any results from this test |
ShowFirstLine TrueVerbosity FalseVerbosity | Show the first line, which indicates whether the test passed or failed and gives the label for the test. Whether to show individual subjects is determined by the TrueVerbosity and FalseVerbosity. |
A single test.
Test | |
|
data TestResult a Source
TestResult | |
|
Pre-built tests
eachSubjectMustBeTrue :: Pdct a -> Name -> Test aSource
The test passes if each subject returns True.
:: Pdct a | |
-> Name | |
-> Int | The number of subjects that must be True. This should be a positive number. |
-> Test a |
The test passes if at least a given number of subjects are True.
Running and showing tests
evalTest :: Test a -> [a] -> TestResult aSource
Evaluates a test for a given list of subjects.
:: IndentAmt | Indent each level by this many spaces |
-> (a -> Text) | Shows each subject. The function should return a single-line text without a trailing newline. |
-> Maybe TestVerbosity | If Just, use this TestVerbosity when showing the test. If Nothing, use the default verbosity. |
-> TestResult a | The result to show |
-> [Chunk] |
Shows a result with indenting.