From aebb9084065fab1f1d7714a5da49032a88150685 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 30 Apr 2011 20:57:38 -0400 Subject: [PATCH] Move the almost_equals function into the Comparisons module. --- src/Comparisons.hs | 10 ++++++++++ src/Tests/Tetrahedron.hs | 8 +------- 2 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 src/Comparisons.hs 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 -- 2.43.2