HUnit-1.6.2.0: A unit testing framework for Haskell

Safe Haskell | Safe-Inferred
Language | Haskell2010

Test.HUnit.Lang

Contents

- Internals

Synopsis

- type Assertion = IO ()
- assertFailure :: HasCallStack => String -> IO a
- assertEqual :: (HasCallStack, Eq a, Show a) => String -> a -> a -> Assertion
- data Result
  - = Success
  - | Failure (Maybe SrcLoc) String
  - | Error (Maybe SrcLoc) String
- performTestCase :: Assertion -> IO Result
- data HUnitFailure = HUnitFailure (Maybe SrcLoc) FailureReason
- data FailureReason
  - = Reason String
  - | ExpectedButGot (Maybe String) String String
- formatFailureReason :: FailureReason -> String

# Documentation

type Assertion = IO () Source #

When an assertion is evaluated, it will output a message if and only if the assertion fails.

Test cases are composed of a sequence of one or more assertions.

assertFailure Source #

Arguments

:: HasCallStack |
=> String | A message that is displayed with the assertion failure
-> IO a |

Unconditionally signals that a failure has occurred.

assertEqual Source #

Arguments

:: (HasCallStack, Eq a, Show a) |
=> String | The message prefix
-> a | The expected value
-> a | The actual value
-> Assertion |

Asserts that the specified actual value is equal to the expected value. The output message will contain the prefix, the expected value, and the actual value.

If the prefix is the empty string (i.e., `""`), then the prefix is omitted and only the expected and actual values are output.

data Result Source #

Constructors

Success |
Failure (Maybe SrcLoc) String |
Error (Maybe SrcLoc) String |

#### Instances

Instances details

Show Result Source # |
Instance details Defined in Test.HUnit.Lang Methods showsPrec :: Int -> Result -> ShowS Source # show :: Result -> String Source # showList :: [Result] -> ShowS Source #
Eq Result Source # |
Instance details Defined in Test.HUnit.Lang Methods (==) :: Result -> Result -> Bool Source # (/=) :: Result -> Result -> Bool Source #

performTestCase Source #

Arguments

:: Assertion | an assertion to be made during the test case run
-> IO Result |

Performs a single test case.

# Internals

Note: This is not part of the public API! It is exposed so that you can tinker with the internals of HUnit, but do not expect it to be stable!

data HUnitFailure Source #

Constructors

HUnitFailure (Maybe SrcLoc) FailureReason |

#### Instances

Instances details

Exception HUnitFailure Source # |
Instance details Defined in Test.HUnit.Lang Methods toException :: HUnitFailure -> SomeException Source # fromException :: SomeException -> Maybe HUnitFailure Source # displayException :: HUnitFailure -> String Source # backtraceDesired :: HUnitFailure -> Bool Source #
Show HUnitFailure Source # |
Instance details Defined in Test.HUnit.Lang Methods showsPrec :: Int -> HUnitFailure -> ShowS Source # show :: HUnitFailure -> String Source # showList :: [HUnitFailure] -> ShowS Source #
Eq HUnitFailure Source # |
Instance details Defined in Test.HUnit.Lang Methods (==) :: HUnitFailure -> HUnitFailure -> Bool Source # (/=) :: HUnitFailure -> HUnitFailure -> Bool Source #

data FailureReason Source #

Constructors

Reason String |
ExpectedButGot (Maybe String) String String |

#### Instances

Instances details

Show FailureReason Source # |
Instance details Defined in Test.HUnit.Lang Methods showsPrec :: Int -> FailureReason -> ShowS Source # show :: FailureReason -> String Source # showList :: [FailureReason] -> ShowS Source #
Eq FailureReason Source # |
Instance details Defined in Test.HUnit.Lang Methods (==) :: FailureReason -> FailureReason -> Bool Source # (/=) :: FailureReason -> FailureReason -> Bool Source #

formatFailureReason :: FailureReason -> String Source #