X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FAssertions.hs;h=44d793b989be2f4eb83955995adfca976e4cfb9b;hb=58cf11569acb270995d2de924dda03ef526647e2;hp=8efd12340b04408c6e5916271d01c25977e368a3;hpb=f07f76b231a3df623aab8b6035ac6000ce2a5eb2;p=spline3.git diff --git a/src/Assertions.hs b/src/Assertions.hs index 8efd123..44d793b 100644 --- a/src/Assertions.hs +++ b/src/Assertions.hs @@ -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,18 @@ 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