]> gitweb.michael.orlitzky.com - spline3.git/blobdiff - src/Assertions.hs
Remove the Tetrahedron 'number' field from tests.
[spline3.git] / src / Assertions.hs
index 8efd12340b04408c6e5916271d01c25977e368a3..33b79b9b8ba68bb3dabc2002ad284498705bc335 100644 (file)
@@ -1,3 +1,6 @@
+-- | The Assertions module contains assertions for use in HUnit
+--   tests. They primarily fill the need for an equality test that
+--   works with floating point numbers.
 module Assertions
 where
 
@@ -8,19 +11,22 @@ import Comparisons
 import Point
 
 -- | An HUnit assertion that wraps the almost_equals function. Stolen
---   from the definition of assertEqual in Test/HUnit/Base.hs.
+--   from the definition of 'assertEqual' in Test\/HUnit\/Base.hs.
 assertAlmostEqual :: String -> Double -> Double -> Assertion
 assertAlmostEqual preface expected actual =
   unless (actual ~= expected) (assertFailure msg)
- where msg = (if null preface then "" else preface ++ "\n") ++
-             "expected: " ++ show expected ++ "\n but got: " ++ show actual
   where msg = (if null preface then "" else preface ++ "\n") ++
+                "expected: " ++ show expected ++ "\n but got: " ++ show actual
 
 
 -- | An HUnit assertion that wraps the is_close function. Stolen
---   from the definition of assertEqual in Test/HUnit/Base.hs.
+--   from the definition of 'assertEqual' in Test\/HUnit\/Base.hs.
 assertClose :: String -> Point -> Point -> Assertion
 assertClose preface expected actual =
   unless (actual `is_close` expected) (assertFailure msg)
- where msg = (if null preface then "" else preface ++ "\n") ++
-             "expected: " ++ show expected ++ "\n but got: " ++ show actual
   where msg = (if null preface then "" else preface ++ "\n") ++
+                "expected: " ++ show expected ++ "\n but got: " ++ show actual
 
+-- | It's asinine that this doesn't exist already.
+assertTrue :: String -> Bool -> Assertion
+assertTrue = assertBool