Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactor test suite so the library can be installed without testing d…

…ependencies
  • Loading branch information...
commit 08019de0d0707b347fae332d80619eb9f22aedf8 1 parent 34b68d1
@DanBurton DanBurton authored
View
45 Data/Number/BigFloat.hs
@@ -5,13 +5,10 @@
-- The numbers are stored in base 10.
module Data.Number.BigFloat(
BigFloat,
- Epsilon, Eps1, EpsDiv10, Prec10, Prec50, PrecPlus20,
- bigfloat_properties
+ Epsilon, Eps1, EpsDiv10, Prec10, Prec50, PrecPlus20
) where
-import Numeric(showSigned)
-import Test.Framework (Test, testGroup)
-import Test.Framework.Providers.QuickCheck2 (testProperty)
+import Numeric(showSigned)
import Data.Number.Fixed
import qualified Data.Number.FixedFunctions as F
@@ -111,41 +108,3 @@ toFloat1 :: (Epsilon e) => (Rational -> Rational -> Rational) ->
toFloat1 f x@(BF m e) =
fromRational $ f (precision m * scl) (toRational m * scl)
where scl = base^^e
-
-
-
--- * Quickcheck Properties
-
-fromReal :: (RealFrac a, Fractional b) => a -> b
-fromReal = fromRational . toRational
-
-prop_bigfloat_double_agree_equality :: Double -> Bool
-prop_bigfloat_double_agree_equality dbl =
- dbl == bf1
- where
- -- Convert dbl to a BigFloat.
- bf1' = fromReal dbl :: BigFloat Prec50
- -- And convert it back.
- bf1 = fromReal bf1' :: Double
-
-
-prop_bigfloat_double_agree_ordering :: Double -> Double -> Bool
-prop_bigfloat_double_agree_ordering dbl1 dbl2 =
- compare dbl1 dbl2 == compare bf1 bf2
- where
- -- Convert dbl1,dbl2 to BigFloat.
- bf1 = fromReal dbl1 :: BigFloat Prec50
- bf2 = fromReal dbl2 :: BigFloat Prec50
-
-
-bigfloat_properties :: Test.Framework.Test
-bigfloat_properties =
- testGroup "BigFloat Properties" [
- testProperty
- "bigfloat/double agree (equality)"
- prop_bigfloat_double_agree_equality,
-
- testProperty
- "bigfloat/double agree (ordering)"
- prop_bigfloat_double_agree_ordering
- ]
View
38 Test/Data/Number/BigFloat.hs
@@ -0,0 +1,38 @@
+module Test.Data.Number.BigFloat (bigfloat_properties) where
+
+import Data.Number.BigFloat (BigFloat, Prec50)
+
+import Test.Framework (Test, testGroup)
+import Test.Framework.Providers.QuickCheck2 (testProperty)
+
+
+prop_bigfloat_double_agree_equality :: Double -> Bool
+prop_bigfloat_double_agree_equality dbl =
+ dbl == bf1
+ where
+ -- Convert dbl to a BigFloat.
+ bf1' = realToFrac dbl :: BigFloat Prec50
+ -- And convert it back.
+ bf1 = realToFrac bf1' :: Double
+
+
+prop_bigfloat_double_agree_ordering :: Double -> Double -> Bool
+prop_bigfloat_double_agree_ordering dbl1 dbl2 =
+ compare dbl1 dbl2 == compare bf1 bf2
+ where
+ -- Convert dbl1,dbl2 to BigFloat.
+ bf1 = realToFrac dbl1 :: BigFloat Prec50
+ bf2 = realToFrac dbl2 :: BigFloat Prec50
+
+
+bigfloat_properties :: Test.Framework.Test
+bigfloat_properties =
+ testGroup "BigFloat Properties" [
+ testProperty
+ "bigfloat/double agree (equality)"
+ prop_bigfloat_double_agree_equality,
+
+ testProperty
+ "bigfloat/double agree (ordering)"
+ prop_bigfloat_double_agree_ordering
+ ]
View
22 numbers.cabal
@@ -28,25 +28,25 @@ source-repository this
Library
Build-Depends:
- base >= 3 && < 5,
- -- Additional test dependencies.
- QuickCheck == 2.*,
- test-framework == 0.6.*,
- test-framework-quickcheck2 == 0.2.*
+ base >= 3 && < 5
Exposed-modules:
Data.Number.Symbolic Data.Number.Dif
Data.Number.CReal Data.Number.Fixed
Data.Number.Interval Data.Number.BigFloat
Data.Number.Natural
- Other-modules: Data.Number.Vectorspace Data.Number.FixedFunctions
+ Other-modules:
+ Data.Number.Vectorspace
+ Data.Number.FixedFunctions
Ghc-Options:
- -fwarn-missing-signatures
- -fwarn-orphans
- -fwarn-tabs
- -fwarn-incomplete-record-updates
- -fwarn-monomorphism-restriction
+ -Wall
+ -fno-warn-name-shadowing
+ -fno-warn-unused-binds
+ -fno-warn-unused-matches
+ -fno-warn-incomplete-patterns
+ -fno-warn-overlapping-patterns
+ -fno-warn-type-defaults
test-suite testsuite
type: exitcode-stdio-1.0
View
2  test/TestSuite.hs
@@ -6,7 +6,7 @@ import Test.Framework (
defaultMain,
)
-import Data.Number.BigFloat (bigfloat_properties)
+import Test.Data.Number.BigFloat (bigfloat_properties)
main :: IO ()
main = defaultMain tests
Please sign in to comment.
Something went wrong with that request. Please try again.