-- 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: -- -- 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: -- --
-- TestOptions {
-- opts_quiet = False
-- , opts_filter = const True
-- , opts_help = False
-- , opts_negated = []
-- }
--
defaultTestOptions :: TestOptions
-- | Parse commandline arguments into TestOptions. Here's a synopsis
-- of the format of the commandline arguments:
--
-- -- [OPTION ...] TEST_PATTERN ... -- -- where TEST_PATTERN is a posix regular expression matching -- the names of the tests to run. -- -- -v --verbose chatty output -- -q --quiet only display errors -- -n TEST_PATTERN --not=TEST_PATTERN tests to exclude -- -h --help display this message --parseTestArgs :: [String] -> Either String TestOptions -- | Type for naming tests. type TestID = String -- | An assertion is just an IO action. type Assertion = IO () -- | Abstract type for tests. data Test -- | Abstract type for test suites. data TestSuite -- | A filter is a predicate on FlatTest. If the predicate is -- True, the flat test is run. type Filter = FlatTest -> Bool -- | Type for flattened tests. data FlatTest FlatTest :: TestSort -> TestID -> (Maybe Location) -> Assertion -> FlatTest -- | Type for distinguishing different sorts of tests. data TestSort UnitTest :: TestSort QuickCheckTest :: TestSort BlackBoxTest :: TestSort -- | 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. See QuickCheckWrapper. Mainly used internally. makeQuickCheckTest :: TestID -> Location -> Assertion -> Test -- | Construct a unit test from the given IO action. See -- HUnitWrapper. Mainly used internally. makeUnitTest :: TestID -> Location -> IO a -> Test -- | Construct a black box test from the given Assertion. See -- BlackBoxTest. 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 Eq TestSort instance Show TestSort instance Read TestSort 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. bbtArgs_dynArgsName :: BBTArgs -> String -- | Ge 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 input file. If -- bbt-dir/should-pass/x.num 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. -- -- The directory bbt-dir/should-fail contains the file -- BBTArgs. If this file exists, then its content specifies -- various arguments for the test run. The file defines the arguments -- separated by newlines. Supported arguments: -- --
-- {-# OPTIONS_GHC -F -pgmF htfpp #-}
--
--
-- at the top of your source file (see the Tutorial).
module Test.Framework.HUnitWrapper
assertBool_ :: Location -> Bool -> Assertion
-- | Fail if the Bool value is False. The String
-- parameter in the Verbose variant can be used to provide extra
-- information about the error. Do not use assertBool_ and
-- assertBoolVerbose_ directly, use the macros
-- assertBool and assertBoolVerbose instead. These
-- macros, provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
assertBoolVerbose_ :: Location -> String -> Bool -> Assertion
assertEqual_ :: (Eq a, Show a) => Location -> a -> a -> Assertion
-- | 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 variant can be used to
-- provide extra information about the error. Do not use
-- assertEqual_ and assertEqualVerbose_ directly, use
-- the macros assertEqual and assertEqualVerbose
-- instead. These macros, provided by the htfpp preprocessor,
-- insert the Location parameter automatically.
assertEqualVerbose_ :: (Eq a, Show a) => Location -> String -> a -> a -> Assertion
assertEqualPretty_ :: (Eq a, Pretty a) => Location -> a -> a -> Assertion
-- | 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 variant can be used to provide extra
-- information about the error. Do not use assertEqualPretty_
-- and assertEqualPrettyVerbose_ directly, use the macros
-- assertEqualPretty and assertEqualPrettyVerbose
-- instead. These macros, provided by the htfpp preprocessor,
-- insert the Location parameter automatically.
assertEqualPrettyVerbose_ :: (Eq a, Pretty a) => Location -> String -> a -> a -> Assertion
assertEqualNoShow_ :: Eq a => Location -> a -> a -> Assertion
-- | 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 variant
-- can be used to provide extra information about the error. Do not use
-- assertEqualNoShow_ and assertEqualNoShowVerbose_
-- directly, use the macros assertEqualNoShow and
-- assertEqualNoShowVerbose instead. These macros, provided by
-- the htfpp preprocessor, insert the Location parameter
-- automatically.
assertEqualNoShowVerbose_ :: Eq a => Location -> String -> a -> a -> Assertion
assertNotEqual_ :: (Eq a, Show a) => Location -> a -> a -> Assertion
-- | 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 variant can be used to
-- provide extra information about the error. Do not use
-- assertNotEqual_ and assertNotEqualVerbose_ directly,
-- use the macros assertNotEqual and
-- assertNotEqualVerbose instead. These macros, provided by the
-- htfpp preprocessor, insert the Location parameter
-- automatically.
assertNotEqualVerbose_ :: (Eq a, Show a) => Location -> String -> a -> a -> Assertion
assertNotEqualPretty_ :: (Eq a, Pretty a) => Location -> a -> a -> Assertion
-- | 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 variant can be used to provide extra
-- information about the error. Do not use assertNotEqualPretty_
-- and assertNotEqualPrettyVerbose_ directly, use the macros
-- assertNotEqualPretty and assertNotEqualPrettyVerbose
-- instead. These macros, provided by the htfpp preprocessor,
-- insert the Location parameter automatically.
assertNotEqualPrettyVerbose_ :: (Eq a, Pretty a) => Location -> String -> a -> a -> Assertion
assertNotEqualNoShow_ :: Eq a => Location -> a -> a -> Assertion
-- | 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 variant
-- can be used to provide extra information about the error. Do not use
-- assertNotEqualNoShow_ and
-- assertNotEqualNoShowVerbose_ directly, use the macros
-- assertNotEqualNoShow and assertNotEqualNoShowVerbose
-- instead. These macros, provided by the htfpp preprocessor,
-- insert the Location parameter automatically.
assertNotEqualNoShowVerbose_ :: Eq a => Location -> String -> a -> a -> Assertion
assertListsEqualAsSets_ :: (Eq a, Show a) => Location -> [a] -> [a] -> Assertion
-- | 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 variant can be used to provide extra
-- information about the error. Do not use
-- assertListsEqualAsSets_ and
-- assertListsEqualAsSetsVerbose_ directly, use the macros
-- assertListsEqualAsSets and
-- assertListsEqualAsSetsVerbose instead. These macros, provided
-- by the htfpp preprocessor, insert the Location
-- parameter automatically.
assertListsEqualAsSetsVerbose_ :: (Eq a, Show a) => Location -> String -> [a] -> [a] -> Assertion
assertNotEmpty_ :: Location -> [a] -> Assertion
-- | Fail if the given list is empty. The String parameter in the
-- Verbose variant can be used to provide extra information
-- about the error. Do not use assertNotEmpty_ and
-- assertNotEmptyVerbose_ directly, use the macros
-- assertNotEmpty and assertNotEmptyVerbose instead.
-- These macros, provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
assertNotEmptyVerbose_ :: Location -> String -> [a] -> Assertion
assertEmpty_ :: Location -> [a] -> Assertion
-- | Fail if the given list is a non-empty list. The String
-- parameter in the Verbose variant can be used to provide extra
-- information about the error. Do not use assertEmpty_ and
-- assertEmptyVerbose_ directly, use the macros
-- assertEmpty and assertEmptyVerbose instead. These
-- macros, provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
assertEmptyVerbose_ :: Location -> String -> [a] -> Assertion
assertThrows_ :: Exception e => Location -> a -> (e -> Bool) -> Assertion
-- | 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
-- assertThrows_ and assertThrowsVerbose_ 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) -> Assertion
assertThrowsSome_ :: Location -> a -> Assertion
-- | 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
-- assertThrowsSome_ and assertThrowsSomeVerbose_
-- directly, use the macros assertThrowsSome and
-- assertThrowsSomeVerbose instead. These macros, provided by
-- the htfpp preprocessor, insert the Location parameter
-- automatically.
assertThrowsSomeVerbose_ :: Location -> String -> a -> Assertion
assertThrowsIO_ :: Exception e => Location -> IO a -> (e -> Bool) -> Assertion
-- | 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
-- assertThrowsIO_ and assertThrowsIOVerbose_ 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) -> Assertion
assertThrowsSomeIO_ :: Location -> IO a -> Assertion
-- | 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
-- assertThrowsSomeIO_ and assertThrowsSomeIOVerbose_
-- 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 -> Assertion
assertLeft_ :: Show b => Location -> Either a b -> IO 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 variant can be used to
-- provide extra information about the error. Do not use
-- assertLeft_ and assertLeftVerbose_ directly, use the
-- macros assertLeft and assertLeftVerbose instead.
-- These macros, provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
assertLeftVerbose_ :: Show b => Location -> String -> Either a b -> IO a
assertLeftNoShow_ :: Location -> Either a b -> IO a
-- | Fail if the given Either a b value is a Right. The
-- String parameter in the Verbose variant can be used to
-- provide extra information about the error. Do not use
-- assertLeftNoShow_ and assertLeftNoShowVerbose_
-- directly, use the macros assertLeftNoShow and
-- assertLeftNoShowVerbose instead. These macros, provided by
-- the htfpp preprocessor, insert the Location parameter
-- automatically.
assertLeftNoShowVerbose_ :: Location -> String -> Either a b -> IO a
assertRight_ :: Show a => Location -> Either a b -> IO 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 variant can be used to provide extra
-- information about the error. Do not use assertRight_ and
-- assertRightVerbose_ directly, use the macros
-- assertRight and assertRightVerbose instead. These
-- macros, provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
assertRightVerbose_ :: Show a => Location -> String -> Either a b -> IO b
assertRightNoShow_ :: Location -> Either a b -> IO b
-- | Fail if the given Either a b value is a Left. The
-- String parameter in the Verbose variant can be used to
-- provide extra information about the error. Do not use
-- assertRightNoShow_ and assertRightNoShowVerbose_
-- directly, use the macros assertRightNoShow and
-- assertRightNoShowVerbose instead. These macros, provided by
-- the htfpp preprocessor, insert the Location parameter
-- automatically.
assertRightNoShowVerbose_ :: Location -> String -> Either a b -> IO b
assertJust_ :: Location -> Maybe a -> IO a
-- | Fail is the given Maybe a value is a Nothing. The
-- String parameter in the Verbose variant can be used to
-- provide extra information about the error. Do not use
-- assertJust_ and assertJustVerbose_ directly, use the
-- macros assertJust and assertJustVerbose instead.
-- These macros, provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
assertJustVerbose_ :: Location -> String -> Maybe a -> IO a
assertNothing_ :: Show a => Location -> Maybe a -> Assertion
-- | 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 variant can be used to
-- provide extra information about the error. Do not use
-- assertNothing_ and assertNothingVerbose_ directly,
-- use the macros assertNothing and
-- assertNothingVerbose instead. These macros, provided by the
-- htfpp preprocessor, insert the Location parameter
-- automatically.
assertNothingVerbose_ :: Show a => Location -> String -> Maybe a -> Assertion
assertNothingNoShow_ :: Location -> Maybe a -> Assertion
-- | Fail is the given Maybe a value is a Just. The
-- String parameter in the Verbose variant can be used to
-- provide extra information about the error. Do not use
-- assertNothingNoShow_ and assertNothingNoShowVerbose_
-- directly, use the macros assertNothingNoShow and
-- assertNothingNoShowVerbose instead. These macros, provided by
-- the htfpp preprocessor, insert the Location parameter
-- automatically.
assertNothingNoShowVerbose_ :: Location -> String -> Maybe a -> Assertion
-- | Fail with the given reason.
assertFailure :: String -> IO a
-- | Mark a unit test as pending without removing it from the test suite.
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
module Test.Framework
-- | Create a new location.
makeLoc :: String -> Int -> Location
module Test.Framework.Tutorial