From: Michael Orlitzky Date: Sun, 1 May 2011 00:57:38 +0000 (-0400) Subject: Move the almost_equals function into the Comparisons module. X-Git-Tag: 0.0.1~358 X-Git-Url: http://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=aebb9084065fab1f1d7714a5da49032a88150685;p=spline3.git Move the almost_equals function into the Comparisons module. --- diff --git a/src/Comparisons.hs b/src/Comparisons.hs new file mode 100644 index 0000000..f4462a0 --- /dev/null +++ b/src/Comparisons.hs @@ -0,0 +1,10 @@ +module Comparisons +where + + +almost_equals :: Double -> Double -> Bool +almost_equals x y = (abs (x - y)) < 0.0001 + +infix 4 ~= +(~=) :: Double -> Double -> Bool +(~=) = almost_equals diff --git a/src/Tests/Tetrahedron.hs b/src/Tests/Tetrahedron.hs index 98edf63..bc13876 100644 --- a/src/Tests/Tetrahedron.hs +++ b/src/Tests/Tetrahedron.hs @@ -4,6 +4,7 @@ where import Test.HUnit import Test.QuickCheck +import Comparisons import Cube import Point import Tests.Cube() @@ -19,13 +20,6 @@ instance Arbitrary Tetrahedron where rnd_v3 <- arbitrary :: Gen Point return (Tetrahedron rnd_c0 rnd_v0 rnd_v1 rnd_v2 rnd_v3) -almost_equals :: Double -> Double -> Bool -almost_equals x y = (abs (x - y)) < 0.0001 - -(~=) :: Double -> Double -> Bool -(~=) = almost_equals - - -- HUnit Tests -- Since p0, p1, p2 are in clockwise order, we expect the volume here