-- 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.*: -- -- -- -- Starting with version 0.9.0.0, HTF uses a new strategy for collecting -- the testcases defined in your project (see -- Test.Framework.Tutorial for a description of this strategy). If -- you used version 0.8.* or earlier of HTF, this will break your -- build! However, it's rather easy to bring you project in line with -- the new HTF version. Here are the steps that will most likely resolve -- your backwards incompatibility problems: -- -- @package HTF @version 0.12.2.2 -- | 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.) -- -- We start with a simple example. Then we show how to use HTF to easily -- collect test definitions from multiple modules and discuss -- backwards-compatibility for projects already using HUnit. -- Finally, we give a brief cookbook-like summary on how to setup your -- tests with HTF. module Test.Framework.Tutorial 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 [()] threadPoolTestStop :: IO () instance Eq StopFlag instance Show StopFlag instance Read StopFlag instance Show (WorkResult m b) instance Show (WorkItem m b) module Test.Framework.PrettyHaskell prettyHaskell :: Show a => a -> String prettyHaskell' :: Show a => a -> Maybe String prettyHaskellTests :: [([Char], IO ())] instance Show MySuperHero instance Show MySuperSuperHero -- | 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 where prettyList l = char '[' <> vcat (punctuate comma (map pretty l)) <> char ']' showPretty = render . pretty pretty :: Pretty a => a -> Doc prettyList :: Pretty a => [a] -> Doc showPretty :: Pretty a => a -> String -- | Utility function for inserting a = between two Doc -- values. (<=>) :: Doc -> Doc -> Doc instance Pretty Bool instance Pretty Int instance Pretty a => Pretty [a] instance Pretty Char module Test.Framework.Colors data Color Color :: PrimColor -> Bool -> Color data PrimColor Black :: PrimColor Blue :: PrimColor Green :: PrimColor Cyan :: PrimColor Red :: PrimColor Magenta :: PrimColor Brown :: PrimColor Gray :: PrimColor DarkGray :: PrimColor LightBlue :: PrimColor LightGreen :: PrimColor LightCyan :: PrimColor LightRed :: PrimColor LightMagenta :: PrimColor Yellow :: PrimColor White :: PrimColor NoColor :: PrimColor newtype ColorString ColorString :: [PrimColorString] -> ColorString unColorString :: ColorString -> [PrimColorString] data PrimColorString PrimColorString :: Color -> Text -> (Maybe Text) -> PrimColorString firstDiffColor :: Color secondDiffColor :: Color skipDiffColor :: Color diffColor :: Color warningColor :: Color testStartColor :: Color testOkColor :: Color pendingColor :: Color emptyColorString :: ColorString (+++) :: ColorString -> ColorString -> ColorString unlinesColorString :: [ColorString] -> ColorString colorStringFind :: (Char -> Bool) -> ColorString -> Bool -> Maybe Char ensureNewlineColorString :: ColorString -> ColorString colorize :: Color -> String -> ColorString colorizeText :: Color -> Text -> ColorString colorize' :: Color -> String -> String -> ColorString colorizeText' :: Color -> Text -> Text -> ColorString noColor :: String -> ColorString noColorText :: Text -> ColorString noColor' :: String -> String -> ColorString noColorText' :: Text -> Text -> ColorString renderColorString :: ColorString -> Bool -> Text maxLength :: ColorString -> Int instance Eq PrimColor instance Show PrimColor instance Read PrimColor instance Eq Color instance Show Color instance Read Color instance Eq PrimColorString instance Show PrimColorString instance Read PrimColorString instance Eq ColorString instance Show ColorString instance Read ColorString instance IsString ColorString -- | This module defines 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 Eq Location instance Ord Location instance Show Location instance Read Location -- | This module defines the API for HTF plugins. 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 :: Maybe Location -> [(Maybe String, Location)] -> Maybe ColorString -> Maybe TestResult -> FullTestResult -- | The location of a possible failure ftr_location :: FullTestResult -> Maybe Location -- | The stack to the location of a possible failure ftr_callingLocations :: FullTestResult -> [(Maybe String, Location)] -- | 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 -- | 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. subAssertHTF :: MonadBaseControl IO m => Location -> Maybe String -> m a -> m a -- | Auxiliary function for contructing a FullTestResult. mkFullTestResult :: TestResult -> Maybe String -> FullTestResult instance Typeable HTFFailureException instance Show TestResult instance Read TestResult instance Eq TestResult instance Eq FullTestResult instance Show FullTestResult instance Read FullTestResult instance Show HTFFailureException instance Exception HTFFailureException 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 FromJSON HistoricTestResult instance ToJSON HistoricTestResult instance FromJSON TestRunHistory instance ToJSON TestRunHistory instance FromJSON SerializableTestHistory instance ToJSON SerializableTestHistory instance Show HistoricTestResult instance Eq HistoricTestResult instance Eq TestRunHistory instance Eq TestHistory instance FromJSON TestResult instance ToJSON TestResult instance Show TestRunHistory instance Show TestHistory -- | This module defines types (and small auxiliary functions) for -- organizing tests, for configuring the execution of tests, and for -- representing and reporting their results. 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 FlatTest. 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 -> 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 -- | 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 -> CallStack -> 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 FlatTest type FlatTestResult = GenFlatTest RunResult -- | A type synonym for time in milliseconds. type Milliseconds = Int -- | The result of a test run. data RunResult RunResult :: TestResult -> Maybe Location -> CallStack -> ColorString -> Milliseconds -> Bool -> RunResult -- | The summary result of the test. rr_result :: RunResult -> TestResult -- | The location where the test failed (if applicable). rr_location :: RunResult -> Maybe Location -- | Information about the callers of the location where the test failed rr_callers :: RunResult -> CallStack -- | 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 Eq TestSort instance Show TestSort instance Read TestSort instance Eq TestOptions instance Show TestOptions instance Read TestOptions instance Eq a => Eq (WithTestOptions a) instance Show a => Show (WithTestOptions a) instance Read a => Read (WithTestOptions a) instance Show TestPath instance Show TestOutput instance Eq TestOutput instance Eq TestReporter instance Show TestReporter instance Show TestConfig instance AssertionWithTestOptions (WithTestOptions (IO a)) instance AssertionWithTestOptions (IO a) -- | See -- http://pzolee.blogs.balabit.com/2012/11/jenkins-vs-junit-xml-format/ -- for a description of the format used. -- -- The source code of this module also contains a rough specification of -- the output format in terms of Haskell data types. module Test.Framework.XmlOutput mkGlobalResultsXml :: ReportGlobalResultsArg -> ByteString -- | 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 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: -- -- blackBoxTests :: FilePath -> String -> String -> BBTArgs -> IO [Test] -- | The type of a function comparing the content of a file against a -- string, similar to the unix tool diff. The first parameter is -- the name of the file containing the expected output. If this parameter -- is Nothing, then output should not be checked. The second -- parameter is the actual output produced. If the result is -- Nothing then no difference was found. Otherwise, a Just -- value contains a string explaining the difference. type Diff = Maybe FilePath -> String -> IO (Maybe String) -- | A default value for the Diff datatype that simple resorts to -- the diff commandline utility. defaultDiff :: Diff -- | 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 => Location -> ColorString -> m a genericSubAssert :: AssertM m => Location -> Maybe String -> m a -> m a -- | Stack trace element for generic assertions. data AssertStackElem AssertStackElem :: Maybe String -> Maybe Location -> AssertStackElem ase_message :: AssertStackElem -> Maybe String ase_location :: AssertStackElem -> Maybe Location -- | 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 :: [AssertStackElem] -> 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 -- | Formats a stack trace. formatStack :: [AssertStackElem] -> String instance Eq AssertStackElem instance Ord AssertStackElem instance Show AssertStackElem instance Read AssertStackElem instance Eq a => Eq (AssertBool a) instance Ord a => Ord (AssertBool a) instance Show a => Show (AssertBool a) instance Read a => Read (AssertBool a) instance AssertM AssertBool instance Monad AssertBool instance Applicative AssertBool instance Functor AssertBool instance AssertM IO -- | 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 -- | 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 [overlap ok] Typeable QCPendingException instance [overlap ok] Show QCPendingException instance [overlap ok] Read QCPendingException instance [overlap ok] Eq QCPendingException instance [overlap ok] Testable a => QCAssertion (WithQCArgs a) instance [overlap ok] Testable a => QCAssertion a instance [overlap ok] Exception QCPendingException -- | This module provides assert-like functions for writing unit tests. -- -- Hint: Do not use the assertXXX_ functions directly. -- Instead, for each function assertXXX_, there exist a -- preprocessor macro assertXXX, which provides the -- Location parameter automatically. Use these macros, which are -- available automatically if you add -- --
--   {-# 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