Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module defines the API for HTF tests, i.e. unit tests and quickcheck properties.
This functionality is mainly used internally in the code
generated by the hftpp
pre-processor.
Synopsis
- type Assertion = IO ()
- data TestResult
- data FullTestResult = FullTestResult {
- ftr_stack :: HtfStack
- ftr_message :: Maybe ColorString
- ftr_result :: Maybe TestResult
- data HTFFailureException = HTFFailure FullTestResult
- data HtfStackEntry = HtfStackEntry {}
- data HtfStack
- emptyHtfStack :: HtfStack
- mkHtfStack :: CallStack -> HtfStack
- formatHtfStack :: HtfStack -> String
- failureLocationFromStack :: HtfStack -> Maybe Location
- failureLocation :: HasCallStack => Maybe Location
- restCallStack :: HtfStack -> [HtfStackEntry]
- htfStackToList :: HtfStack -> [HtfStackEntry]
- failHTF :: MonadBaseControl IO m => FullTestResult -> m a
- subAssertHTF :: (HasCallStack, MonadBaseControl IO m) => Maybe String -> m a -> m a
- addCallerToSubAssertStack :: CallStack -> HtfStack -> Maybe String -> HtfStack
- mkFullTestResult :: TestResult -> Maybe String -> FullTestResult
Documentation
type Assertion = IO () Source #
An assertion is just an IO
action. Internally, the body of any test
in HTF is of type Assertion
. If a test specification of a certain plugin
has a type different from Assertion
, the plugin's preprocessor pass must
inject wrapper code to convert the test specification into an assertion.
Assertions may use failHTF
to signal a TestResult
different from
Pass
. If the assertion finishes successfully, the tests passes
implicitly.
Please note: the assertion must not swallow any exceptions! Otherwise, timeouts and other things might not work as expected.
data TestResult Source #
The summary result of a test.
Instances
FromJSON TestResult Source # | |
Defined in Test.Framework.History parseJSON :: Value -> Parser TestResult # parseJSONList :: Value -> Parser [TestResult] # | |
ToJSON TestResult Source # | |
Defined in Test.Framework.History toJSON :: TestResult -> Value # toEncoding :: TestResult -> Encoding # toJSONList :: [TestResult] -> Value # toEncodingList :: [TestResult] -> Encoding # omitField :: TestResult -> Bool # | |
Read TestResult Source # | |
Defined in Test.Framework.TestInterface readsPrec :: Int -> ReadS TestResult # readList :: ReadS [TestResult] # readPrec :: ReadPrec TestResult # readListPrec :: ReadPrec [TestResult] # | |
Show TestResult Source # | |
Defined in Test.Framework.TestInterface showsPrec :: Int -> TestResult -> ShowS # show :: TestResult -> String # showList :: [TestResult] -> ShowS # | |
Eq TestResult Source # | |
Defined in Test.Framework.TestInterface (==) :: TestResult -> TestResult -> Bool # (/=) :: TestResult -> TestResult -> Bool # |
data FullTestResult Source #
The full result of a test, as used by HTF plugins.
FullTestResult | |
|
Instances
Read FullTestResult Source # | |
Defined in Test.Framework.TestInterface readsPrec :: Int -> ReadS FullTestResult # readList :: ReadS [FullTestResult] # | |
Show FullTestResult Source # | |
Defined in Test.Framework.TestInterface showsPrec :: Int -> FullTestResult -> ShowS # show :: FullTestResult -> String # showList :: [FullTestResult] -> ShowS # | |
Eq FullTestResult Source # | |
Defined in Test.Framework.TestInterface (==) :: FullTestResult -> FullTestResult -> Bool # (/=) :: FullTestResult -> FullTestResult -> Bool # |
data HTFFailureException Source #
Instances
Exception HTFFailureException Source # | |
Show HTFFailureException Source # | |
Defined in Test.Framework.TestInterface showsPrec :: Int -> HTFFailureException -> ShowS # show :: HTFFailureException -> String # showList :: [HTFFailureException] -> ShowS # |
data HtfStackEntry Source #
Instances
Read HtfStackEntry Source # | |
Defined in Test.Framework.TestInterface readsPrec :: Int -> ReadS HtfStackEntry # readList :: ReadS [HtfStackEntry] # | |
Show HtfStackEntry Source # | |
Defined in Test.Framework.TestInterface showsPrec :: Int -> HtfStackEntry -> ShowS # show :: HtfStackEntry -> String # showList :: [HtfStackEntry] -> ShowS # | |
Eq HtfStackEntry Source # | |
Defined in Test.Framework.TestInterface (==) :: HtfStackEntry -> HtfStackEntry -> Bool # (/=) :: HtfStackEntry -> HtfStackEntry -> Bool # | |
Ord HtfStackEntry Source # | |
Defined in Test.Framework.TestInterface compare :: HtfStackEntry -> HtfStackEntry -> Ordering # (<) :: HtfStackEntry -> HtfStackEntry -> Bool # (<=) :: HtfStackEntry -> HtfStackEntry -> Bool # (>) :: HtfStackEntry -> HtfStackEntry -> Bool # (>=) :: HtfStackEntry -> HtfStackEntry -> Bool # max :: HtfStackEntry -> HtfStackEntry -> HtfStackEntry # min :: HtfStackEntry -> HtfStackEntry -> HtfStackEntry # |
mkHtfStack :: CallStack -> HtfStack Source #
formatHtfStack :: HtfStack -> String Source #
Formats a stack trace.
restCallStack :: HtfStack -> [HtfStackEntry] Source #
htfStackToList :: HtfStack -> [HtfStackEntry] Source #
failHTF :: MonadBaseControl IO m => FullTestResult -> m a Source #
Terminate a HTF test, usually to signal a failure. The result of the test
is given in the FullTestResult
argument.
subAssertHTF :: (HasCallStack, MonadBaseControl IO m) => Maybe String -> m a -> m a Source #
Opens a new assertion stack frame to allow for sensible location information.
This function should be used if the function being called does not carry
a HasCallStack
annotation.
mkFullTestResult :: TestResult -> Maybe String -> FullTestResult Source #
Auxiliary function for contructing a FullTestResult
.