-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | The Haskell Test Framework -- -- The Haskell Test Framework (HTF for short) lets you define and -- organize unit tests, QuickCheck properties, and black box tests in an -- easy and convenient way. HTF uses a custom preprocessor that collects -- test definitions automatically. -- -- HTF produces highly readable output for failing test cases: it -- provides exact file name and line number information, it colors and -- pretty prints expected and actual results, and it displays a diff -- highlighting the mismatching parts. -- -- The documentation of the Test.Framework.Tutorial module -- provides a tutorial for HTF. The sample provides a good -- starting point for a project using HTF. @package HTF @version 0.15.0.0 -- | Internal module for types and functions dealing with source code -- locations. module Test.Framework.Location -- | An abstract type representing locations in a file. data Location -- | The unknown location (file ? and line 0). unknownLocation :: Location -- | Extract the file name of a Location. fileName :: Location -> String -- | Extract the line number of a Location. lineNumber :: Location -> Int -- | Render a Location as a String. showLoc :: Location -> String -- | Create a new location. makeLoc :: String -> Int -> Location instance GHC.Read.Read Test.Framework.Location.Location instance GHC.Show.Show Test.Framework.Location.Location instance GHC.Classes.Ord Test.Framework.Location.Location instance GHC.Classes.Eq Test.Framework.Location.Location -- | Internal module providing access to some functionality of cpphs. module Test.Framework.Preprocessor transform :: TransformOptions -> FilePath -> String -> IO String progName :: String preprocessorTests :: [([Char], IO ())] data TransformOptions TransformOptions :: Bool -> Bool -> TransformOptions [debug] :: TransformOptions -> Bool [literateTex] :: TransformOptions -> Bool instance GHC.Show.Show Test.Framework.Preprocessor.Definition instance GHC.Classes.Eq Test.Framework.Preprocessor.Definition instance GHC.Classes.Eq Test.Framework.Preprocessor.ImportDecl instance GHC.Show.Show Test.Framework.Preprocessor.ImportDecl instance GHC.Classes.Eq Test.Framework.Preprocessor.ModuleInfo instance GHC.Show.Show Test.Framework.Preprocessor.ModuleInfo -- | This module defines the Pretty type class. The assert functions -- from HUnitWrapper use the pretty-printing functionality -- provided by this type class so as to provide nicely formatted error -- messages. -- -- Additionally, this module re-exports the standard Haskell -- pretty-printing module PrettyPrint module Test.Framework.Pretty -- | A type class for pretty-printable things. Minimal complete definition: -- pretty. class Pretty a -- | Pretty-print a single value. pretty :: Pretty a => a -> Doc -- | Pretty-print a list of things. prettyList :: Pretty a => [a] -> Doc -- | Pretty-print a single value as a String. showPretty :: Pretty a => a -> String -- | Utility function for inserting a = between two Doc -- values. (<=>) :: Doc -> Doc -> Doc -- | Rendering mode. data Mode -- | Normal rendering (lineLength and ribbonsPerLine -- respected'). PageMode :: Mode -- | With zig-zag cuts. ZigZagMode :: Mode -- | No indentation, infinitely long lines (lineLength ignored), but -- explicit new lines, i.e., text "one" $$ text "two", are -- respected. LeftMode :: Mode -- | All on one line, lineLength ignored and explicit new lines -- ($$) are turned into spaces. OneLineMode :: Mode -- | A rendering style. Allows us to specify constraints to choose among -- the many different rendering options. data Style Style :: Mode -> Int -> Float -> Style -- | The rendering mode. [mode] :: Style -> Mode -- | Maximum length of a line, in characters. [lineLength] :: Style -> Int -- | Ratio of line length to ribbon length. A ribbon refers to the -- characters on a line excluding indentation. So a -- lineLength of 100, with a ribbonsPerLine of 2.0 -- would only allow up to 50 characters of ribbon to be displayed on a -- line, while allowing it to be indented up to 50 characters. [ribbonsPerLine] :: Style -> Float -- | The default style (mode=PageMode, lineLength=100, -- ribbonsPerLine=1.5). style :: Style -- | The general rendering interface. Please refer to the Style -- and Mode types for a description of rendering mode, line -- length and ribbons. fullRender :: Mode -> Int -> Float -> (TextDetails -> a -> a) -> a -> Doc -> a -- | Render the Doc to a String using the given Style. renderStyle :: Style -> Doc -> String -- | Render the Doc to a String using the default Style -- (see style). render :: Doc -> String -- | "Paragraph fill" version of sep. fsep :: [Doc] -> Doc -- | "Paragraph fill" version of cat. fcat :: [Doc] -> Doc -- | Either hcat or vcat. cat :: [Doc] -> Doc -- | Either hsep or vcat. sep :: [Doc] -> Doc -- | Beside, separated by space, unless one of the arguments is -- empty. <+> is associative, with identity -- empty. (<+>) :: Doc -> Doc -> Doc infixl 6 <+> -- | Above, with no overlapping. $+$ is associative, with identity -- empty. ($+$) :: Doc -> Doc -> Doc infixl 5 $+$ -- | Above, except that if the last line of the first argument stops at -- least one position before the first line of the second begins, these -- two lines are overlapped. For example: -- --
-- text "hi" $$ nest 5 (text "there") ---- -- lays out as -- --
-- hi there ---- -- rather than -- --
-- hi -- there ---- -- $$ is associative, with identity empty, and also -- satisfies -- -- ($$) :: Doc -> Doc -> Doc infixl 5 $$ -- |
-- punctuate p [d1, ... dn] = [d1 <> p, d2 <> p, ... dn-1 <> p, dn] --punctuate :: Doc -> [Doc] -> [Doc] -- |
-- hang d1 n d2 = sep [d1, nest n d2] --hang :: Doc -> Int -> Doc -> Doc -- | Nest (or indent) a document by a given number of positions (which may -- also be negative). nest satisfies the laws: -- --
nest 0 x = x
nest k (nest k' x) = nest (k+k') -- x
nest k (x <> y) = nest k x -- <> nest k y
nest k (x $$ y) = nest k x $$ -- nest k y
nest k empty = empty
-- {"test": {"flatName": "Main:nonEmpty",
-- "location": {"file": "Tutorial.hs", "line": 17},
-- "path": ["Main","nonEmpty"],
-- "sort": "unit-test"},
-- "type":"test-start"}
--
--
--
-- {"result": "pass",
-- "message":"",
-- "test":{"flatName": "Main:nonEmpty",
-- "location": {"file": "Tutorial.hs", "line": 17},
-- "path": ["Main","nonEmpty"],
-- "sort": "unit-test"},
-- "wallTime": 0, // in milliseconds
-- "type": "test-end",
-- "location":null}
--
--
--
-- {"failures": 0,
-- "passed": 4,
-- "pending": 0,
-- "wallTime": 39, // in milliseconds
-- "errors": 0,
-- "type":"test-results"}
--
--
--
-- {"tests": [{"flatName":"Main:nonEmpty","location":{"file":"Tutorial.hs","line":17},"path":["Main","nonEmpty"],"sort":"unit-test"},
-- {"flatName":"Main:empty","location":{"file":"Tutorial.hs","line":19},"path":["Main","empty"],"sort":"unit-test"},
-- {"flatName":"Main:reverse","location":{"file":"Tutorial.hs","line":22},"path":["Main","reverse"],"sort":"quickcheck-property"},
-- {"flatName":"Main:reverseReplay","location":{"file":"Tutorial.hs","line":24},"path":["Main","reverseReplay"],"sort":"quickcheck-property"}],
-- "type":"test-list"}
--
--
-- For an exact specification, please have a look at the code of this
-- module.
module Test.Framework.JsonOutput
data TestStartEventObj
data TestEndEventObj
data TestListObj
data TestObj
data TestResultsObj
mkTestStartEventObj :: FlatTest -> String -> TestStartEventObj
mkTestEndEventObj :: FlatTestResult -> String -> TestEndEventObj
mkTestListObj :: [(FlatTest, String)] -> TestListObj
mkTestResultsObj :: ReportGlobalResultsArg -> TestResultsObj
decodeObj :: HTFJsonObj a => a -> ByteString
class ToJSON a => HTFJsonObj a
instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.JsonOutput.TestStartEventObj
instance Test.Framework.JsonOutput.HTFJsonObj Test.Framework.JsonOutput.TestStartEventObj
instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.JsonOutput.TestEndEventObj
instance Test.Framework.JsonOutput.HTFJsonObj Test.Framework.JsonOutput.TestEndEventObj
instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.JsonOutput.TestListObj
instance Test.Framework.JsonOutput.HTFJsonObj Test.Framework.JsonOutput.TestListObj
instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.JsonOutput.TestObj
instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.JsonOutput.TestResultsObj
instance Test.Framework.JsonOutput.HTFJsonObj Test.Framework.JsonOutput.TestResultsObj
instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.TestTypes.TestPath
instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.TestTypes.TestSort
instance Data.Aeson.Types.ToJSON.ToJSON Test.Framework.Location.Location
-- | Internal module providing a pool of threads.
module Test.Framework.ThreadPool
type ThreadPoolEntry m a b = (m a, a -> IO b, Either SomeException b -> m StopFlag)
data ThreadPool m a b
ThreadPool :: ([ThreadPoolEntry m a b] -> m ()) -> ThreadPool m a b
[tp_run] :: ThreadPool m a b -> [ThreadPoolEntry m a b] -> m ()
data StopFlag
DoStop :: StopFlag
DoNotStop :: StopFlag
sequentialThreadPool :: MonadIO m => ThreadPool m a b
parallelThreadPool :: MonadIO m => Int -> m (ThreadPool m a b)
threadPoolTest :: (Int, Int) -> Int -> IO [()]
instance GHC.Read.Read Test.Framework.ThreadPool.StopFlag
instance GHC.Show.Show Test.Framework.ThreadPool.StopFlag
instance GHC.Classes.Eq Test.Framework.ThreadPool.StopFlag
instance GHC.Show.Show (Test.Framework.ThreadPool.WorkResult m b)
instance GHC.Show.Show (Test.Framework.ThreadPool.WorkItem m b)
-- | This module provides a short tutorial on how to use the HTF. It
-- assumes that you are using GHC for compiling your Haskell code. (It is
-- possible to use the HTF with other Haskell environments, only the
-- steps taken to invoke the custom preprocessor of the HTF may differ in
-- this case.)
module Test.Framework.Tutorial
-- | This module integrates the QuickCheck library into HTF. It
-- re-exports all functionality of QuickCheck and defines some
-- additional functions.
module Test.Framework.QuickCheckWrapper
-- | The Args used if not explicitly changed.
defaultArgs :: Args
-- | Retrieve the Args currently used per default when evaluating
-- quick check properties.
getCurrentArgs :: IO Args
-- | Change the default Args used to evaluate quick check
-- properties.
setDefaultArgs :: Args -> IO ()
-- | Run a QuickCheck property with modified quick check arguments
-- Args.
withQCArgs :: Testable a => (Args -> Args) -> a -> WithQCArgs a
-- | Abstract type for representing quick check properties with custom
-- Args. Used only internally.
data WithQCArgs a
-- | Sets the replay parameter of the Args datatype by
-- parsing the given string.
setReplayFromString :: Args -> String -> Args
-- | Type class providing access to the custom Args of a quick check
-- property. Used only internally.
class QCAssertion a
-- | Use qcPending msg prop to mark the given quick check property
-- as pending without removing it from the test suite and without
-- deleting or commenting out the property code.
qcPending :: Testable t => String -> t -> t
assertionAsProperty :: IO () -> Property
-- | Turns a QuickCheck property into an Assertion. This
-- function is used internally in the code generated by htfpp,
-- do not use it directly.
qcAssertion :: QCAssertion t => t -> Assertion
instance GHC.Classes.Eq Test.Framework.QuickCheckWrapper.QCPendingException
instance GHC.Read.Read Test.Framework.QuickCheckWrapper.QCPendingException
instance GHC.Show.Show Test.Framework.QuickCheckWrapper.QCPendingException
instance Test.QuickCheck.Property.Testable a => Test.Framework.QuickCheckWrapper.QCAssertion a
instance Test.QuickCheck.Property.Testable a => Test.Framework.QuickCheckWrapper.QCAssertion (Test.Framework.QuickCheckWrapper.WithQCArgs a)
instance GHC.Exception.Type.Exception Test.Framework.QuickCheckWrapper.QCPendingException
-- | Internal module for pretty-printing showable Haskell values.
module Test.Framework.PrettyHaskell
prettyHaskell :: Show a => a -> String
prettyHaskell' :: Show a => a -> Maybe String
prettyHaskellTests :: [([Char], IO ())]
instance GHC.Show.Show Test.Framework.PrettyHaskell.MySuperHero
instance GHC.Show.Show Test.Framework.PrettyHaskell.MySuperSuperHero
-- | This module provides assert-like functions for writing unit tests.
module Test.Framework.HUnitWrapper
-- | Fail if the Bool value is False.
assertBool :: HasCallStack => Bool -> IO ()
assertBoolVerbose :: HasCallStack => String -> Bool -> IO ()
-- | Fail if the two values of type a are not equal. Use if
-- a is an instance of Show but not of Pretty.
assertEqual :: (Eq a, Show a, HasCallStack) => a -> a -> IO ()
-- | Fail if the two values of type a are not equal, supplying an
-- additional message. Use if a is an instance of Show
-- but not of Pretty.
assertEqualVerbose :: (Eq a, Show a, HasCallStack) => String -> a -> a -> IO ()
-- | Fail if the two values of type a are not equal. Use if
-- a is an instance of Pretty.
assertEqualPretty :: (Eq a, Pretty a, HasCallStack) => a -> a -> IO ()
-- | Fail if the two values of type a are not equal, supplying an
-- additional message. Use if a is an instance of Pretty.
assertEqualPrettyVerbose :: (Eq a, Pretty a, HasCallStack) => String -> a -> a -> IO ()
-- | Fail if the two values of type a are not equal. Use if
-- a is neither an instance of Show nor of Pretty.
assertEqualNoShow :: (Eq a, HasCallStack) => a -> a -> IO ()
-- | Fail if the two values of type a are not equal, supplying an
-- additional message. Use if a is neither an instance of
-- Show nor of Pretty.
assertEqualNoShowVerbose :: (Eq a, HasCallStack) => String -> a -> a -> IO ()
-- | Fail if the two values of type a are equal. Use if a
-- is an instance of Show but not of Pretty.
assertNotEqual :: (Eq a, Show a, HasCallStack) => a -> a -> IO ()
-- | Fail if the two values of type a are equal, supplying an
-- additional message. Use if a is an instance of Show
-- but not of Pretty.
assertNotEqualVerbose :: (Eq a, Show a, HasCallStack) => String -> a -> a -> IO ()
-- | Fail if the two values of type a are equal. Use if a
-- is an instance of Pretty.
assertNotEqualPretty :: (Eq a, Pretty a, HasCallStack) => a -> a -> IO ()
-- | Fail if the two values of type a are equal, supplying an
-- additional message. Use if a is an instance of Pretty.
assertNotEqualPrettyVerbose :: (Eq a, Pretty a, HasCallStack) => String -> a -> a -> IO ()
-- | Fail if the two values of type a are equal. Use if a
-- is neither an instance of Show nor of Pretty.
assertNotEqualNoShow :: (Eq a, HasCallStack) => a -> a -> IO ()
-- | Fail if the two values of type a are equal, supplying an
-- additional message. Use if a is neither an instance of
-- Show nor of Pretty.
assertNotEqualNoShowVerbose :: (Eq a, HasCallStack) => String -> a -> a -> IO ()
-- | Fail if the two given lists are not equal when considered as sets.
assertListsEqualAsSets :: (Eq a, Show a, HasCallStack) => [a] -> [a] -> IO ()
-- | Fail if the two given lists are not equal when considered as sets,
-- supplying an additional error message.
assertListsEqualAsSetsVerbose :: (Eq a, Show a, HasCallStack) => String -> [a] -> [a] -> IO ()
-- | Fail if the given list is empty.
assertNotEmpty :: HasCallStack => [a] -> IO ()
-- | Fail if the given list is empty, supplying an additional error
-- message.
assertNotEmptyVerbose :: HasCallStack => String -> [a] -> IO ()
-- | Fail if the given list is not empty.
assertEmpty :: HasCallStack => [a] -> IO ()
-- | Fail if the given list is not empty, supplying an additional error
-- message.
assertEmptyVerbose :: HasCallStack => String -> [a] -> IO ()
-- | Fail if the element given is not contained in the list.
assertElem :: (Eq a, Show a, HasCallStack) => a -> [a] -> IO ()
-- | Fail if the element given is not contained in the list, supplying an
-- additional error message.
assertElemVerbose :: (Eq a, Show a, HasCallStack) => String -> a -> [a] -> IO ()
-- | Fail if evaluating the expression of type a does not throw an
-- exception satisfying the given predicate (e -> Bool).
assertThrows :: (HasCallStack, Exception e) => a -> (e -> Bool) -> IO ()
-- | Fail if evaluating the expression of type a does not throw an
-- exception satisfying the given predicate (e -> Bool),
-- supplying an additional error message.
assertThrowsVerbose :: (HasCallStack, Exception e) => String -> a -> (e -> Bool) -> IO ()
-- | Fail if evaluating the expression of type a does not throw
-- any exception.
assertThrowsSome :: HasCallStack => a -> IO ()
-- | Fail if evaluating the expression of type a does not throw
-- any exception, supplying an additional error message.
assertThrowsSomeVerbose :: HasCallStack => String -> a -> IO ()
-- | Fail if executing the IO action does not throw an exception
-- satisfying the given predicate (e -> Bool).
assertThrowsIO :: (HasCallStack, Exception e) => IO a -> (e -> Bool) -> IO ()
-- | Fail if executing the IO action does not throw an exception
-- satisfying the given predicate (e -> Bool), supplying an
-- additional error message.
assertThrowsIOVerbose :: (HasCallStack, Exception e) => String -> IO a -> (e -> Bool) -> IO ()
-- | Fail if executing the IO action does not throw any exception.
assertThrowsSomeIO :: HasCallStack => IO a -> IO ()
-- | Fail if executing the IO action does not throw any exception,
-- supplying an additional error message.
assertThrowsSomeIOVerbose :: HasCallStack => String -> IO a -> IO ()
-- | Fail if executing the m action does not throw an exception
-- satisfying the given predicate (e -> Bool).
assertThrowsM :: (MonadBaseControl IO m, MonadIO m, Exception e, HasCallStack) => m a -> (e -> Bool) -> m ()
-- | Fail if executing the m action does not throw an exception
-- satisfying the given predicate (e -> Bool), supplying an
-- additional error message.
assertThrowsMVerbose :: (MonadBaseControl IO m, MonadIO m, Exception e, HasCallStack) => String -> m a -> (e -> Bool) -> m ()
-- | Fail if executing the m action does not throw any exception.
assertThrowsSomeM :: (MonadBaseControl IO m, MonadIO m, HasCallStack) => m a -> m ()
-- | Fail if executing the m action does not throw any exception,
-- supplying an additional error message.
assertThrowsSomeMVerbose :: (MonadBaseControl IO m, MonadIO m, HasCallStack) => String -> m a -> m ()
-- | Fail if the given Either a b value is a Right. Use
-- this function if b is an instance of Show.
assertLeft :: (HasCallStack, Show b) => Either a b -> IO a
-- | Fail if the given Either a b value is a Right,
-- supplying an additional error message. Use this function if b
-- is an instance of Show.
assertLeftVerbose :: (Show b, HasCallStack) => String -> Either a b -> IO a
-- | Fail if the given Either a b value is a Right. Use
-- this function if b is not an instance of Show.
assertLeftNoShow :: HasCallStack => Either a b -> IO a
-- | Fail if the given Either a b value is a Right,
-- supplying an additional error message. Use this function if b
-- is not an instance of Show.
assertLeftNoShowVerbose :: HasCallStack => String -> Either a b -> IO a
-- | Fail if the given Either a b value is a Left. Use this
-- function if a is an instance of Show.
assertRight :: (HasCallStack, Show a) => Either a b -> IO b
-- | Fail if the given Either a b value is a Left,
-- supplying an additional error message. Use this function if a
-- is an instance of Show.
assertRightVerbose :: (Show a, HasCallStack) => String -> Either a b -> IO b
-- | Fail if the given Either a b value is a Left. Use this
-- function if a is not an instance of Show.
assertRightNoShow :: HasCallStack => Either a b -> IO b
-- | Fail if the given Either a b value is a Left,
-- supplying an additional error message. Use this function if a
-- is not an instance of Show.
assertRightNoShowVerbose :: HasCallStack => String -> Either a b -> IO b
-- | Fail if the given value is a Nothing.
assertJust :: HasCallStack => Maybe a -> IO a
-- | Fail if the given value is a Nothing, supplying an additional error
-- message.
assertJustVerbose :: HasCallStack => String -> Maybe a -> IO a
-- | Fail if the given Maybe a value is a Just. Use this
-- function if a is an instance of Show.
assertNothing :: (HasCallStack, Show a) => Maybe a -> IO ()
-- | Fail if the given Maybe a value is a Just, supplying
-- an additional error message. Use this function if a is an
-- instance of Show.
assertNothingVerbose :: (Show a, HasCallStack) => String -> Maybe a -> IO ()
-- | Fail if the given Maybe a value is a Just. Use this
-- function if a is not an instance of Show.
assertNothingNoShow :: HasCallStack => Maybe a -> IO ()
-- | Fail if the given Maybe a value is a Just, supplying
-- an additional error message. Use this function if a is not an
-- instance of Show.
assertNothingNoShowVerbose :: HasCallStack => String -> Maybe a -> IO ()
-- | Specialization of gassertFailure to IO.
assertFailure :: HasCallStack => String -> IO a
-- | Signals that the current unit test is pending.
unitTestPending :: String -> IO a
-- | Use unitTestPending' msg test to mark the given test as
-- pending without removing it from the test suite and without deleting
-- or commenting out the test code.
unitTestPending' :: String -> IO a -> IO a
-- | Use subAssert if you want location information for the call
-- site but the function being called does not carry a
-- HasCallStack constraint.
subAssert :: (HasCallStack, MonadBaseControl IO m) => m a -> m a
subAssertVerbose :: (HasCallStack, MonadBaseControl IO m) => String -> m a -> m a
gassertBool :: (HasCallStack, AssertM m) => Bool -> m ()
gassertBoolVerbose :: (HasCallStack, AssertM m) => String -> Bool -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are not equal. Use if a is an instance of Show but not
-- of Pretty.
gassertEqual :: (Eq a, Show a, AssertM m, HasCallStack) => a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are not equal, supplying an additional message. Use if a is
-- an instance of Show but not of Pretty.
gassertEqualVerbose :: (Eq a, Show a, AssertM m, HasCallStack) => String -> a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are not equal. Use if a is an instance of Pretty.
gassertEqualPretty :: (Eq a, Pretty a, AssertM m, HasCallStack) => a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are not equal, supplying an additional message. Use if a is
-- an instance of Pretty.
gassertEqualPrettyVerbose :: (Eq a, Pretty a, AssertM m, HasCallStack) => String -> a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are not equal. Use if a is neither an instance of Show
-- nor of Pretty.
gassertEqualNoShow :: (Eq a, AssertM m, HasCallStack) => a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are not equal, supplying an additional message. Use if a is
-- neither an instance of Show nor of Pretty.
gassertEqualNoShowVerbose :: (Eq a, AssertM m, HasCallStack) => String -> a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are equal. Use if a is an instance of Show but not of
-- Pretty.
gassertNotEqual :: (Eq a, Show a, AssertM m, HasCallStack) => a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are equal, supplying an additional message. Use if a is an
-- instance of Show but not of Pretty.
gassertNotEqualVerbose :: (Eq a, Show a, AssertM m, HasCallStack) => String -> a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are equal. Use if a is an instance of Pretty.
gassertNotEqualPretty :: (Eq a, Pretty a, AssertM m, HasCallStack) => a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are equal, supplying an additional message. Use if a is an
-- instance of Pretty.
gassertNotEqualPrettyVerbose :: (Eq a, Pretty a, AssertM m, HasCallStack) => String -> a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are equal. Use if a is neither an instance of Show nor
-- of Pretty.
gassertNotEqualNoShow :: (Eq a, AssertM m, HasCallStack) => a -> a -> m ()
-- | Fail in some AssertM monad if the two values of type a
-- are equal, supplying an additional message. Use if a is
-- neither an instance of Show nor of Pretty.
gassertNotEqualNoShowVerbose :: (Eq a, AssertM m, HasCallStack) => String -> a -> a -> m ()
-- | Fail in some AssertM monad if the two given lists are not equal
-- when considered as sets.
gassertListsEqualAsSets :: (Eq a, Show a, AssertM m, HasCallStack) => [a] -> [a] -> m ()
-- | Fail in some AssertM monad if the two given lists are not equal
-- when considered as sets, supplying an additional error message.
gassertListsEqualAsSetsVerbose :: (Eq a, Show a, AssertM m, HasCallStack) => String -> [a] -> [a] -> m ()
-- | Fail in some AssertM monad if the given list is empty.
gassertNotEmpty :: (HasCallStack, AssertM m) => [a] -> m ()
-- | Fail in some AssertM monad if the given list is empty,
-- supplying an additional error message.
gassertNotEmptyVerbose :: (AssertM m, HasCallStack) => String -> [a] -> m ()
-- | Fail in some AssertM monad if the given list is not empty.
gassertEmpty :: (HasCallStack, AssertM m) => [a] -> m ()
-- | Fail in some AssertM monad if the given list is not empty,
-- supplying an additional error message.
gassertEmptyVerbose :: (AssertM m, HasCallStack) => String -> [a] -> m ()
-- | Fail in some AssertM monad if the element given is not
-- contained in the list.
gassertElem :: (Eq a, Show a, AssertM m, HasCallStack) => a -> [a] -> m ()
-- | Fail in some AssertM monad if the element given is not
-- contained in the list, supplying an additional error message.
gassertElemVerbose :: (Eq a, Show a, AssertM m, HasCallStack) => String -> a -> [a] -> m ()
-- | Fail in some AssertM monad if the given Either a b
-- value is a Right. Use this function if b is an
-- instance of Show.
gassertLeft :: (Show b, AssertM m, HasCallStack) => Either a b -> m a
-- | Fail in some AssertM monad if the given Either a b
-- value is a Right, supplying an additional error message. Use
-- this function if b is an instance of Show.
gassertLeftVerbose :: (Show b, AssertM m, HasCallStack) => String -> Either a b -> m a
-- | Fail in some AssertM monad if the given Either a b
-- value is a Right. Use this function if b is not an
-- instance of Show.
gassertLeftNoShow :: (HasCallStack, AssertM m) => Either a b -> m a
-- | Fail in some AssertM monad if the given Either a b
-- value is a Right, supplying an additional error message. Use
-- this function if b is not an instance of Show.
gassertLeftNoShowVerbose :: (HasCallStack, AssertM m) => String -> Either a b -> m a
-- | Fail in some AssertM monad if the given Either a b
-- value is a Left. Use this function if a is an instance
-- of Show.
gassertRight :: (Show a, AssertM m, HasCallStack) => Either a b -> m b
-- | Fail in some AssertM monad if the given Either a b
-- value is a Left, supplying an additional error message. Use
-- this function if a is an instance of Show.
gassertRightVerbose :: (Show a, AssertM m, HasCallStack) => String -> Either a b -> m b
-- | Fail in some AssertM monad if the given Either a b
-- value is a Left. Use this function if a is not an
-- instance of Show.
gassertRightNoShow :: (HasCallStack, AssertM m) => Either a b -> m b
-- | Fail in some AssertM monad if the given Either a b
-- value is a Left, supplying an additional error message. Use
-- this function if a is not an instance of Show.
gassertRightNoShowVerbose :: (HasCallStack, AssertM m) => String -> Either a b -> m b
-- | Fail in some AssertM monad if the given value is a Nothing.
gassertJust :: (HasCallStack, AssertM m) => Maybe a -> m a
-- | Fail in some AssertM monad if the given value is a Nothing,
-- supplying an additional error message.
gassertJustVerbose :: (HasCallStack, AssertM m) => String -> Maybe a -> m a
-- | Fail in some AssertM monad if the given Maybe a value
-- is a Just. Use this function if a is an instance of
-- Show.
gassertNothing :: (Show a, AssertM m, HasCallStack) => Maybe a -> m ()
-- | Fail in some AssertM monad if the given Maybe a value
-- is a Just, supplying an additional error message. Use this
-- function if a is an instance of Show.
gassertNothingVerbose :: (Show a, AssertM m, HasCallStack) => String -> Maybe a -> m ()
-- | Fail in some AssertM monad if the given Maybe a value
-- is a Just. Use this function if a is not an instance
-- of Show.
gassertNothingNoShow :: (HasCallStack, AssertM m) => Maybe a -> m ()
-- | Fail in some AssertM monad if the given Maybe a value
-- is a Just, supplying an additional error message. Use this
-- function if a is not an instance of Show.
gassertNothingNoShowVerbose :: (HasCallStack, AssertM m) => String -> Maybe a -> m ()
-- | Fail with the given reason in some AssertM monad.
gassertFailure :: (HasCallStack, AssertM m) => String -> m a
gsubAssert :: (HasCallStack, AssertM m) => m a -> m a
gsubAssertVerbose :: (HasCallStack, AssertM m) => String -> m a -> m a
data HUnitFailure
hunitWrapperTests :: [([Char], IO ())]
-- | XML-output following the JUnit output format.
--
-- The data types exposed by this module give a rough specification of
-- the output format.
--
-- Here is a sample ouput:
--
-- -- <?xml version="1.0" encoding="UTF-8" standalone="yes"?> -- <testsuites tests="6" failures="2" errors="0" time="0.705"> -- <testsuite id="0" tests="2" failures="0" errors="0" time="0.000" name=MyPkg.A package=MyPkg.A> -- <testcase classname=MyPkg.A name="test_funA2" time="0.000"/> -- <testcase classname=MyPkg.A name="test_funA1" time="0.000"/> -- </testsuite> -- <testsuite id="1" tests="2" failures="0" errors="0" time="0.000" name=MyPkg.B package=MyPkg.B> -- <testcase classname=MyPkg.B name="test_funB2" time="0.000"/> -- <testcase classname=MyPkg.B name="test_funB1" time="0.000"/> -- </testsuite> -- <testsuite id="2" tests="2" failures="2" errors="0" time="0.703" name="bbts" package="bbts"> -- <testcase classname="bbts" name="bbt_bbt-dirshould-passx.num" time="0.230"> -- <failure type="failure" message="test is supposed to succeed but failed with exit code 255">test is supposed to succeed but failed with exit code 255</failure> -- </testcase> -- <testcase classname="bbts" name="bbt_bbt-dirshould-failz.num" time="0.473"> -- <failure type="failure" message="Mismatch on stderr:">Mismatch on stderr: -- --- bbt-dirshould-failz.err 2015-09-05 18:37:30.000000000 +0200 -- +++ - 2022-03-06 09:49:55.480265000 +0100 -- @@ -1 +1 @@ -- -invalid input -- +sample[88331]: [fatal] unable to read input graph: The data couldn’t be read because it isn’t in the correct format. -- [end of diff output] -- </failure> -- </testcase> -- </testsuite> -- </testsuites> --module Test.Framework.XmlOutput -- | A "specification" of the output format in terms of haskell data types: -- The name of each data type corresponds to the name of an XML element -- (lowercase first letter). The name of a field with a primitive -- corresponds to an attribute with then same name as the field (without -- the prefix up to the first _). -- -- The root element is testsuites data JunitXmlOutput JunitXmlOutput :: Testsuites -> JunitXmlOutput data Testsuites Testsuites :: Int -> Int -> Int -> Seconds -> [Testsuite] -> Testsuites [tss_tests] :: Testsuites -> Int [tss_failures] :: Testsuites -> Int [tss_errors] :: Testsuites -> Int [tss_time] :: Testsuites -> Seconds [tss_suites] :: Testsuites -> [Testsuite] data Testsuite Testsuite :: Int -> Int -> Int -> Seconds -> Int -> String -> String -> [Testcase] -> Testsuite [ts_tests] :: Testsuite -> Int [ts_failures] :: Testsuite -> Int [ts_errors] :: Testsuite -> Int [ts_time] :: Testsuite -> Seconds [ts_id] :: Testsuite -> Int [ts_name] :: Testsuite -> String [ts_package] :: Testsuite -> String [ts_testcases] :: Testsuite -> [Testcase] data Testcase Testcase :: String -> String -> Seconds -> Maybe Result -> Testcase [tc_classname] :: Testcase -> String [tc_name] :: Testcase -> String [tc_time] :: Testcase -> Seconds [tc_result] :: Testcase -> Maybe Result data Result Result :: String -> Text -> String -> Text -> Result [r_elemName] :: Result -> String [r_message] :: Result -> Text [r_type] :: Result -> String [r_textContent] :: Result -> Text mkGlobalResultsXml :: ReportGlobalResultsArg -> ByteString -- | This module defines function for running a set of tests. Furthermore, -- it provides functionality for organzing tests into a hierarchical -- structure. -- -- This functionality is mainly used internally in the code generated by -- the hftpp pre-processor. module Test.Framework.TestManager -- | Runs something testable by parsing the commandline arguments as test -- options (using parseTestArgs). Exits with the exit code -- returned by runTestWithArgs. This function is the main entry -- point for running tests. htfMain :: TestableHTF t => t -> IO () -- | Runs something testable by parsing the commandline arguments as test -- options (using parseTestArgs). Exits with the exit code -- returned by runTestWithArgs. htfMainWithArgs :: TestableHTF t => [String] -> t -> IO () -- | Run something testable using the defaultCmdlineOptions. runTest :: TestableHTF t => t -> IO ExitCode -- | Run something testable using the defaultCmdlineOptions. runTest' :: TestableHTF t => t -> IO (IO (), ExitCode) -- | Run something testable, parse the CmdlineOptions from the given -- commandline arguments. Does not print the overall test results but -- returns an IO action for doing so. runTestWithArgs :: TestableHTF t => [String] -> t -> IO ExitCode -- | Run something testable, parse the CmdlineOptions from the given -- commandline arguments. runTestWithArgs' :: TestableHTF t => [String] -> t -> IO (IO (), ExitCode) -- | Runs something testable with the given CmdlineOptions. See -- runTestWithConfig for a specification of the ExitCode -- result. runTestWithOptions :: TestableHTF t => CmdlineOptions -> t -> IO ExitCode -- | Runs something testable with the given CmdlineOptions. Does not -- print the overall test results but returns an IO action for -- doing so. See runTestWithConfig for a specification of the -- ExitCode result. runTestWithOptions' :: TestableHTF t => CmdlineOptions -> t -> IO (IO (), ExitCode) -- | Runs something testable with the given TestConfig. The result -- is ExitSuccess if all tests were executed successfully, -- ExitFailure otherwise. In the latter case, an error code of -- 1 indicates that failures but no errors occurred, otherwise -- the error code 2 is used. -- -- A test is successful if the test terminates and no assertion -- fails. A test is said to fail if an assertion fails but no -- other error occur. runTestWithConfig :: TestableHTF t => TestConfig -> t -> IO (ExitCode, TestHistory) -- | Runs something testable with the given TestConfig. Does not -- print the overall test results but returns an IO action for -- doing so. See runTestWithConfig for a specification of the -- ExitCode result. runTestWithConfig' :: TestableHTF t => TestConfig -> t -> IO (IO (), ExitCode, TestHistory) -- | A type class for things that can be run as tests. Mainly used -- internally. class TestableHTF t -- | Kind of specialised Functor type class for tests, which allows -- you to modify the Assertions of the WrappableHTF-thing -- without changing any test code. -- -- E.g. if you want to add timeouts to all tests of a module, you could -- write: -- --
-- addTimeout test = timeout 100 test >>= assertJustVerbose "Timeout exceeded" -- testsWithTimeouts = wrap addTimeout htf_thisModulesTests --class WrappableHTF t wrap :: WrappableHTF t => (Assertion -> Assertion) -> t -> t -- | Construct a test where the given Assertion checks a quick check -- property. Mainly used internally by the htfpp preprocessor. makeQuickCheckTest :: TestID -> Location -> Assertion -> Test -- | Construct a unit test from the given IO action. Mainly used -- internally by the htfpp preprocessor. makeUnitTest :: AssertionWithTestOptions a => TestID -> Location -> a -> Test -- | Construct a black box test from the given Assertion. Mainly -- used internally. makeBlackBoxTest :: TestID -> Assertion -> Test -- | Create a named TestSuite from a list of Test values. makeTestSuite :: TestID -> [Test] -> TestSuite -- | Create an unnamed TestSuite from a list of Test values. makeAnonTestSuite :: [Test] -> TestSuite -- | Extend a TestSuite with a list of Test values addToTestSuite :: TestSuite -> [Test] -> TestSuite -- | Turn a TestSuite into a proper Test. testSuiteAsTest :: TestSuite -> Test flattenTest :: Test -> [FlatTest] wrappableTests :: [([Char], IO ())] instance Test.Framework.TestManager.TestableHTF Test.Framework.TestTypes.Test instance Test.Framework.TestManager.TestableHTF Test.Framework.TestTypes.TestSuite instance Test.Framework.TestManager.TestableHTF t => Test.Framework.TestManager.TestableHTF [t] instance Test.Framework.TestManager.TestableHTF (GHC.Types.IO a) instance Test.Framework.TestManager.WrappableHTF Test.Framework.TestTypes.TestSuite instance Test.Framework.TestManager.WrappableHTF Test.Framework.TestTypes.Test -- | A black box test in the terminology of the HTF consists of a -- driver program that is run in various input files. For each input -- file, the HTF checks that the driver program exits with the correct -- exit code and that it produces the expected output. The samples -- directory of the HTF source tree shows an example for a black box -- test, see https://github.com/skogsbaer/HTF/tree/master/sample. -- -- NOTE: If you use black box tests, you have to compile your -- program with the -threaded option. Otherwise, your program -- just blocks indefinitely! module Test.Framework.BlackBoxTest -- | Use a value of this datatype to customize various aspects of your -- black box tests. data BBTArgs BBTArgs :: String -> String -> String -> String -> Bool -> Diff -> Diff -> BBTArgs -- | File extension for the file used as stdin. [bbtArgs_stdinSuffix] :: BBTArgs -> String -- | File extension for the file specifying expected output on stdout. [bbtArgs_stdoutSuffix] :: BBTArgs -> String -- | File extension for the file specifying expected output on stderr. [bbtArgs_stderrSuffix] :: BBTArgs -> String -- | Name of a file defining various arguments for executing the tests -- contained in a subdirectory of the test hierarchy. If a directory -- contains a such-named file, the arguments apply to all testfiles -- directly contained in this directory. See the documentation of -- blackBoxTests for a specification of the argument file format. -- Default: BBTArgs [bbtArgs_dynArgsName] :: BBTArgs -> String -- | Be verbose or not. [bbtArgs_verbose] :: BBTArgs -> Bool -- | Diff program for comparing output on stdout with the expected value. [bbtArgs_stdoutDiff] :: BBTArgs -> Diff -- | Diff program for comparing output on stderr with the expected value. [bbtArgs_stderrDiff] :: BBTArgs -> Diff -- | Sensible default values for BBTArgs: -- --
-- defaultBBTArgs = BBTArgs { bbtArgs_stdinSuffix = ".in"
-- , bbtArgs_stdoutSuffix = ".out"
-- , bbtArgs_stderrSuffix = ".err"
-- , bbtArgs_dynArgsName = "BBTArgs"
-- , bbtArgs_stdoutDiff = defaultDiff
-- , bbtArgs_stderrDiff = defaultDiff
-- , bbtArgs_verbose = False }
--
defaultBBTArgs :: BBTArgs
-- | Collects all black box tests with the given file extension stored in a
-- specific directory. For example, the invocation
--
-- -- blackBoxTests "bbt-dir" "dist/build/sample/sample" ".num" defaultBBTArgs ---- -- returns a list of Test values, one Test for each -- .num file found in bbt-dir and its subdirectories. -- (The samples directory of the HTF source tree contains the example -- shown here, see -- https://github.com/skogsbaer/HTF/tree/master/sample.) -- -- Suppose that one of the .num files is -- bbt-dir/should-pass/x.num. Running the corresponding -- Test invokes dist/build/sample/sample (the program -- under test) with bbt-dir/should-pass/x.num as the last -- commandline argument. The other commandline arguments are taken from -- the flags specification given in the file whose name is stored in the -- bbtArgs_dynArgsName field of the BBTArgs record (see -- below, default is BBTArgs). -- -- If bbt-dir/should-pass/x.in existed, its content would be -- used as stdin. The tests succeeds if the exit code of the program is -- zero and the output on stdout and stderr matches the contents of -- bbt-dir/should-pass/x.out and -- bbt-dir/should-pass/x.err, respectively. If -- bbt-dir/should-pass/x.out and -- bbt-dir/should-pass/x.err do not exist, then output is not -- checked. -- -- The bbtArgs_dynArgsName field of the BBTArgs record -- specifies a filename that contains some more configuration flags for -- the tests. The following flags (separated by newlines) are supported: -- --
-- addTimeout test = timeout 100 test >>= assertJustVerbose "Timeout exceeded" -- testsWithTimeouts = wrap addTimeout htf_thisModulesTests --class WrappableHTF t wrap :: WrappableHTF t => (Assertion -> Assertion) -> t -> t