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 )
11 import Test.Tasty.HUnit (
16 import Comparisons ( (~=) )
19 -- | An HUnit assertion that wraps the almost_equals function. Stolen
20 -- from the definition of 'assertEqual' in Test\/Tasty\/HUnit\/Orig.hs.
22 assertAlmostEqual :: String -- ^ The message prefix
23 -> Double -- ^ The expected value
24 -> Double -- ^ The actual value
26 assertAlmostEqual preface expected actual =
27 unless (actual ~= expected) (assertFailure msg)
28 where msg = (if null preface then "" else preface ++ "\n") ++
29 "expected: " ++ show expected ++ "\n but got: " ++ show actual
33 -- | It's asinine that this doesn't exist already.
35 assertTrue :: String -> Bool -> Assertion
36 assertTrue = assertBool