HUnit-1.6.0.0: A unit testing framework for Haskell
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.HUnit.Lang

Contents

Synopsis

Documentation

type Assertion = IO () #

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 #

Arguments

:: HasCallStack 
=> String

A message that is displayed with the assertion failure

-> IO a 

Unconditionally signals that a failure has occured. All other assertions can be expressed with the form:

   if conditionIsMet
       then IO ()
       else assertFailure msg

assertEqual #

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 #

Constructors

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

Instances

Instances details
Eq Result # 
Instance details

Defined in Test.HUnit.Lang

Methods

(==) :: Result -> Result -> Bool

(/=) :: Result -> Result -> Bool

Show Result # 
Instance details

Defined in Test.HUnit.Lang

Methods

showsPrec :: Int -> Result -> ShowS

show :: Result -> String

showList :: [Result] -> ShowS

performTestCase #

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 #

Constructors

HUnitFailure (Maybe SrcLoc) FailureReason 

Instances

Instances details
Eq HUnitFailure # 
Instance details

Defined in Test.HUnit.Lang

Methods

(==) :: HUnitFailure -> HUnitFailure -> Bool

(/=) :: HUnitFailure -> HUnitFailure -> Bool

Show HUnitFailure # 
Instance details

Defined in Test.HUnit.Lang

Methods

showsPrec :: Int -> HUnitFailure -> ShowS

show :: HUnitFailure -> String

showList :: [HUnitFailure] -> ShowS

Exception HUnitFailure # 
Instance details

Defined in Test.HUnit.Lang

Methods

toException :: HUnitFailure -> SomeException

fromException :: SomeException -> Maybe HUnitFailure

displayException :: HUnitFailure -> String

data FailureReason #

Constructors

Reason String 
ExpectedButGot (Maybe String) String String 

Instances

Instances details
Eq FailureReason # 
Instance details

Defined in Test.HUnit.Lang

Show FailureReason # 
Instance details

Defined in Test.HUnit.Lang

Methods

showsPrec :: Int -> FailureReason -> ShowS

show :: FailureReason -> String

showList :: [FailureReason] -> ShowS