1 -- | The Assertions module contains assertions for use in HUnit
2 -- tests. They primarily fill the need for an equality test that
3 -- works with floating point numbers.
10 import Control.Monad ( unless )
16 import Comparisons ( (~=) )
19 -- | An HUnit assertion that wraps the almost_equals function. Stolen
20 -- from the definition of 'assertEqual' in Test\/HUnit\/Base.hs.
21 assertAlmostEqual :: String -> Double -> Double -> Assertion
22 assertAlmostEqual preface expected actual =
23 unless (actual ~= expected) (assertFailure msg)
24 where msg = (if null preface then "" else preface ++ "\n") ++
25 "expected: " ++ show expected ++ "\n but got: " ++ show actual
29 -- | It's asinine that this doesn't exist already.
30 assertTrue :: String -> Bool -> Assertion
31 assertTrue = assertBool