-- 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 unit -- tests (http://hunit.sourceforge.net), QuickCheck properties -- (http://www.cs.chalmers.se/~rjmh/QuickCheck/), and black box -- tests in an easy and convenient way. HTF uses a custom preprocessor -- that collects test definitions automatically. Furthermore, the -- preprocessor allows HTF to report failing test cases with exact file -- name and line number information. Additionally, HTF tries to produce -- highly readable output for failing tests: for example, it colors and -- pretty prints expected and actual results and provides a diff between -- the two values. -- -- The documentation of the Test.Framework.Tutorial module -- provides a tutorial for HTF. There is also a slightly out-dated blog -- article -- (http://factisresearch.blogspot.de/2011/10/new-version-of-htf-with-diffs-colors.html) -- demonstrating HTF's coloring, pretty-printing and diff functionality. -- -- HEADS UP, backwards incomatibility with prior versions: -- -- In version 0.10.0.0, the following changes could break code compiled -- against version 0.9.*: -- --
-- {"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 ToJSON Location
instance ToJSON TestSort
instance ToJSON TestPath
instance ToJSON TestObj
instance HTFJsonObj TestResultsObj
instance ToJSON TestResultsObj
instance HTFJsonObj TestListObj
instance ToJSON TestListObj
instance HTFJsonObj TestEndEventObj
instance ToJSON TestEndEventObj
instance HTFJsonObj TestStartEventObj
instance ToJSON TestStartEventObj
-- | This module defines functions for notifying all test reporters
-- registered about particular events in the lifecycle of a test run.
--
-- Further, it defines the standard test reporters for HTF's various
-- output formats.
module Test.Framework.TestReporter
data IsParallel
Parallel :: IsParallel
NonParallel :: IsParallel
isParallelFromBool :: Bool -> IsParallel
data IsJsonOutput
JsonOutput :: IsJsonOutput
NoJsonOutput :: IsJsonOutput
data IsXmlOutput
XmlOutput :: IsXmlOutput
NoXmlOutput :: IsXmlOutput
-- | Invokes tr_reportAllTests on all test reporters registered.
reportAllTests :: ReportAllTests
-- | Invokes tr_reportGlobalStart on all test reporters registered.
reportGlobalStart :: ReportGlobalStart
-- | Invokes tr_reportTestStart on all test reporters registered.
reportTestStart :: ReportTestStart
-- | Invokes tr_reportTestResult on all test reporters registered.
reportTestResult :: ReportTestResult
-- | Invokes tr_reportGlobalResults on all test reporters
-- registered.
reportGlobalResults :: ReportGlobalResults
-- | The default test reporters for HTF.
defaultTestReporters :: IsParallel -> IsJsonOutput -> IsXmlOutput -> [TestReporter]
instance Eq ReportLevel
instance Ord ReportLevel
-- | This module defines the commandline options of the test driver
-- provided by HTF.
module Test.Framework.CmdlineOptions
-- | Commandline options for running tests.
data CmdlineOptions
CmdlineOptions :: Bool -> TestFilter -> Bool -> [String] -> Maybe Int -> Bool -> Bool -> Maybe FilePath -> Maybe Bool -> Maybe FilePath -> Bool -> Bool -> Maybe FilePath -> Bool -> Bool -> Maybe Milliseconds -> Maybe Milliseconds -> Maybe Double -> Bool -> CmdlineOptions
-- | Be quiet or not.
opts_quiet :: CmdlineOptions -> Bool
-- | Run only tests matching this filter.
opts_filter :: CmdlineOptions -> TestFilter
-- | If True, display a help message and exit.
opts_help :: CmdlineOptions -> Bool
-- | Regular expressions matching test names which should not run.
opts_negated :: CmdlineOptions -> [String]
-- | Use Just i for parallel execution with i threads,
-- Nothing for sequential execution.
opts_threads :: CmdlineOptions -> Maybe Int
-- | If True, shuffle tests when running them in parallel. Default:
-- False
opts_shuffle :: CmdlineOptions -> Bool
-- | Format output for machines (JSON format) or humans. See
-- JsonOutput for a definition of the JSON format.
opts_machineOutput :: CmdlineOptions -> Bool
-- | Output file for junit-style XML output. See XmlOutput for a
-- definition of the XML format.
opts_machineOutputXml :: CmdlineOptions -> Maybe FilePath
-- | Use Just b to enable/disable use of colors, Nothing
-- infers the use of colors.
opts_useColors :: CmdlineOptions -> Maybe Bool
-- | The output file, defaults to stdout
opts_outputFile :: CmdlineOptions -> Maybe FilePath
-- | If True, lists all tests available and exits.
opts_listTests :: CmdlineOptions -> Bool
-- | If True, each message is sent to a new ouput file (derived by
-- appending an index to opts_outputFile).
opts_split :: CmdlineOptions -> Bool
-- | History file, default: ..HTFProgramName.history
opts_historyFile :: CmdlineOptions -> Maybe FilePath
-- | Fail and terminate test run as soon as the first test fails. Default:
-- False
opts_failFast :: CmdlineOptions -> Bool
-- | Sort tests by their previous run times (ascending). Default:
-- False
opts_sortByPrevTime :: CmdlineOptions -> Bool
-- | Ignore tests with a runtime greater than given in a previous test run.
opts_maxPrevTimeMs :: CmdlineOptions -> Maybe Milliseconds
-- | Abort tests that run more than the given milliseconds.
opts_maxCurTimeMs :: CmdlineOptions -> Maybe Milliseconds
-- | Warn if a test runs more than N times slower than in a previosu run.
opts_prevFactor :: CmdlineOptions -> Maybe Double
-- | Do not regard test timeout as an error.
opts_timeoutIsSuccess :: CmdlineOptions -> Bool
-- | The default CmdlineOptions.
defaultCmdlineOptions :: CmdlineOptions
-- | Parse commandline arguments into CmdlineOptions. Here is a
-- synopsis of the format of the commandline arguments:
--
-- -- USAGE: COMMAND [OPTION ...] PATTERN ... -- -- where PATTERN is a posix regular expression matching -- the names of the tests to run. -- -- -q --quiet Only display errors. -- -n PATTERN --not=PATTERN Tests to exclude. -- -l --list List all matching tests. -- -j[N] --threads[=N] Run N tests in parallel, default N=1. -- --deterministic Do not shuffle tests when executing them in parallel. -- -o FILE --output-file=FILE Name of output file. -- --json Output results in machine-readable JSON format (incremental). -- --xml=FILE Output results in junit-style XML format. -- --split Splits results in separate files to avoid file locking (requires -o/--output-file). -- --colors=BOOL Use colors or not. -- --history=FILE Path to the history file. Default: ./.HTF/<ProgramName>.history -- --fail-fast Fail and abort test run as soon as the first test fails. -- --sort-by-prev-time Sort tests ascending by their execution of the previous test run (if available). Default: false -- --max-prev-ms=MILLISECONDS Do not try to execute tests that had a execution time greater than MILLISECONDS in a previous test run. -- --max-cur-ms=MILLISECONDS Abort a test that runs more than MILLISECONDS. -- --prev-factor=DOUBLE Abort a test that runs more than DOUBLE times slower than in a previous run. -- --timeout-is-success Do not regard a test timeout as an error. -- -h --help Display this message. --parseTestArgs :: [String] -> Either String CmdlineOptions -- | The string displayed for the --help option. helpString :: String -- | Turn the CmdlineOptions into a TestConfig. testConfigFromCmdlineOptions :: CmdlineOptions -> IO TestConfig module Test.Framework.Preprocessor transform :: Bool -> Bool -> FilePath -> String -> IO String progName :: String preprocessorTests :: [(String, IO ())] instance Eq Definition instance Show Definition instance Show ImportDecl instance Eq ImportDecl instance Show ModuleInfo instance Eq ModuleInfo instance Eq Loc instance Show Loc -- | 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 -- | 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 instance TestableHTF (IO a) instance TestableHTF t => TestableHTF [t] instance TestableHTF TestSuite instance TestableHTF 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: -- --
-- {-# OPTIONS_GHC -F -pgmF htfpp #-}
--
--
-- at the top of your source file (see the Tutorial).
module Test.Framework.HUnitWrapper
assertBool_ :: Location -> Bool -> IO ()
assertBoolVerbose_ :: Location -> String -> Bool -> IO ()
gassertBool_ :: AssertM m => Location -> Bool -> m ()
-- | Fail if the Bool value is False. The String
-- parameter in the Verbose variants can be used to provide
-- extra information about the error. The variants gassertBool
-- and gassertBoolVerbose are generic assertions: they run in
-- the IO monad and can be evaluated to a Bool value. Do not use
-- the assertBool_, assertBoolVerbose_,
-- gassertBool_, and gassertBoolVerbose_ functions
-- directly, use the macros assertBool,
-- assertBoolVerbose, gassertBool, and
-- gassertBoolVerbose instead. These macros, provided by the
-- htfpp preprocessor, insert the Location parameter
-- automatically.
gassertBoolVerbose_ :: AssertM m => Location -> String -> Bool -> m ()
assertEqual_ :: (Eq a, Show a) => Location -> a -> a -> IO ()
assertEqualVerbose_ :: (Eq a, Show a) => Location -> String -> a -> a -> IO ()
gassertEqual_ :: (Eq a, Show a, AssertM m) => Location -> a -> a -> m ()
-- | Fail if the two values of type a are not equal. The first
-- parameter denotes the expected value. Use these two functions of
-- a is an instance of Show but not of Pretty. The
-- String parameter in the Verbose variants can be used
-- to provide extra information about the error. The variants
-- gassertEqual and gassertEqualVerbose are generic
-- assertions: they run in the IO monad and can be evaluated to a
-- Bool value. Do not use the assertEqual_,
-- assertEqualVerbose_, gassertEqual_, and
-- gassertEqualVerbose_ functions directly, use the macros
-- assertEqual, assertEqualVerbose,
-- gassertEqual, and gassertEqualVerbose instead. These
-- macros, provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
gassertEqualVerbose_ :: (Eq a, Show a, AssertM m) => Location -> String -> a -> a -> m ()
assertEqualPretty_ :: (Eq a, Pretty a) => Location -> a -> a -> IO ()
assertEqualPrettyVerbose_ :: (Eq a, Pretty a) => Location -> String -> a -> a -> IO ()
gassertEqualPretty_ :: (Eq a, Pretty a, AssertM m) => Location -> a -> a -> m ()
-- | Fail if the two values of type a are not equal. The first
-- parameter denotes the expected value. Use these two functions of
-- a is an instance of Pretty. The String
-- parameter in the Verbose variants can be used to provide
-- extra information about the error. The variants
-- gassertEqualPretty and gassertEqualPrettyVerbose are
-- generic assertions: they run in the IO monad and can be evaluated to a
-- Bool value. Do not use the assertEqualPretty_,
-- assertEqualPrettyVerbose_, gassertEqualPretty_, and
-- gassertEqualPrettyVerbose_ functions directly, use the macros
-- assertEqualPretty, assertEqualPrettyVerbose,
-- gassertEqualPretty, and gassertEqualPrettyVerbose
-- instead. These macros, provided by the htfpp preprocessor,
-- insert the Location parameter automatically.
gassertEqualPrettyVerbose_ :: (Eq a, Pretty a, AssertM m) => Location -> String -> a -> a -> m ()
assertEqualNoShow_ :: Eq a => Location -> a -> a -> IO ()
assertEqualNoShowVerbose_ :: Eq a => Location -> String -> a -> a -> IO ()
gassertEqualNoShow_ :: (Eq a, AssertM m) => Location -> a -> a -> m ()
-- | Fail if the two values of type a are not equal. The first
-- parameter denotes the expected value. Use these two functions of
-- a is neither an instance of Show nor Pretty. Be
-- aware that in this case the generated error message might not be very
-- helpful. The String parameter in the Verbose variants
-- can be used to provide extra information about the error. The variants
-- gassertEqualNoShow and gassertEqualNoShowVerbose are
-- generic assertions: they run in the IO monad and can be evaluated to a
-- Bool value. Do not use the assertEqualNoShow_,
-- assertEqualNoShowVerbose_, gassertEqualNoShow_, and
-- gassertEqualNoShowVerbose_ functions directly, use the macros
-- assertEqualNoShow, assertEqualNoShowVerbose,
-- gassertEqualNoShow, and gassertEqualNoShowVerbose
-- instead. These macros, provided by the htfpp preprocessor,
-- insert the Location parameter automatically.
gassertEqualNoShowVerbose_ :: (Eq a, AssertM m) => Location -> String -> a -> a -> m ()
assertNotEqual_ :: (Eq a, Show a) => Location -> a -> a -> IO ()
assertNotEqualVerbose_ :: (Eq a, Show a) => Location -> String -> a -> a -> IO ()
gassertNotEqual_ :: (Eq a, Show a, AssertM m) => Location -> a -> a -> m ()
-- | Fail if the two values of type a are equal. The first
-- parameter denotes the expected value. Use these two functions of
-- a is an instance of Show but not of Pretty. The
-- String parameter in the Verbose variants can be used
-- to provide extra information about the error. The variants
-- gassertNotEqual and gassertNotEqualVerbose are
-- generic assertions: they run in the IO monad and can be evaluated to a
-- Bool value. Do not use the assertNotEqual_,
-- assertNotEqualVerbose_, gassertNotEqual_, and
-- gassertNotEqualVerbose_ functions directly, use the macros
-- assertNotEqual, assertNotEqualVerbose,
-- gassertNotEqual, and gassertNotEqualVerbose instead.
-- These macros, provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
gassertNotEqualVerbose_ :: (Eq a, Show a, AssertM m) => Location -> String -> a -> a -> m ()
assertNotEqualPretty_ :: (Eq a, Pretty a) => Location -> a -> a -> IO ()
assertNotEqualPrettyVerbose_ :: (Eq a, Pretty a) => Location -> String -> a -> a -> IO ()
gassertNotEqualPretty_ :: (Eq a, Pretty a, AssertM m) => Location -> a -> a -> m ()
-- | Fail if the two values of type a are equal. The first
-- parameter denotes the expected value. Use these two functions of
-- a is an instance of Pretty. The String
-- parameter in the Verbose variants can be used to provide
-- extra information about the error. The variants
-- gassertNotEqualPretty and
-- gassertNotEqualPrettyVerbose are generic assertions: they run
-- in the IO monad and can be evaluated to a Bool value. Do not
-- use the assertNotEqualPretty_,
-- assertNotEqualPrettyVerbose_,
-- gassertNotEqualPretty_, and
-- gassertNotEqualPrettyVerbose_ functions directly, use the
-- macros assertNotEqualPretty,
-- assertNotEqualPrettyVerbose, gassertNotEqualPretty,
-- and gassertNotEqualPrettyVerbose instead. These macros,
-- provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
gassertNotEqualPrettyVerbose_ :: (Eq a, Pretty a, AssertM m) => Location -> String -> a -> a -> m ()
assertNotEqualNoShow_ :: Eq a => Location -> a -> a -> IO ()
assertNotEqualNoShowVerbose_ :: Eq a => Location -> String -> a -> a -> IO ()
gassertNotEqualNoShow_ :: (Eq a, AssertM m) => Location -> a -> a -> m ()
-- | Fail if the two values of type a are equal. The first
-- parameter denotes the expected value. Use these two functions of
-- a is neither an instance of Show nor Pretty. Be
-- aware that in this case the generated error message might not be very
-- helpful. The String parameter in the Verbose variants
-- can be used to provide extra information about the error. The variants
-- gassertNotEqualNoShow and
-- gassertNotEqualNoShowVerbose are generic assertions: they run
-- in the IO monad and can be evaluated to a Bool value. Do not
-- use the assertNotEqualNoShow_,
-- assertNotEqualNoShowVerbose_,
-- gassertNotEqualNoShow_, and
-- gassertNotEqualNoShowVerbose_ functions directly, use the
-- macros assertNotEqualNoShow,
-- assertNotEqualNoShowVerbose, gassertNotEqualNoShow,
-- and gassertNotEqualNoShowVerbose instead. These macros,
-- provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
gassertNotEqualNoShowVerbose_ :: (Eq a, AssertM m) => Location -> String -> a -> a -> m ()
assertListsEqualAsSets_ :: (Eq a, Show a) => Location -> [a] -> [a] -> IO ()
assertListsEqualAsSetsVerbose_ :: (Eq a, Show a) => Location -> String -> [a] -> [a] -> IO ()
gassertListsEqualAsSets_ :: (Eq a, Show a, AssertM m) => Location -> [a] -> [a] -> m ()
-- | Fail if the two given lists are not equal when considered as sets. The
-- first list parameter denotes the expected value. The String
-- parameter in the Verbose variants can be used to provide
-- extra information about the error. The variants
-- gassertListsEqualAsSets and
-- gassertListsEqualAsSetsVerbose are generic assertions: they
-- run in the IO monad and can be evaluated to a Bool value. Do
-- not use the assertListsEqualAsSets_,
-- assertListsEqualAsSetsVerbose_,
-- gassertListsEqualAsSets_, and
-- gassertListsEqualAsSetsVerbose_ functions directly, use the
-- macros assertListsEqualAsSets,
-- assertListsEqualAsSetsVerbose,
-- gassertListsEqualAsSets, and
-- gassertListsEqualAsSetsVerbose instead. These macros,
-- provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
gassertListsEqualAsSetsVerbose_ :: (Eq a, Show a, AssertM m) => Location -> String -> [a] -> [a] -> m ()
assertNotEmpty_ :: Location -> [a] -> IO ()
assertNotEmptyVerbose_ :: Location -> String -> [a] -> IO ()
gassertNotEmpty_ :: AssertM m => Location -> [a] -> m ()
-- | Fail if the given list is empty. The String parameter in the
-- Verbose variants can be used to provide extra information
-- about the error. The variants gassertNotEmpty and
-- gassertNotEmptyVerbose are generic assertions: they run in
-- the IO monad and can be evaluated to a Bool value. Do not use
-- the assertNotEmpty_, assertNotEmptyVerbose_,
-- gassertNotEmpty_, and gassertNotEmptyVerbose_
-- functions directly, use the macros assertNotEmpty,
-- assertNotEmptyVerbose, gassertNotEmpty, and
-- gassertNotEmptyVerbose instead. These macros, provided by the
-- htfpp preprocessor, insert the Location parameter
-- automatically.
gassertNotEmptyVerbose_ :: AssertM m => Location -> String -> [a] -> m ()
assertEmpty_ :: Location -> [a] -> IO ()
assertEmptyVerbose_ :: Location -> String -> [a] -> IO ()
gassertEmpty_ :: AssertM m => Location -> [a] -> m ()
-- | Fail if the given list is a non-empty list. The String
-- parameter in the Verbose variants can be used to provide
-- extra information about the error. The variants gassertEmpty
-- and gassertEmptyVerbose are generic assertions: they run in
-- the IO monad and can be evaluated to a Bool value. Do not use
-- the assertEmpty_, assertEmptyVerbose_,
-- gassertEmpty_, and gassertEmptyVerbose_ functions
-- directly, use the macros assertEmpty,
-- assertEmptyVerbose, gassertEmpty, and
-- gassertEmptyVerbose instead. These macros, provided by the
-- htfpp preprocessor, insert the Location parameter
-- automatically.
gassertEmptyVerbose_ :: AssertM m => Location -> String -> [a] -> m ()
assertElem_ :: (Eq a, Show a) => Location -> a -> [a] -> IO ()
assertElemVerbose_ :: (Eq a, Show a) => Location -> String -> a -> [a] -> IO ()
gassertElem_ :: (Eq a, Show a, AssertM m) => Location -> a -> [a] -> m ()
-- | Fail if the given element is not in the list. The String
-- parameter in the Verbose variants can be used to provide
-- extra information about the error. The variants gassertElem
-- and gassertElemVerbose are generic assertions: they run in
-- the IO monad and can be evaluated to a Bool value. Do not use
-- the assertElem_, assertElemVerbose_,
-- gassertElem_, and gassertElemVerbose_ functions
-- directly, use the macros assertElem,
-- assertElemVerbose, gassertElem, and
-- gassertElemVerbose instead. These macros, provided by the
-- htfpp preprocessor, insert the Location parameter
-- automatically.
gassertElemVerbose_ :: (Eq a, Show a, AssertM m) => Location -> String -> a -> [a] -> m ()
assertThrows_ :: Exception e => Location -> a -> (e -> Bool) -> IO ()
-- | Fail if evaluating the expression of type a does not throw an
-- exception satisfying the given predicate (e -> Bool). The
-- String parameter in the Verbose variant can be used to
-- provide extra information about the error. Do not use the
-- assertThrows_ and assertThrowsVerbose_ functions
-- directly, use the macros assertThrows and
-- assertThrowsVerbose instead. These macros, provided by the
-- htfpp preprocessor, insert the Location parameter
-- automatically.
assertThrowsVerbose_ :: Exception e => Location -> String -> a -> (e -> Bool) -> IO ()
assertThrowsSome_ :: Location -> a -> IO ()
-- | Fail if evaluating the expression of type a does not throw an
-- exception. The String parameter in the Verbose variant
-- can be used to provide extra information about the error. Do not use
-- the assertThrowsSome_ and assertThrowsSomeVerbose_
-- functions directly, use the macros assertThrowsSome and
-- assertThrowsSomeVerbose instead. These macros, provided by
-- the htfpp preprocessor, insert the Location parameter
-- automatically.
assertThrowsSomeVerbose_ :: Location -> String -> a -> IO ()
assertThrowsIO_ :: Exception e => Location -> IO a -> (e -> Bool) -> IO ()
-- | Fail if executing the IO action does not throw an exception
-- satisfying the given predicate (e -> Bool). The
-- String parameter in the Verbose variant can be used to
-- provide extra information about the error. Do not use the
-- assertThrowsIO_ and assertThrowsIOVerbose_ functions
-- directly, use the macros assertThrowsIO and
-- assertThrowsIOVerbose instead. These macros, provided by the
-- htfpp preprocessor, insert the Location parameter
-- automatically.
assertThrowsIOVerbose_ :: Exception e => Location -> String -> IO a -> (e -> Bool) -> IO ()
assertThrowsSomeIO_ :: Location -> IO a -> IO ()
-- | Fail if executing the IO action does not throw an exception.
-- The String parameter in the Verbose variant can be
-- used to provide extra information about the error. Do not use the
-- assertThrowsSomeIO_ and assertThrowsSomeIOVerbose_
-- functions directly, use the macros assertThrowsSomeIO and
-- assertThrowsSomeIOVerbose instead. These macros, provided by
-- the htfpp preprocessor, insert the Location parameter
-- automatically.
assertThrowsSomeIOVerbose_ :: Location -> String -> IO a -> IO ()
assertThrowsM_ :: (MonadBaseControl IO m, MonadIO m, Exception e) => Location -> m a -> (e -> Bool) -> m ()
-- | Fail if executing the m action does not throw an exception
-- satisfying the given predicate (e -> Bool). The
-- String parameter in the Verbose variant can be used to
-- provide extra information about the error. Do not use the
-- assertThrowsM_ and assertThrowsMVerbose_ functions
-- directly, use the macros assertThrowsM and
-- assertThrowsMVerbose instead. These macros, provided by the
-- htfpp preprocessor, insert the Location parameter
-- automatically.
assertThrowsMVerbose_ :: (MonadBaseControl IO m, MonadIO m, Exception e) => Location -> String -> m a -> (e -> Bool) -> m ()
assertThrowsSomeM_ :: (MonadBaseControl IO m, MonadIO m) => Location -> m a -> m ()
-- | Fail if executing the m action does not throw an exception.
-- The String parameter in the Verbose variant can be
-- used to provide extra information about the error. Do not use the
-- assertThrowsSomeM_ and assertThrowsSomeMVerbose_
-- functions directly, use the macros assertThrowsSomeM and
-- assertThrowsSomeMVerbose instead. These macros, provided by
-- the htfpp preprocessor, insert the Location parameter
-- automatically.
assertThrowsSomeMVerbose_ :: (MonadBaseControl IO m, MonadIO m) => Location -> String -> m a -> m ()
assertLeft_ :: Show b => Location -> Either a b -> IO a
assertLeftVerbose_ :: Show b => Location -> String -> Either a b -> IO a
gassertLeft_ :: (Show b, AssertM m) => Location -> Either a b -> m a
-- | Fail if the given Either a b value is a Right. Use
-- this function if b is an instance of Show The
-- String parameter in the Verbose variants can be used
-- to provide extra information about the error. The variants
-- gassertLeft and gassertLeftVerbose are generic
-- assertions: they run in the IO monad and can be evaluated to a
-- Bool value. Do not use the assertLeft_,
-- assertLeftVerbose_, gassertLeft_, and
-- gassertLeftVerbose_ functions directly, use the macros
-- assertLeft, assertLeftVerbose, gassertLeft,
-- and gassertLeftVerbose instead. These macros, provided by the
-- htfpp preprocessor, insert the Location parameter
-- automatically.
gassertLeftVerbose_ :: (Show b, AssertM m) => Location -> String -> Either a b -> m a
assertLeftNoShow_ :: Location -> Either a b -> IO a
assertLeftNoShowVerbose_ :: Location -> String -> Either a b -> IO a
gassertLeftNoShow_ :: AssertM m => Location -> Either a b -> m a
-- | Fail if the given Either a b value is a Right. The
-- String parameter in the Verbose variants can be used
-- to provide extra information about the error. The variants
-- gassertLeftNoShow and gassertLeftNoShowVerbose are
-- generic assertions: they run in the IO monad and can be evaluated to a
-- Bool value. Do not use the assertLeftNoShow_,
-- assertLeftNoShowVerbose_, gassertLeftNoShow_, and
-- gassertLeftNoShowVerbose_ functions directly, use the macros
-- assertLeftNoShow, assertLeftNoShowVerbose,
-- gassertLeftNoShow, and gassertLeftNoShowVerbose
-- instead. These macros, provided by the htfpp preprocessor,
-- insert the Location parameter automatically.
gassertLeftNoShowVerbose_ :: AssertM m => Location -> String -> Either a b -> m a
assertRight_ :: Show a => Location -> Either a b -> IO b
assertRightVerbose_ :: Show a => Location -> String -> Either a b -> IO b
gassertRight_ :: (Show a, AssertM m) => Location -> Either a b -> m b
-- | Fail if the given Either a b value is a Left. Use this
-- function if a is an instance of Show The String
-- parameter in the Verbose variants can be used to provide
-- extra information about the error. The variants gassertRight
-- and gassertRightVerbose are generic assertions: they run in
-- the IO monad and can be evaluated to a Bool value. Do not use
-- the assertRight_, assertRightVerbose_,
-- gassertRight_, and gassertRightVerbose_ functions
-- directly, use the macros assertRight,
-- assertRightVerbose, gassertRight, and
-- gassertRightVerbose instead. These macros, provided by the
-- htfpp preprocessor, insert the Location parameter
-- automatically.
gassertRightVerbose_ :: (Show a, AssertM m) => Location -> String -> Either a b -> m b
assertRightNoShow_ :: Location -> Either a b -> IO b
assertRightNoShowVerbose_ :: Location -> String -> Either a b -> IO b
gassertRightNoShow_ :: AssertM m => Location -> Either a b -> m b
-- | Fail if the given Either a b value is a Left. The
-- String parameter in the Verbose variants can be used
-- to provide extra information about the error. The variants
-- gassertRightNoShow and gassertRightNoShowVerbose are
-- generic assertions: they run in the IO monad and can be evaluated to a
-- Bool value. Do not use the assertRightNoShow_,
-- assertRightNoShowVerbose_, gassertRightNoShow_, and
-- gassertRightNoShowVerbose_ functions directly, use the macros
-- assertRightNoShow, assertRightNoShowVerbose,
-- gassertRightNoShow, and gassertRightNoShowVerbose
-- instead. These macros, provided by the htfpp preprocessor,
-- insert the Location parameter automatically.
gassertRightNoShowVerbose_ :: AssertM m => Location -> String -> Either a b -> m b
assertJust_ :: Location -> Maybe a -> IO a
assertJustVerbose_ :: Location -> String -> Maybe a -> IO a
gassertJust_ :: AssertM m => Location -> Maybe a -> m a
-- | Fail is the given Maybe a value is a Nothing. The
-- String parameter in the Verbose variants can be used
-- to provide extra information about the error. The variants
-- gassertJust and gassertJustVerbose are generic
-- assertions: they run in the IO monad and can be evaluated to a
-- Bool value. Do not use the assertJust_,
-- assertJustVerbose_, gassertJust_, and
-- gassertJustVerbose_ functions directly, use the macros
-- assertJust, assertJustVerbose, gassertJust,
-- and gassertJustVerbose instead. These macros, provided by the
-- htfpp preprocessor, insert the Location parameter
-- automatically.
gassertJustVerbose_ :: AssertM m => Location -> String -> Maybe a -> m a
assertNothing_ :: Show a => Location -> Maybe a -> IO ()
assertNothingVerbose_ :: Show a => Location -> String -> Maybe a -> IO ()
gassertNothing_ :: (Show a, AssertM m) => Location -> Maybe a -> m ()
-- | Fail is the given Maybe a value is a Just. Use this
-- function if a is an instance of Show. The
-- String parameter in the Verbose variants can be used
-- to provide extra information about the error. The variants
-- gassertNothing and gassertNothingVerbose are generic
-- assertions: they run in the IO monad and can be evaluated to a
-- Bool value. Do not use the assertNothing_,
-- assertNothingVerbose_, gassertNothing_, and
-- gassertNothingVerbose_ functions directly, use the macros
-- assertNothing, assertNothingVerbose,
-- gassertNothing, and gassertNothingVerbose instead.
-- These macros, provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
gassertNothingVerbose_ :: (Show a, AssertM m) => Location -> String -> Maybe a -> m ()
assertNothingNoShow_ :: Location -> Maybe a -> IO ()
assertNothingNoShowVerbose_ :: Location -> String -> Maybe a -> IO ()
gassertNothingNoShow_ :: AssertM m => Location -> Maybe a -> m ()
-- | Fail is the given Maybe a value is a Just. The
-- String parameter in the Verbose variants can be used
-- to provide extra information about the error. The variants
-- gassertNothingNoShow and gassertNothingNoShowVerbose
-- are generic assertions: they run in the IO monad and can be evaluated
-- to a Bool value. Do not use the assertNothingNoShow_,
-- assertNothingNoShowVerbose_, gassertNothingNoShow_,
-- and gassertNothingNoShowVerbose_ functions directly, use the
-- macros assertNothingNoShow,
-- assertNothingNoShowVerbose, gassertNothingNoShow,
-- and gassertNothingNoShowVerbose instead. These macros,
-- provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
gassertNothingNoShowVerbose_ :: AssertM m => Location -> String -> Maybe a -> m ()
-- | Specialization of gassertFailure.
assertFailure_ :: Location -> String -> IO a
-- | Fail with the given reason, supplying the error location and the error
-- message.
gassertFailure_ :: AssertM m => Location -> String -> m 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
-- | Sub assertions are a poor man's way of abstracting over assertions
-- while still propagating location information. Say you want to abstract
-- over the assertion that an Int is positive. You would write
--
-- -- assertIsPositive :: Int -> Assertion -- assertIsPositive n = assertBool (n > 0) ---- -- You can now use assertIsPositive i for some integer -- i from your unit tests, but if you call it directly you will -- lose location information: if assertIsPositive i fails you -- will only get the location where assertIsPositive is defined -- but not from where it has been called. -- -- To recover the location information you simply use subAssert -- (assertIsPositive i). In this case, if i is not -- positive, you will get the location of the caller. -- -- Note: Don't use subAssert_ directly but use the preprocessor -- macro subAssert. subAssert_ :: MonadBaseControl IO m => Location -> m a -> m a -- | Same as subAssert_ but with an additional error message. subAssertVerbose_ :: MonadBaseControl IO m => Location -> String -> m a -> m a -- | Generic variant of subAssert_. gsubAssert_ :: AssertM m => Location -> m a -> m a -- | Generic variant of subAssertVerbose_. gsubAssertVerbose_ :: AssertM m => Location -> String -> m a -> m a data HUnitFailure :: * -- | Top-level module that re-exports functionality from sub-modules. -- Modules that only define unit tests and quickcheck properties -- typically only need to import this module. Your test driver should -- additionally import TestManager and, if needed, -- BlackBoxTest. module Test.Framework -- | 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 test where the given Assertion checks a quick check -- property. Mainly used internally by the htfpp preprocessor. makeQuickCheckTest :: TestID -> Location -> Assertion -> Test -- | Create a named TestSuite from a list of Test values. makeTestSuite :: TestID -> [Test] -> TestSuite -- | Abstract type for test suites and their results. data TestSuite -- | 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 () -- | Create a new location. makeLoc :: String -> Int -> Location