-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | The Haskell Test Framework -- -- The Haskell Test Framework (HTF for short) lets you define and -- organize unit tests, QuickCheck properties, and black box tests in an -- easy and convenient way. HTF uses a custom preprocessor that collects -- test definitions automatically. -- -- HTF produces highly readable output for failing test cases: it -- provides exact file name and line number information, it colors and -- pretty prints expected and actual results, and it displays a diff -- highlighting the mismatching parts. -- -- The documentation of the Test.Framework.Tutorial module -- provides a tutorial for HTF. The sample directory in the HTF -- repo provides a good starting point for a project using HTF. @package HTF @version 0.15.0.2 -- | Internal module for types and functions dealing with source code -- locations. module Test.Framework.Location -- | An abstract type representing locations in a file. data Location -- | The unknown location (file ? and line 0). unknownLocation :: Location -- | Extract the file name of a Location. fileName :: Location -> String -- | Extract the line number of a Location. lineNumber :: Location -> Int -- | Render a Location as a String. showLoc :: Location -> String -- | Create a new location. makeLoc :: String -> Int -> Location instance GHC.Read.Read Test.Framework.Location.Location instance GHC.Show.Show Test.Framework.Location.Location instance GHC.Classes.Ord Test.Framework.Location.Location instance GHC.Classes.Eq Test.Framework.Location.Location -- | Internal module providing access to some functionality of cpphs. module Test.Framework.Preprocessor transform :: TransformOptions -> FilePath -> String -> IO String progName :: String preprocessorTests :: [(String, IO ())] data TransformOptions TransformOptions :: Bool -> Bool -> TransformOptions [debug] :: TransformOptions -> Bool [literateTex] :: TransformOptions -> Bool instance GHC.Show.Show Test.Framework.Preprocessor.Definition instance GHC.Classes.Eq Test.Framework.Preprocessor.Definition instance GHC.Classes.Eq Test.Framework.Preprocessor.ImportDecl instance GHC.Show.Show Test.Framework.Preprocessor.ImportDecl instance GHC.Classes.Eq Test.Framework.Preprocessor.ModuleInfo instance GHC.Show.Show Test.Framework.Preprocessor.ModuleInfo -- | This module defines the Pretty type class. The assert functions -- from HUnitWrapper use the pretty-printing functionality -- provided by this type class so as to provide nicely formatted error -- messages. -- -- Additionally, this module re-exports the standard Haskell -- pretty-printing module PrettyPrint module Test.Framework.Pretty -- | A type class for pretty-printable things. Minimal complete definition: -- pretty. class Pretty a -- | Pretty-print a single value. pretty :: Pretty a => a -> Doc -- | Pretty-print a list of things. prettyList :: Pretty a => [a] -> Doc -- | Pretty-print a single value as a String. showPretty :: Pretty a => a -> String -- | Utility function for inserting a = between two Doc -- values. (<=>) :: Doc -> Doc -> Doc -- | Rendering mode. data () => Mode -- | Normal rendering (lineLength and ribbonsPerLine -- respected'). PageMode :: Mode -- | With zig-zag cuts. ZigZagMode :: Mode -- | No indentation, infinitely long lines (lineLength ignored), but -- explicit new lines, i.e., text "one" $$ text "two", are -- respected. LeftMode :: Mode -- | All on one line, lineLength ignored and explicit new lines -- ($$) are turned into spaces. OneLineMode :: Mode -- | A rendering style. Allows us to specify constraints to choose among -- the many different rendering options. data () => Style Style :: Mode -> Int -> Float -> Style -- | The rendering mode. [mode] :: Style -> Mode -- | Maximum length of a line, in characters. [lineLength] :: Style -> Int -- | Ratio of line length to ribbon length. A ribbon refers to the -- characters on a line excluding indentation. So a -- lineLength of 100, with a ribbonsPerLine of 2.0 -- would only allow up to 50 characters of ribbon to be displayed on a -- line, while allowing it to be indented up to 50 characters. [ribbonsPerLine] :: Style -> Float -- | The abstract type of documents. A Doc represents a set of -- layouts. A Doc with no occurrences of Union or NoDoc represents just -- one layout. data () => Doc -- | A TextDetails represents a fragment of text that will be output at -- some point in a Doc. data () => TextDetails -- | A single Char fragment Chr :: {-# UNPACK #-} !Char -> TextDetails -- | A whole String fragment Str :: String -> TextDetails -- | Used to represent a Fast String fragment but now deprecated and -- identical to the Str constructor. PStr :: String -> TextDetails -- | A document of height 1 containing a literal string. text -- satisfies the following laws: -- --
-- -- The side condition on the last law is necessary because -- text "" has height 1, while empty has no -- height. text :: String -> Doc -- | The empty document, with no height and no width. empty is the -- identity for <>, <+>, $$ and -- $+$, and anywhere in the argument list for sep, -- hcat, hsep, vcat, fcat etc. empty :: Doc comma :: Doc colon :: Doc int :: Int -> Doc integer :: Integer -> Doc float :: Float -> Doc double :: Double -> Doc -- | A document of height and width 1, containing a literal character. char :: Char -> Doc parens :: Doc -> Doc -- | Beside, separated by space, unless one of the arguments is -- empty. <+> is associative, with identity -- empty. (<+>) :: Doc -> Doc -> Doc infixl 6 <+> -- | Returns True if the document is empty isEmpty :: Doc -> Bool -- | The default style (mode=PageMode, lineLength=100, -- ribbonsPerLine=1.5). style :: Style space :: Doc braces :: Doc -> Doc brackets :: Doc -> Doc semi :: Doc -- | Same as text. Used to be used for Bytestrings. ptext :: String -> Doc -- | Some text with any width. (text s = sizedText (length s) s) sizedText :: Int -> String -> Doc -- | Some text, but without any width. Use for non-printing text such as a -- HTML or Latex tags zeroWidthText :: String -> Doc equals :: Doc lparen :: Doc rparen :: Doc lbrack :: Doc rbrack :: Doc lbrace :: Doc rbrace :: Doc rational :: Rational -> Doc quotes :: Doc -> Doc doubleQuotes :: Doc -> Doc -- | List version of <>. hcat :: [Doc] -> Doc -- | List version of <+>. hsep :: [Doc] -> Doc -- | List version of $$. vcat :: [Doc] -> Doc -- | Nest (or indent) a document by a given number of positions (which may -- also be negative). nest satisfies the laws: -- --nest 0 x = x
nest k (nest k' x) = nest (k+k') -- x
nest k (x <> y) = nest k x -- <> nest k y
nest k (x $$ y) = nest k x $$ -- nest k y
nest k empty = empty
-- hang d1 n d2 = sep [d1, nest n d2] --hang :: Doc -> Int -> Doc -> Doc -- |
-- punctuate p [d1, ... dn] = [d1 <> p, d2 <> p, ... dn-1 <> p, dn] --punctuate :: Doc -> [Doc] -> [Doc] -- | Above, except that if the last line of the first argument stops at -- least one position before the first line of the second begins, these -- two lines are overlapped. For example: -- --
-- text "hi" $$ nest 5 (text "there") ---- -- lays out as -- --
-- hi there ---- -- rather than -- --
-- hi -- there ---- -- $$ is associative, with identity empty, and also -- satisfies -- -- ($$) :: Doc -> Doc -> Doc infixl 5 $$ -- | Above, with no overlapping. $+$ is associative, with identity -- empty. ($+$) :: Doc -> Doc -> Doc infixl 5 $+$ -- | Either hsep or vcat. sep :: [Doc] -> Doc -- | Either hcat or vcat. cat :: [Doc] -> Doc -- | "Paragraph fill" version of cat. fcat :: [Doc] -> Doc -- | "Paragraph fill" version of sep. fsep :: [Doc] -> Doc -- | Render the Doc to a String using the default Style -- (see style). render :: Doc -> String -- | Render the Doc to a String using the given Style. renderStyle :: Style -> Doc -> String -- | The general rendering interface. Please refer to the Style -- and Mode types for a description of rendering mode, line -- length and ribbons. fullRender :: Mode -> Int -> Float -> (TextDetails -> a -> a) -> a -> Doc -> a instance Test.Framework.Pretty.Pretty GHC.Types.Char instance Test.Framework.Pretty.Pretty a => Test.Framework.Pretty.Pretty [a] instance Test.Framework.Pretty.Pretty GHC.Types.Int instance Test.Framework.Pretty.Pretty GHC.Types.Bool -- | 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. module Test.Framework.TestInterface -- | 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. type Assertion = IO () -- | The summary result of a test. data TestResult Pass :: TestResult Pending :: TestResult Fail :: TestResult Error :: TestResult -- | The full result of a test, as used by HTF plugins. data FullTestResult FullTestResult :: HtfStack -> Maybe ColorString -> Maybe TestResult -> FullTestResult -- | The stack to the location of a possible failure [ftr_stack] :: FullTestResult -> HtfStack -- | An error message [ftr_message] :: FullTestResult -> Maybe ColorString -- | The outcome of the test, Nothing means timeout [ftr_result] :: FullTestResult -> Maybe TestResult data HTFFailureException HTFFailure :: FullTestResult -> HTFFailureException data HtfStackEntry HtfStackEntry :: Location -> String -> Maybe String -> HtfStackEntry [hse_location] :: HtfStackEntry -> Location [hse_calledFunction] :: HtfStackEntry -> String [hse_message] :: HtfStackEntry -> Maybe String data HtfStack emptyHtfStack :: HtfStack mkHtfStack :: CallStack -> HtfStack -- | Formats a stack trace. formatHtfStack :: HtfStack -> String failureLocationFromStack :: HtfStack -> Maybe Location failureLocation :: HasCallStack => Maybe Location restCallStack :: HtfStack -> [HtfStackEntry] htfStackToList :: HtfStack -> [HtfStackEntry] -- | Terminate a HTF test, usually to signal a failure. The result of the -- test is given in the FullTestResult argument. failHTF :: MonadBaseControl IO m => FullTestResult -> m a -- | 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. subAssertHTF :: (HasCallStack, MonadBaseControl IO m) => Maybe String -> m a -> m a addCallerToSubAssertStack :: CallStack -> HtfStack -> Maybe String -> HtfStack -- | Auxiliary function for contructing a FullTestResult. mkFullTestResult :: TestResult -> Maybe String -> FullTestResult instance GHC.Classes.Eq Test.Framework.TestInterface.TestResult instance GHC.Read.Read Test.Framework.TestInterface.TestResult instance GHC.Show.Show Test.Framework.TestInterface.TestResult instance GHC.Read.Read Test.Framework.TestInterface.HtfStackEntry instance GHC.Show.Show Test.Framework.TestInterface.HtfStackEntry instance GHC.Classes.Ord Test.Framework.TestInterface.HtfStackEntry instance GHC.Classes.Eq Test.Framework.TestInterface.HtfStackEntry instance GHC.Read.Read Test.Framework.TestInterface.HtfStack instance GHC.Show.Show Test.Framework.TestInterface.HtfStack instance GHC.Classes.Ord Test.Framework.TestInterface.HtfStack instance GHC.Classes.Eq Test.Framework.TestInterface.HtfStack instance GHC.Read.Read Test.Framework.TestInterface.FullTestResult instance GHC.Show.Show Test.Framework.TestInterface.FullTestResult instance GHC.Classes.Eq Test.Framework.TestInterface.FullTestResult instance GHC.Show.Show Test.Framework.TestInterface.HTFFailureException instance GHC.Exception.Type.Exception Test.Framework.TestInterface.HTFFailureException -- | Internal module for retaining a history of test runs. module Test.Framework.History data TestHistory data HistoricTestResult HistoricTestResult :: !Text -> !TestResult -> !Bool -> !Milliseconds -> HistoricTestResult [htr_testId] :: HistoricTestResult -> !Text [htr_result] :: HistoricTestResult -> !TestResult [htr_timedOut] :: HistoricTestResult -> !Bool [htr_timeMs] :: HistoricTestResult -> !Milliseconds emptyTestHistory :: TestHistory -- | A type synonym for time in milliseconds. type Milliseconds = Int -- | The summary result of a test. data TestResult Pass :: TestResult Pending :: TestResult Fail :: TestResult Error :: TestResult serializeTestHistory :: TestHistory -> ByteString deserializeTestHistory :: ByteString -> Either String TestHistory findHistoricTestResult :: Text -> TestHistory -> Maybe HistoricTestResult findHistoricSuccessfulTestResult :: Text -> TestHistory -> Maybe HistoricTestResult updateTestHistory :: TestRunHistory -> TestHistory -> TestHistory mkTestRunHistory :: UTCTime -> [HistoricTestResult] -> TestRunHistory historyTests :: [(String, IO ())] instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.History.SerializableTestHistory instance Data.Aeson.Types.FromJSON.FromJSON Test.Framework.History.SerializableTestHistory instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.History.TestRunHistory instance Data.Aeson.Types.FromJSON.FromJSON Test.Framework.History.TestRunHistory instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.History.HistoricTestResult instance Data.Aeson.Types.FromJSON.FromJSON Test.Framework.History.HistoricTestResult instance GHC.Classes.Eq Test.Framework.History.HistoricTestResult instance GHC.Show.Show Test.Framework.History.HistoricTestResult instance GHC.Classes.Eq Test.Framework.History.TestRunHistory instance GHC.Classes.Eq Test.Framework.History.TestHistory instance GHC.Show.Show Test.Framework.History.TestHistory instance GHC.Show.Show Test.Framework.History.TestRunHistory instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.TestInterface.TestResult instance Data.Aeson.Types.FromJSON.FromJSON Test.Framework.TestInterface.TestResult -- | This module defines the AssertM monad, which allows you either -- to run assertions as ordinary unit tests or to evaluate them as pure -- functions. module Test.Framework.AssertM -- | A typeclass for generic assertions. class Monad m => AssertM m genericAssertFailure :: (AssertM m, HasCallStack) => ColorString -> m a genericSubAssert :: (AssertM m, HasCallStack) => Maybe String -> m a -> m a -- | Type for evaluating a generic assertion as a pure function. data AssertBool a -- | Assertion passes successfully and yields the given value. AssertOk :: a -> AssertBool a -- | Assertion fails with the given stack trace. In the stack trace, the -- outermost stackframe comes first. AssertFailed :: HtfStack -> String -> AssertBool a -- | Evaluates a generic assertion to a Bool value. boolValue :: AssertBool a -> Bool -- | Evaluates a generic assertion to an Either value. The result is -- Right x if the assertion passes and yields value x, -- otherwise the result is Left err, where err is an -- error message. eitherValue :: AssertBool a -> Either String a instance GHC.Read.Read a => GHC.Read.Read (Test.Framework.AssertM.AssertBool a) instance GHC.Show.Show a => GHC.Show.Show (Test.Framework.AssertM.AssertBool a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Test.Framework.AssertM.AssertBool a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Test.Framework.AssertM.AssertBool a) instance GHC.Base.Functor Test.Framework.AssertM.AssertBool instance GHC.Base.Applicative Test.Framework.AssertM.AssertBool instance GHC.Base.Monad Test.Framework.AssertM.AssertBool instance Test.Framework.AssertM.AssertM Test.Framework.AssertM.AssertBool instance Test.Framework.AssertM.AssertM GHC.Types.IO -- | This module defines types (and small auxiliary functions) for -- organizing tests, for configuring the execution of tests, and for -- representing and reporting their results. -- -- This functionality is mainly used internally in the code generated by -- the hftpp pre-processor. module Test.Framework.TestTypes -- | Type for naming tests. type TestID = String -- | Abstract type for tests and their results. data Test BaseTest :: TestSort -> TestID -> Maybe Location -> TestOptions -> Assertion -> Test CompoundTest :: TestSuite -> Test -- | General options for tests data TestOptions TestOptions :: Bool -> TestOptions [to_parallel] :: TestOptions -> Bool -- | A type class for an assertion with TestOptions. class AssertionWithTestOptions a testOptions :: AssertionWithTestOptions a => a -> TestOptions assertion :: AssertionWithTestOptions a => a -> Assertion -- | Something with TestOptions data WithTestOptions a WithTestOptions :: TestOptions -> a -> WithTestOptions a [wto_options] :: WithTestOptions a -> TestOptions [wto_payload] :: WithTestOptions a -> a -- | Abstract type for test suites and their results. data TestSuite TestSuite :: TestID -> [Test] -> TestSuite AnonTestSuite :: [Test] -> TestSuite -- | Type for distinguishing different sorts of tests. data TestSort UnitTest :: TestSort QuickCheckTest :: TestSort BlackBoxTest :: TestSort -- | A type denoting the hierarchical name of a test. data TestPath TestPathBase :: TestID -> TestPath TestPathCompound :: Maybe TestID -> TestPath -> TestPath -- | Generic type for flattened tests and their results. data GenFlatTest a FlatTest :: TestSort -> TestPath -> Maybe Location -> a -> GenFlatTest a -- | The sort of the test. [ft_sort] :: GenFlatTest a -> TestSort -- | Hierarchival path. [ft_path] :: GenFlatTest a -> TestPath -- | Place of definition. [ft_location] :: GenFlatTest a -> Maybe Location -- | A generic payload. [ft_payload] :: GenFlatTest a -> a -- | Flattened representation of tests. type FlatTest = GenFlatTest (WithTestOptions Assertion) -- | A filter is a predicate on GenFlatTest. If the predicate is -- True, the flat test is run. type TestFilter = FlatTest -> Bool -- | Splits a TestPath into a list of test identifiers. testPathToList :: TestPath -> [Maybe TestID] -- | Creates a string representation from a TestPath. flatName :: TestPath -> String -- | Returns the final name of a TestPath finalName :: TestPath -> String -- | Returns the name of the prefix of a test path. The prefix is -- everything except the last element. prefixName :: TestPath -> String -- | The default TestOptions defaultTestOptions :: TestOptions -- | Shortcut for constructing a WithTestOptions value. withOptions :: (TestOptions -> TestOptions) -> a -> WithTestOptions a -- | Key of a flat test for the history database. historyKey :: GenFlatTest a -> Text -- | The TR (test runner) monad. type TR = RWST TestConfig () TestState IO -- | The state type for the TR monad. data TestState TestState :: [FlatTestResult] -> Int -> TestState -- | Results collected so far. [ts_results] :: TestState -> [FlatTestResult] -- | Current index for splitted output. [ts_index] :: TestState -> Int -- | The initial test state. initTestState :: TestState -- | Configuration of test execution. data TestConfig TestConfig :: Bool -> Maybe Int -> Bool -> TestOutput -> Maybe FilePath -> TestFilter -> [TestReporter] -> Bool -> FilePath -> TestHistory -> Bool -> Bool -> Bool -> Maybe Milliseconds -> Maybe Double -> Int -> TestConfig -- | If set, displays messages only for failed tests. [tc_quiet] :: TestConfig -> Bool -- | Use Just i for parallel execution with i threads, -- Nothing for sequential execution. [tc_threads] :: TestConfig -> Maybe Int -- | Shuffle tests before parallel execution [tc_shuffle] :: TestConfig -> Bool -- | Output destination of progress and result messages. [tc_output] :: TestConfig -> TestOutput -- | Output destination of XML result summary [tc_outputXml] :: TestConfig -> Maybe FilePath -- | Filter for the tests to run. [tc_filter] :: TestConfig -> TestFilter -- | Test reporters to use. [tc_reporters] :: TestConfig -> [TestReporter] -- | Whether to use colored output [tc_useColors] :: TestConfig -> Bool -- | Path to history file [tc_historyFile] :: TestConfig -> FilePath -- | History of previous test runs [tc_history] :: TestConfig -> TestHistory -- | Sort ascending by previous execution times [tc_sortByPrevTime] :: TestConfig -> Bool -- | Stop test run as soon as one test fails [tc_failFast] :: TestConfig -> Bool -- | Do not regard timeout as an error [tc_timeoutIsSuccess] :: TestConfig -> Bool -- | Maximum time in milliseconds a single test is allowed to run [tc_maxSingleTestTime] :: TestConfig -> Maybe Milliseconds -- | Maximum factor a single test is allowed to run slower than its -- previous execution [tc_prevFactor] :: TestConfig -> Maybe Double -- | Number of times to repeat tests selected on the command line before -- reporting them as a success. [tc_repeat] :: TestConfig -> Int -- | The destination of progress and result messages from HTF. data TestOutput -- | Output goes to Handle, boolean flag indicates whether the -- handle should be closed at the end. TestOutputHandle :: Handle -> Bool -> TestOutput -- | Output goes to files whose names are derived from FilePath by -- appending a number to it. Numbering starts at zero. TestOutputSplitted :: FilePath -> TestOutput -- | Reports the IDs of all tests available. type ReportAllTests = [FlatTest] -> TR () -- | Signals that test execution is about to start. type ReportGlobalStart = [FlatTest] -> TR () -- | Reports the start of a single test. type ReportTestStart = FlatTest -> TR () -- | Reports the result of a single test. type ReportTestResult = FlatTestResult -> TR () -- | Reports the overall results of all tests. type ReportGlobalResults = ReportGlobalResultsArg -> TR () data ReportGlobalResultsArg ReportGlobalResultsArg :: Milliseconds -> [FlatTestResult] -> [FlatTestResult] -> [FlatTestResult] -> [FlatTestResult] -> [FlatTestResult] -> [FlatTest] -> ReportGlobalResultsArg [rgra_timeMs] :: ReportGlobalResultsArg -> Milliseconds [rgra_passed] :: ReportGlobalResultsArg -> [FlatTestResult] [rgra_pending] :: ReportGlobalResultsArg -> [FlatTestResult] [rgra_failed] :: ReportGlobalResultsArg -> [FlatTestResult] [rgra_errors] :: ReportGlobalResultsArg -> [FlatTestResult] [rgra_timedOut] :: ReportGlobalResultsArg -> [FlatTestResult] [rgra_filtered] :: ReportGlobalResultsArg -> [FlatTest] -- | A TestReporter provides hooks to customize the output of HTF. data TestReporter TestReporter :: String -> ReportAllTests -> ReportGlobalStart -> ReportTestStart -> ReportTestResult -> ReportGlobalResults -> TestReporter [tr_id] :: TestReporter -> String -- | Called to report the IDs of all tests available. [tr_reportAllTests] :: TestReporter -> ReportAllTests -- | Called to report the start of test execution. [tr_reportGlobalStart] :: TestReporter -> ReportGlobalStart -- | Called to report the start of a single test. [tr_reportTestStart] :: TestReporter -> ReportTestStart -- | Called to report the result of a single test. [tr_reportTestResult] :: TestReporter -> ReportTestResult -- | Called to report the overall results of all tests. [tr_reportGlobalResults] :: TestReporter -> ReportGlobalResults emptyTestReporter :: String -> TestReporter attachCallStack :: ColorString -> HtfStack -> ColorString -- | A type for call-stacks type CallStack = [(Maybe String, Location)] -- | The summary result of a test. data TestResult Pass :: TestResult Pending :: TestResult Fail :: TestResult Error :: TestResult -- | The result of running a GenFlatTest type FlatTestResult = GenFlatTest RunResult -- | A type synonym for time in milliseconds. type Milliseconds = Int -- | The result of a test run. data RunResult RunResult :: TestResult -> HtfStack -> ColorString -> Milliseconds -> Bool -> RunResult -- | The summary result of the test. [rr_result] :: RunResult -> TestResult -- | The stack leading to the test failure [rr_stack] :: RunResult -> HtfStack -- | A message describing the result. [rr_message] :: RunResult -> ColorString -- | Execution time in milliseconds. [rr_wallTimeMs] :: RunResult -> Milliseconds -- | True if the execution took too long [rr_timeout] :: RunResult -> Bool instance GHC.Read.Read Test.Framework.TestTypes.TestSort instance GHC.Show.Show Test.Framework.TestTypes.TestSort instance GHC.Classes.Eq Test.Framework.TestTypes.TestSort instance GHC.Read.Read Test.Framework.TestTypes.TestOptions instance GHC.Show.Show Test.Framework.TestTypes.TestOptions instance GHC.Classes.Eq Test.Framework.TestTypes.TestOptions instance GHC.Read.Read a => GHC.Read.Read (Test.Framework.TestTypes.WithTestOptions a) instance GHC.Show.Show a => GHC.Show.Show (Test.Framework.TestTypes.WithTestOptions a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Test.Framework.TestTypes.WithTestOptions a) instance GHC.Show.Show Test.Framework.TestTypes.TestPath instance GHC.Classes.Eq Test.Framework.TestTypes.TestOutput instance GHC.Show.Show Test.Framework.TestTypes.TestOutput instance GHC.Show.Show Test.Framework.TestTypes.TestConfig instance GHC.Show.Show Test.Framework.TestTypes.TestReporter instance GHC.Classes.Eq Test.Framework.TestTypes.TestReporter instance Test.Framework.TestTypes.AssertionWithTestOptions (GHC.Types.IO a) instance Test.Framework.TestTypes.AssertionWithTestOptions (Test.Framework.TestTypes.WithTestOptions (GHC.Types.IO a)) -- | HTF's machine-readable output is a sequence of JSON messages. Each -- message is terminated by a newline followed by two semicolons followed -- again by a newline. -- -- There are four types of JSON messages. Each JSON object has a "type" -- attribute denoting this type. The types are: test-start, -- test-end, and test-list, test-results. -- Their haskell representations are TestStartEventObj, -- TestEndEventObj, TestListObj, and TestResultsObj. -- The corresponding JSON rendering is defined in this module. -- --
-- {"test": {"flatName": "Main:nonEmpty",
-- "location": {"file": "Tutorial.hs", "line": 17},
-- "path": ["Main","nonEmpty"],
-- "sort": "unit-test"},
-- "type":"test-start"}
--
--
--
-- {"result": "pass",
-- "message":"",
-- "test":{"flatName": "Main:nonEmpty",
-- "location": {"file": "Tutorial.hs", "line": 17},
-- "path": ["Main","nonEmpty"],
-- "sort": "unit-test"},
-- "wallTime": 0, // in milliseconds
-- "type": "test-end",
-- "location":null}
--
--
--
-- {"failures": 0,
-- "passed": 4,
-- "pending": 0,
-- "wallTime": 39, // in milliseconds
-- "errors": 0,
-- "type":"test-results"}
--
--
--
-- {"tests": [{"flatName":"Main:nonEmpty","location":{"file":"Tutorial.hs","line":17},"path":["Main","nonEmpty"],"sort":"unit-test"},
-- {"flatName":"Main:empty","location":{"file":"Tutorial.hs","line":19},"path":["Main","empty"],"sort":"unit-test"},
-- {"flatName":"Main:reverse","location":{"file":"Tutorial.hs","line":22},"path":["Main","reverse"],"sort":"quickcheck-property"},
-- {"flatName":"Main:reverseReplay","location":{"file":"Tutorial.hs","line":24},"path":["Main","reverseReplay"],"sort":"quickcheck-property"}],
-- "type":"test-list"}
--
--
-- For an exact specification, please have a look at the code of this
-- module.
module Test.Framework.JsonOutput
data TestStartEventObj
data TestEndEventObj
data TestListObj
data TestObj
data TestResultsObj
mkTestStartEventObj :: FlatTest -> String -> TestStartEventObj
mkTestEndEventObj :: FlatTestResult -> String -> TestEndEventObj
mkTestListObj :: [(FlatTest, String)] -> TestListObj
mkTestResultsObj :: ReportGlobalResultsArg -> TestResultsObj
decodeObj :: HTFJsonObj a => a -> ByteString
class ToJSON a => HTFJsonObj a
instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.JsonOutput.TestStartEventObj
instance Test.Framework.JsonOutput.HTFJsonObj Test.Framework.JsonOutput.TestStartEventObj
instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.JsonOutput.TestEndEventObj
instance Test.Framework.JsonOutput.HTFJsonObj Test.Framework.JsonOutput.TestEndEventObj
instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.JsonOutput.TestListObj
instance Test.Framework.JsonOutput.HTFJsonObj Test.Framework.JsonOutput.TestListObj
instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.JsonOutput.TestObj
instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.JsonOutput.TestResultsObj
instance Test.Framework.JsonOutput.HTFJsonObj Test.Framework.JsonOutput.TestResultsObj
instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.TestTypes.TestPath
instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.TestTypes.TestSort
instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.Location.Location
-- | Internal module providing a pool of threads.
module Test.Framework.ThreadPool
type ThreadPoolEntry m a b = (m a, a -> IO b, Either SomeException b -> m StopFlag)
data ThreadPool m a b
ThreadPool :: ([ThreadPoolEntry m a b] -> m ()) -> ThreadPool m a b
[tp_run] :: ThreadPool m a b -> [ThreadPoolEntry m a b] -> m ()
data StopFlag
DoStop :: StopFlag
DoNotStop :: StopFlag
sequentialThreadPool :: MonadIO m => ThreadPool m a b
parallelThreadPool :: MonadIO m => Int -> m (ThreadPool m a b)
threadPoolTest :: (Int, Int) -> Int -> IO [()]
instance GHC.Read.Read Test.Framework.ThreadPool.StopFlag
instance GHC.Show.Show Test.Framework.ThreadPool.StopFlag
instance GHC.Classes.Eq Test.Framework.ThreadPool.StopFlag
instance GHC.Show.Show (Test.Framework.ThreadPool.WorkResult m b)
instance GHC.Show.Show (Test.Framework.ThreadPool.WorkItem m b)
-- | This module provides a short tutorial on how to use the HTF. It
-- assumes that you are using GHC for compiling your Haskell code. (It is
-- possible to use the HTF with other Haskell environments, only the
-- steps taken to invoke the custom preprocessor of the HTF may differ in
-- this case.)
module Test.Framework.Tutorial
-- | This module integrates the QuickCheck library into HTF. It
-- re-exports all functionality of QuickCheck and defines some
-- additional functions.
module Test.Framework.QuickCheckWrapper
-- | The Args used if not explicitly changed.
defaultArgs :: Args
-- | Retrieve the Args currently used per default when evaluating
-- quick check properties.
getCurrentArgs :: IO Args
-- | Change the default Args used to evaluate quick check
-- properties.
setDefaultArgs :: Args -> IO ()
-- | Run a QuickCheck property with modified quick check arguments
-- Args.
withQCArgs :: Testable a => (Args -> Args) -> a -> WithQCArgs a
-- | Abstract type for representing quick check properties with custom
-- Args. Used only internally.
data WithQCArgs a
-- | Sets the replay parameter of the Args datatype by
-- parsing the given string.
setReplayFromString :: Args -> String -> Args
-- | Type class providing access to the custom Args of a quick check
-- property. Used only internally.
class QCAssertion a
-- | Use qcPending msg prop to mark the given quick check property
-- as pending without removing it from the test suite and without
-- deleting or commenting out the property code.
qcPending :: Testable t => String -> t -> t
assertionAsProperty :: IO () -> Property
-- | Turns a QuickCheck property into an Assertion. This
-- function is used internally in the code generated by htfpp,
-- do not use it directly.
qcAssertion :: QCAssertion t => t -> Assertion
instance GHC.Classes.Eq Test.Framework.QuickCheckWrapper.QCPendingException
instance GHC.Read.Read Test.Framework.QuickCheckWrapper.QCPendingException
instance GHC.Show.Show Test.Framework.QuickCheckWrapper.QCPendingException
instance Test.QuickCheck.Property.Testable a => Test.Framework.QuickCheckWrapper.QCAssertion a
instance Test.QuickCheck.Property.Testable a => Test.Framework.QuickCheckWrapper.QCAssertion (Test.Framework.QuickCheckWrapper.WithQCArgs a)
instance GHC.Exception.Type.Exception Test.Framework.QuickCheckWrapper.QCPendingException
-- | Internal module for pretty-printing showable Haskell values.
module Test.Framework.PrettyHaskell
prettyHaskell :: Show a => a -> String
prettyHaskell' :: Show a => a -> Maybe String
prettyHaskellTests :: [(String, IO ())]
instance GHC.Show.Show Test.Framework.PrettyHaskell.MySuperHero
instance GHC.Show.Show Test.Framework.PrettyHaskell.MySuperSuperHero
-- | This module provides assert-like functions for writing unit tests.
module Test.Framework.HUnitWrapper
-- | Fail if the Bool value is False.
assertBool :: HasCallStack => Bool -> IO ()
assertBoolVerbose :: HasCallStack => String -> Bool -> IO ()
-- | Fail if the two values of type a are not equal. Use if
-- a is an instance of Show but not of Pretty.
assertEqual :: (Eq a, Show a, HasCallStack) => a -> a -> IO ()
-- | Fail if the two values of type a are not equal, supplying an
-- additional message. Use if a is an instance of Show
-- but not of Pretty.
assertEqualVerbose :: (Eq a, Show a, HasCallStack) => String -> a -> a -> IO ()
-- | Fail if the two values of type a are not equal. Use if
-- a is an instance of Pretty.
assertEqualPretty :: (Eq a, Pretty a, HasCallStack) => a -> a -> IO ()
-- | Fail if the two values of type a are not equal, supplying an
-- additional message. Use if a is an instance of Pretty.
assertEqualPrettyVerbose :: (Eq a, Pretty a, HasCallStack) => String -> a -> a -> IO ()
-- | Fail if the two values of type a are not equal. Use if
-- a is neither an instance of Show nor of Pretty.
assertEqualNoShow :: (Eq a, HasCallStack) => a -> a -> IO ()
-- | Fail if the two values of type a are not equal, supplying an
-- additional message. Use if a is neither an instance of
-- Show nor of Pretty.
assertEqualNoShowVerbose :: (Eq a, HasCallStack) => String -> a -> a -> IO ()
-- | Fail if the two values of type a are equal. Use if a
-- is an instance of Show but not of Pretty.
assertNotEqual :: (Eq a, Show a, HasCallStack) => a -> a -> IO ()
-- | Fail if the two values of type a are equal, supplying an
-- additional message. Use if a is an instance of Show
-- but not of Pretty.
assertNotEqualVerbose :: (Eq a, Show a, HasCallStack) => String -> a -> a -> IO ()
-- | Fail if the two values of type a are equal. Use if a
-- is an instance of Pretty.
assertNotEqualPretty :: (Eq a, Pretty a, HasCallStack) => a -> a -> IO ()
-- | Fail if the two values of type a are equal, supplying an
-- additional message. Use if a is an instance of Pretty.
assertNotEqualPrettyVerbose :: (Eq a, Pretty a, HasCallStack) => String -> a -> a -> IO ()
-- | Fail if the two values of type a are equal. Use if a
-- is neither an instance of Show nor of Pretty.
assertNotEqualNoShow :: (Eq a, HasCallStack) => a -> a -> IO ()
-- | Fail if the two values of type a are equal, supplying an
-- additional message. Use if a is neither an instance of
-- Show nor of Pretty.
assertNotEqualNoShowVerbose :: (Eq a, HasCallStack) => String -> a -> a -> IO ()
-- | Fail if the two given lists are not equal when considered as sets.
assertListsEqualAsSets :: (Eq a, Show a, HasCallStack) => [a] -> [a] -> IO ()
-- | Fail if the two given lists are not equal when considered as sets,
-- supplying an additional error message.
assertListsEqualAsSetsVerbose :: (Eq a, Show a, HasCallStack) => String -> [a] -> [a] -> IO ()
-- | Fail if the given list is empty.
assertNotEmpty :: HasCallStack => [a] -> IO ()
-- | Fail if the given list is empty, supplying an additional error
-- message.
assertNotEmptyVerbose :: HasCallStack => String -> [a] -> IO ()
-- | Fail if the given list is not empty.
assertEmpty :: HasCallStack => [a] -> IO ()
-- | Fail if the given list is not empty, supplying an additional error
-- message.
assertEmptyVerbose :: HasCallStack => String -> [a] -> IO ()
-- | Fail if the element given is not contained in the list.
assertElem :: (Eq a, Show a, HasCallStack) => a -> [a] -> IO ()
-- | Fail if the element given is not contained in the list, supplying an
-- additional error message.
assertElemVerbose :: (Eq a, Show a, HasCallStack) => String -> a -> [a] -> IO ()
-- | Fail if evaluating the expression of type a does not throw an
-- exception satisfying the given predicate (e -> Bool).
assertThrows :: (HasCallStack, Exception e) => a -> (e -> Bool) -> IO ()
-- | Fail if evaluating the expression of type a does not throw an
-- exception satisfying the given predicate (e -> Bool),
-- supplying an additional error message.
assertThrowsVerbose :: (HasCallStack, Exception e) => String -> a -> (e -> Bool) -> IO ()
-- | Fail if evaluating the expression of type a does not throw
-- any exception.
assertThrowsSome :: HasCallStack => a -> IO ()
-- | Fail if evaluating the expression of type a does not throw
-- any exception, supplying an additional error message.
assertThrowsSomeVerbose :: HasCallStack => String -> a -> IO ()
-- | Fail if executing the IO action does not throw an exception
-- satisfying the given predicate (e -> Bool).
assertThrowsIO :: (HasCallStack, Exception e) => IO a -> (e -> Bool) -> IO ()
-- | Fail if executing the IO action does not throw an exception
-- satisfying the given predicate (e -> Bool), supplying an
-- additional error message.
assertThrowsIOVerbose :: (HasCallStack, Exception e) => String -> IO a -> (e -> Bool) -> IO ()
-- | Fail if executing the IO action does not throw any exception.
assertThrowsSomeIO :: HasCallStack => IO a -> IO ()
-- | Fail if executing the IO action does not throw any exception,
-- supplying an additional error message.
assertThrowsSomeIOVerbose :: HasCallStack => String -> IO a -> IO ()
-- | Fail if executing the m action does not throw an exception
-- satisfying the given predicate (e -> Bool).
assertThrowsM :: (MonadBaseControl IO m, MonadIO m, Exception e, HasCallStack) => m a -> (e -> Bool) -> m ()
-- | Fail if executing the m action does not throw an exception
-- satisfying the given predicate (e -> Bool), supplying an
-- additional error message.
assertThrowsMVerbose :: (MonadBaseControl IO m, MonadIO m, Exception e, HasCallStack) => String -> m a -> (e -> Bool) -> m ()
-- | Fail if executing the m action does not throw any exception.
assertThrowsSomeM :: (MonadBaseControl IO m, MonadIO m, HasCallStack) => m a -> m ()
-- | Fail if executing the m action does not throw any exception,
-- supplying an additional error message.
assertThrowsSomeMVerbose :: (MonadBaseControl IO m, MonadIO m, HasCallStack) => String -> m a -> m ()
-- | Fail if the given Either a b value is a Right. Use
-- this function if b is an instance of Show.
assertLeft :: (HasCallStack, Show b) => Either a b -> IO a
-- | Fail if the given Either a b value is a Right,
-- supplying an additional error message. Use this function if b
-- is an instance of Show.
assertLeftVerbose :: (Show b, HasCallStack) => String -> Either a b -> IO a
-- | Fail if the given Either a b value is a Right. Use
-- this function if b is not an instance of Show.
assertLeftNoShow :: HasCallStack => Either a b -> IO a
-- | Fail if the given Either a b value is a Right,
-- supplying an additional error message. Use this function if b
-- is not an instance of Show.
assertLeftNoShowVerbose :: HasCallStack => String -> Either a b -> IO a
-- | Fail if the given Either a b value is a Left. Use this
-- function if a is an instance of Show.
assertRight :: (HasCallStack, Show a) => Either a b -> IO b
-- | Fail if the given Either a b value is a Left,
-- supplying an additional error message. Use this function if a
-- is an instance of Show.
assertRightVerbose :: (Show a, HasCallStack) => String -> Either a b -> IO b
-- | Fail if the given Either a b value is a Left. Use this
-- function if a is not an instance of Show.
assertRightNoShow :: HasCallStack => Either a b -> IO b
-- | Fail if the given Either a b value is a Left,
-- supplying an additional error message. Use this function if a
-- is not an instance of Show.
assertRightNoShowVerbose :: HasCallStack => String -> Either a b -> IO b
-- | Fail if the given value is a Nothing.
assertJust :: HasCallStack => Maybe a -> IO a
-- | Fail if the given value is a Nothing, supplying an additional error
-- message.
assertJustVerbose :: HasCallStack => String -> Maybe a -> IO a
-- | Fail if the given Maybe a value is a Just. Use this
-- function if a is an instance of Show.
assertNothing :: (HasCallStack, Show a) => Maybe a -> IO ()
-- | Fail if the given Maybe a value is a Just, supplying
-- an additional error message. Use this function if a is an
-- instance of Show.
assertNothingVerbose :: (Show a, HasCallStack) => String -> Maybe a -> IO ()
-- | Fail if the given Maybe a value is a Just. Use this
-- function if a is not an instance of Show.
assertNothingNoShow :: HasCallStack => Maybe a -> IO ()
-- | Fail if the given Maybe a value is a Just, supplying
-- an additional error message. Use this function if a is not an
-- instance of Show.
assertNothingNoShowVerbose :: HasCallStack => String -> Maybe a -> IO ()
-- | Specialization of gassertFailure to IO.
assertFailure :: HasCallStack => String -> IO a
-- | Signals that the current unit test is pending.
unitTestPending :: String -> IO a
-- | Use unitTestPending' msg test to mark the given test as
-- pending without removing it from the test suite and without deleting
-- or commenting out the test code.
unitTestPending' :: String -> IO a -> IO a
-- | Use subAssert if you want location information for the call
-- site but the function being called does not carry a
-- HasCallStack constraint.
subAssert :: (HasCallStack, MonadBaseControl IO m) => m a -> m a
subAssertVerbose :: (HasCallStack, MonadBaseControl IO m) => String -> m a -> m a
gassertBool :: (HasCallStack, AssertM m) => Bool -> m ()
gassertBoolVerbose :: (HasCallStack, AssertM m) => String -> Bool -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are not equal. Use if a is an instance of Show but not
-- of Pretty.
gassertEqual :: (Eq a, Show a, AssertM m, HasCallStack) => a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are not equal, supplying an additional message. Use if a is
-- an instance of Show but not of Pretty.
gassertEqualVerbose :: (Eq a, Show a, AssertM m, HasCallStack) => String -> a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are not equal. Use if a is an instance of Pretty.
gassertEqualPretty :: (Eq a, Pretty a, AssertM m, HasCallStack) => a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are not equal, supplying an additional message. Use if a is
-- an instance of Pretty.
gassertEqualPrettyVerbose :: (Eq a, Pretty a, AssertM m, HasCallStack) => String -> a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are not equal. Use if a is neither an instance of Show
-- nor of Pretty.
gassertEqualNoShow :: (Eq a, AssertM m, HasCallStack) => a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are not equal, supplying an additional message. Use if a is
-- neither an instance of Show nor of Pretty.
gassertEqualNoShowVerbose :: (Eq a, AssertM m, HasCallStack) => String -> a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are equal. Use if a is an instance of Show but not of
-- Pretty.
gassertNotEqual :: (Eq a, Show a, AssertM m, HasCallStack) => a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are equal, supplying an additional message. Use if a is an
-- instance of Show but not of Pretty.
gassertNotEqualVerbose :: (Eq a, Show a, AssertM m, HasCallStack) => String -> a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are equal. Use if a is an instance of Pretty.
gassertNotEqualPretty :: (Eq a, Pretty a, AssertM m, HasCallStack) => a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are equal, supplying an additional message. Use if a is an
-- instance of Pretty.
gassertNotEqualPrettyVerbose :: (Eq a, Pretty a, AssertM m, HasCallStack) => String -> a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are equal. Use if a is neither an instance of Show nor
-- of Pretty.
gassertNotEqualNoShow :: (Eq a, AssertM m, HasCallStack) => a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are equal, supplying an additional message. Use if a is
-- neither an instance of Show nor of Pretty.
gassertNotEqualNoShowVerbose :: (Eq a, AssertM m, HasCallStack) => String -> a -> a -> m ()
-- | Fail in some AssertM monad if the two given lists are not equal
-- when considered as sets.
gassertListsEqualAsSets :: (Eq a, Show a, AssertM m, HasCallStack) => [a] -> [a] -> m ()
-- | Fail in some AssertM monad if the two given lists are not equal
-- when considered as sets, supplying an additional error message.
gassertListsEqualAsSetsVerbose :: (Eq a, Show a, AssertM m, HasCallStack) => String -> [a] -> [a] -> m ()
-- | Fail in some AssertM monad if the given list is empty.
gassertNotEmpty :: (HasCallStack, AssertM m) => [a] -> m ()
-- | Fail in some AssertM monad if the given list is empty,
-- supplying an additional error message.
gassertNotEmptyVerbose :: (AssertM m, HasCallStack) => String -> [a] -> m ()
-- | Fail in some AssertM monad if the given list is not empty.
gassertEmpty :: (HasCallStack, AssertM m) => [a] -> m ()
-- | Fail in some AssertM monad if the given list is not empty,
-- supplying an additional error message.
gassertEmptyVerbose :: (AssertM m, HasCallStack) => String -> [a] -> m ()
-- | Fail in some AssertM monad if the element given is not
-- contained in the list.
gassertElem :: (Eq a, Show a, AssertM m, HasCallStack) => a -> [a] -> m ()
-- | Fail in some AssertM monad if the element given is not
-- contained in the list, supplying an additional error message.
gassertElemVerbose :: (Eq a, Show a, AssertM m, HasCallStack) => String -> a -> [a] -> m ()
-- | Fail in some AssertM monad if the given Either a b
-- value is a Right. Use this function if b is an
-- instance of Show.
gassertLeft :: (Show b, AssertM m, HasCallStack) => Either a b -> m a
-- | Fail in some AssertM monad if the given Either a b
-- value is a Right, supplying an additional error message. Use
-- this function if b is an instance of Show.
gassertLeftVerbose :: (Show b, AssertM m, HasCallStack) => String -> Either a b -> m a
-- | Fail in some AssertM monad if the given Either a b
-- value is a Right. Use this function if b is not an
-- instance of Show.
gassertLeftNoShow :: (HasCallStack, AssertM m) => Either a b -> m a
-- | Fail in some AssertM monad if the given Either a b
-- value is a Right, supplying an additional error message. Use
-- this function if b is not an instance of Show.
gassertLeftNoShowVerbose :: (HasCallStack, AssertM m) => String -> Either a b -> m a
-- | Fail in some AssertM monad if the given Either a b
-- value is a Left. Use this function if a is an instance
-- of Show.
gassertRight :: (Show a, AssertM m, HasCallStack) => Either a b -> m b
-- | Fail in some AssertM monad if the given Either a b
-- value is a Left, supplying an additional error message. Use
-- this function if a is an instance of Show.
gassertRightVerbose :: (Show a, AssertM m, HasCallStack) => String -> Either a b -> m b
-- | Fail in some AssertM monad if the given Either a b
-- value is a Left. Use this function if a is not an
-- instance of Show.
gassertRightNoShow :: (HasCallStack, AssertM m) => Either a b -> m b
-- | Fail in some AssertM monad if the given Either a b
-- value is a Left, supplying an additional error message. Use
-- this function if a is not an instance of Show.
gassertRightNoShowVerbose :: (HasCallStack, AssertM m) => String -> Either a b -> m b
-- | Fail in some AssertM monad if the given value is a Nothing.
gassertJust :: (HasCallStack, AssertM m) => Maybe a -> m a
-- | Fail in some AssertM monad if the given value is a Nothing,
-- supplying an additional error message.
gassertJustVerbose :: (HasCallStack, AssertM m) => String -> Maybe a -> m a
-- | Fail in some AssertM monad if the given Maybe a value
-- is a Just. Use this function if a is an instance of
-- Show.
gassertNothing :: (Show a, AssertM m, HasCallStack) => Maybe a -> m ()
-- | Fail in some AssertM monad if the given Maybe a value
-- is a Just, supplying an additional error message. Use this
-- function if a is an instance of Show.
gassertNothingVerbose :: (Show a, AssertM m, HasCallStack) => String -> Maybe a -> m ()
-- | Fail in some AssertM monad if the given Maybe a value
-- is a Just. Use this function if a is not an instance
-- of Show.
gassertNothingNoShow :: (HasCallStack, AssertM m) => Maybe a -> m ()
-- | Fail in some AssertM monad if the given Maybe a value
-- is a Just, supplying an additional error message. Use this
-- function if a is not an instance of Show.
gassertNothingNoShowVerbose :: (HasCallStack, AssertM m) => String -> Maybe a -> m ()
-- | Fail with the given reason in some AssertM monad.
gassertFailure :: (HasCallStack, AssertM m) => String -> m a
gsubAssert :: (HasCallStack, AssertM m) => m a -> m a
gsubAssertVerbose :: (HasCallStack, AssertM m) => String -> m a -> m a
data () => HUnitFailure
hunitWrapperTests :: [(String, IO ())]
-- | XML-output following the JUnit output format.
--
-- The data types exposed by this module give a rough specification of
-- the output format.
--
-- Here is a sample ouput:
--
-- -- <?xml version="1.0" encoding="UTF-8" standalone="yes"?> -- <testsuites tests="6" failures="2" errors="0" time="0.705"> -- <testsuite id="0" tests="2" failures="0" errors="0" time="0.000" name=MyPkg.A package=MyPkg.A> -- <testcase classname=MyPkg.A name="test_funA2" time="0.000"/> -- <testcase classname=MyPkg.A name="test_funA1" time="0.000"/> -- </testsuite> -- <testsuite id="1" tests="2" failures="0" errors="0" time="0.000" name=MyPkg.B package=MyPkg.B> -- <testcase classname=MyPkg.B name="test_funB2" time="0.000"/> -- <testcase classname=MyPkg.B name="test_funB1" time="0.000"/> -- </testsuite> -- <testsuite id="2" tests="2" failures="2" errors="0" time="0.703" name="bbts" package="bbts"> -- <testcase classname="bbts" name="bbt_bbt-dirshould-passx.num" time="0.230"> -- <failure type="failure" message="test is supposed to succeed but failed with exit code 255">test is supposed to succeed but failed with exit code 255</failure> -- </testcase> -- <testcase classname="bbts" name="bbt_bbt-dirshould-failz.num" time="0.473"> -- <failure type="failure" message="Mismatch on stderr:">Mismatch on stderr: -- --- bbt-dirshould-failz.err 2015-09-05 18:37:30.000000000 +0200 -- +++ - 2022-03-06 09:49:55.480265000 +0100 -- @@ -1 +1 @@ -- -invalid input -- +sample[88331]: [fatal] unable to read input graph: The data couldn’t be read because it isn’t in the correct format. -- [end of diff output] -- </failure> -- </testcase> -- </testsuite> -- </testsuites> --module Test.Framework.XmlOutput -- | A "specification" of the output format in terms of haskell data types: -- The name of each data type corresponds to the name of an XML element -- (lowercase first letter). The name of a field with a primitive -- corresponds to an attribute with then same name as the field (without -- the prefix up to the first _). -- -- The root element is testsuites data JunitXmlOutput JunitXmlOutput :: Testsuites -> JunitXmlOutput data Testsuites Testsuites :: Int -> Int -> Int -> Seconds -> [Testsuite] -> Testsuites [tss_tests] :: Testsuites -> Int [tss_failures] :: Testsuites -> Int [tss_errors] :: Testsuites -> Int [tss_time] :: Testsuites -> Seconds [tss_suites] :: Testsuites -> [Testsuite] data Testsuite Testsuite :: Int -> Int -> Int -> Seconds -> Int -> String -> String -> [Testcase] -> Testsuite [ts_tests] :: Testsuite -> Int [ts_failures] :: Testsuite -> Int [ts_errors] :: Testsuite -> Int [ts_time] :: Testsuite -> Seconds [ts_id] :: Testsuite -> Int [ts_name] :: Testsuite -> String [ts_package] :: Testsuite -> String [ts_testcases] :: Testsuite -> [Testcase] data Testcase Testcase :: String -> String -> Seconds -> Maybe Result -> Testcase [tc_classname] :: Testcase -> String [tc_name] :: Testcase -> String [tc_time] :: Testcase -> Seconds [tc_result] :: Testcase -> Maybe Result data Result Result :: String -> Text -> String -> Text -> Result [r_elemName] :: Result -> String [r_message] :: Result -> Text [r_type] :: Result -> String [r_textContent] :: Result -> Text mkGlobalResultsXml :: ReportGlobalResultsArg -> ByteString -- | This module defines function for running a set of tests. Furthermore, -- it provides functionality for organzing tests into a hierarchical -- structure. -- -- This functionality is mainly used internally in the code generated by -- the hftpp pre-processor. module Test.Framework.TestManager -- | Runs something testable by parsing the commandline arguments as test -- options (using parseTestArgs). Exits with the exit code -- returned by runTestWithArgs. This function is the main entry -- point for running tests. htfMain :: TestableHTF t => t -> IO () -- | Runs something testable by parsing the commandline arguments as test -- options (using parseTestArgs). Exits with the exit code -- returned by runTestWithArgs. htfMainWithArgs :: TestableHTF t => [String] -> t -> IO () -- | Run something testable using the defaultCmdlineOptions. runTest :: TestableHTF t => t -> IO ExitCode -- | Run something testable using the defaultCmdlineOptions. runTest' :: TestableHTF t => t -> IO (IO (), ExitCode) -- | Run something testable, parse the CmdlineOptions from the given -- commandline arguments. Does not print the overall test results but -- returns an IO action for doing so. runTestWithArgs :: TestableHTF t => [String] -> t -> IO ExitCode -- | Run something testable, parse the CmdlineOptions from the given -- commandline arguments. runTestWithArgs' :: TestableHTF t => [String] -> t -> IO (IO (), ExitCode) -- | Runs something testable with the given CmdlineOptions. See -- runTestWithConfig for a specification of the ExitCode -- result. runTestWithOptions :: TestableHTF t => CmdlineOptions -> t -> IO ExitCode -- | Runs something testable with the given CmdlineOptions. Does not -- print the overall test results but returns an IO action for -- doing so. See runTestWithConfig for a specification of the -- ExitCode result. runTestWithOptions' :: TestableHTF t => CmdlineOptions -> t -> IO (IO (), ExitCode) -- | Runs something testable with the given TestConfig. The result -- is ExitSuccess if all tests were executed successfully, -- ExitFailure otherwise. In the latter case, an error code of -- 1 indicates that failures but no errors occurred, otherwise -- the error code 2 is used. -- -- A test is successful if the test terminates and no assertion -- fails. A test is said to fail if an assertion fails but no -- other error occur. runTestWithConfig :: TestableHTF t => TestConfig -> t -> IO (ExitCode, TestHistory) -- | Runs something testable with the given TestConfig. Does not -- print the overall test results but returns an IO action for -- doing so. See runTestWithConfig for a specification of the -- ExitCode result. runTestWithConfig' :: TestableHTF t => TestConfig -> t -> IO (IO (), ExitCode, TestHistory) -- | A type class for things that can be run as tests. Mainly used -- internally. class TestableHTF t -- | Kind of specialised Functor type class for tests, which allows -- you to modify the Assertions of the WrappableHTF-thing -- without changing any test code. -- -- E.g. if you want to add timeouts to all tests of a module, you could -- write: -- --
-- addTimeout test = timeout 100 test >>= assertJustVerbose "Timeout exceeded" -- testsWithTimeouts = wrap addTimeout htf_thisModulesTests --class WrappableHTF t wrap :: WrappableHTF t => (Assertion -> Assertion) -> t -> t -- | Construct a test where the given Assertion checks a quick check -- property. Mainly used internally by the htfpp preprocessor. makeQuickCheckTest :: TestID -> Location -> Assertion -> Test -- | Construct a unit test from the given IO action. Mainly used -- internally by the htfpp preprocessor. makeUnitTest :: AssertionWithTestOptions a => TestID -> Location -> a -> Test -- | Construct a black box test from the given Assertion. Mainly -- used internally. makeBlackBoxTest :: TestID -> Assertion -> Test -- | Create a named TestSuite from a list of Test values. makeTestSuite :: TestID -> [Test] -> TestSuite -- | Create an unnamed TestSuite from a list of Test values. makeAnonTestSuite :: [Test] -> TestSuite -- | Extend a TestSuite with a list of Test values addToTestSuite :: TestSuite -> [Test] -> TestSuite -- | Turn a TestSuite into a proper Test. testSuiteAsTest :: TestSuite -> Test flattenTest :: Test -> [FlatTest] wrappableTests :: [(String, IO ())] instance Test.Framework.TestManager.TestableHTF Test.Framework.TestTypes.Test instance Test.Framework.TestManager.TestableHTF Test.Framework.TestTypes.TestSuite instance Test.Framework.TestManager.TestableHTF t => Test.Framework.TestManager.TestableHTF [t] instance Test.Framework.TestManager.TestableHTF (GHC.Types.IO a) instance Test.Framework.TestManager.WrappableHTF Test.Framework.TestTypes.TestSuite instance Test.Framework.TestManager.WrappableHTF Test.Framework.TestTypes.Test -- | A black box test in the terminology of the HTF consists of a -- driver program that is run in various input files. For each input -- file, the HTF checks that the driver program exits with the correct -- exit code and that it produces the expected output. The samples -- directory of the HTF source tree shows an example for a black box -- test, see https://github.com/skogsbaer/HTF/tree/master/sample. -- -- NOTE: If you use black box tests, you have to compile your -- program with the -threaded option. Otherwise, your program -- just blocks indefinitely! module Test.Framework.BlackBoxTest -- | Use a value of this datatype to customize various aspects of your -- black box tests. data BBTArgs BBTArgs :: String -> String -> String -> String -> Bool -> Diff -> Diff -> BBTArgs -- | File extension for the file used as stdin. [bbtArgs_stdinSuffix] :: BBTArgs -> String -- | File extension for the file specifying expected output on stdout. [bbtArgs_stdoutSuffix] :: BBTArgs -> String -- | File extension for the file specifying expected output on stderr. [bbtArgs_stderrSuffix] :: BBTArgs -> String -- | Name of a file defining various arguments for executing the tests -- contained in a subdirectory of the test hierarchy. If a directory -- contains a such-named file, the arguments apply to all testfiles -- directly contained in this directory. See the documentation of -- blackBoxTests for a specification of the argument file format. -- Default: BBTArgs [bbtArgs_dynArgsName] :: BBTArgs -> String -- | Be verbose or not. [bbtArgs_verbose] :: BBTArgs -> Bool -- | Diff program for comparing output on stdout with the expected value. [bbtArgs_stdoutDiff] :: BBTArgs -> Diff -- | Diff program for comparing output on stderr with the expected value. [bbtArgs_stderrDiff] :: BBTArgs -> Diff -- | Sensible default values for BBTArgs: -- --
-- defaultBBTArgs = BBTArgs { bbtArgs_stdinSuffix = ".in"
-- , bbtArgs_stdoutSuffix = ".out"
-- , bbtArgs_stderrSuffix = ".err"
-- , bbtArgs_dynArgsName = "BBTArgs"
-- , bbtArgs_stdoutDiff = defaultDiff
-- , bbtArgs_stderrDiff = defaultDiff
-- , bbtArgs_verbose = False }
--
defaultBBTArgs :: BBTArgs
-- | Collects all black box tests with the given file extension stored in a
-- specific directory. For example, the invocation
--
-- -- blackBoxTests "bbt-dir" "dist/build/sample/sample" ".num" defaultBBTArgs ---- -- returns a list of Test values, one Test for each -- .num file found in bbt-dir and its subdirectories. -- (The samples directory of the HTF source tree contains the example -- shown here, see -- https://github.com/skogsbaer/HTF/tree/master/sample.) -- -- Suppose that one of the .num files is -- bbt-dir/should-pass/x.num. Running the corresponding -- Test invokes dist/build/sample/sample (the program -- under test) with bbt-dir/should-pass/x.num as the last -- commandline argument. The other commandline arguments are taken from -- the flags specification given in the file whose name is stored in the -- bbtArgs_dynArgsName field of the BBTArgs record (see -- below, default is BBTArgs). -- -- If bbt-dir/should-pass/x.in existed, its content would be -- used as stdin. The tests succeeds if the exit code of the program is -- zero and the output on stdout and stderr matches the contents of -- bbt-dir/should-pass/x.out and -- bbt-dir/should-pass/x.err, respectively. If -- bbt-dir/should-pass/x.out and -- bbt-dir/should-pass/x.err do not exist, then output is not -- checked. -- -- The bbtArgs_dynArgsName field of the BBTArgs record -- specifies a filename that contains some more configuration flags for -- the tests. The following flags (separated by newlines) are supported: -- --
-- addTimeout test = timeout 100 test >>= assertJustVerbose "Timeout exceeded" -- testsWithTimeouts = wrap addTimeout htf_thisModulesTests --class WrappableHTF t wrap :: WrappableHTF t => (Assertion -> Assertion) -> t -> t