X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FAssertions.hs;h=f6152d74cb0c867b96aaf708640b5190109b7d6d;hb=a499efdb0e215ac424fe7c38a52430daebefc22b;hp=33b79b9b8ba68bb3dabc2002ad284498705bc335;hpb=fa5503e32f29d7258e79744e7b2fc7ee49c923d5;p=spline3.git diff --git a/src/Assertions.hs b/src/Assertions.hs index 33b79b9..f6152d7 100644 --- a/src/Assertions.hs +++ b/src/Assertions.hs @@ -1,32 +1,36 @@ -- | 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 +-- +module Assertions ( + assertAlmostEqual, + assertTrue ) where -import Control.Monad (unless) -import Test.HUnit +import Control.Monad ( unless ) +import Test.Tasty.HUnit ( + Assertion, + assertBool, + assertFailure ) + +import Comparisons ( (~=) ) -import Comparisons -import Point -- | An HUnit assertion that wraps the almost_equals function. Stolen --- from the definition of 'assertEqual' in Test\/HUnit\/Base.hs. -assertAlmostEqual :: String -> Double -> Double -> Assertion +-- from the definition of 'assertEqual' in Test\/Tasty\/HUnit\/Orig.hs. +-- +assertAlmostEqual :: String -- ^ The message prefix + -> Double -- ^ The expected value + -> Double -- ^ The actual value + -> 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 --- | An HUnit assertion that wraps the is_close function. Stolen --- 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 -- | It's asinine that this doesn't exist already. +-- assertTrue :: String -> Bool -> Assertion assertTrue = assertBool