summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBasVanDijk <>2017-08-30 12:50:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2017-08-30 12:50:00 (GMT)
commit511deb5208233abf51a499e55de05735f05836ae (patch)
tree402c057187cb6a0636db9e8d09cf4a428db98d69
parent8d2e9bdb43874b1ebe329509a2184bc6c75be004 (diff)
version 0.3.5.2HEAD0.3.5.2master
-rw-r--r--changelog4
-rw-r--r--scientific.cabal3
-rw-r--r--test/test.hs12
3 files changed, 17 insertions, 2 deletions
diff --git a/changelog b/changelog
index 39848f4..8815853 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,7 @@
+0.3.5.2
+ * Remove unused ghc-prim dependency.
+ * Added unit tests for read and scientificP
+
0.3.5.1
* Replace use of Vector from vector with Array from primitive.
diff --git a/scientific.cabal b/scientific.cabal
index a915ec0..d967212 100644
--- a/scientific.cabal
+++ b/scientific.cabal
@@ -1,5 +1,5 @@
name: scientific
-version: 0.3.5.1
+version: 0.3.5.2
synopsis: Numbers represented using scientific notation
description:
@Data.Scientific@ provides the number type 'Scientific'. Scientific numbers are
@@ -67,7 +67,6 @@ library
other-extensions: DeriveDataTypeable, BangPatterns
ghc-options: -Wall
build-depends: base >= 4.3 && < 4.11
- , ghc-prim
, integer-logarithms >= 1 && <1.1
, deepseq >= 1.3 && < 1.5
, text >= 0.8 && < 1.3
diff --git a/test/test.hs b/test/test.hs
index 7a6e74d..990fa34 100644
--- a/test/test.hs
+++ b/test/test.hs
@@ -34,6 +34,7 @@ import Numeric ( floatToDigits )
import qualified Data.ByteString.Lazy.Char8 as BLC8
import qualified Data.ByteString.Builder.Scientific as B
import qualified Data.ByteString.Builder as B
+import Text.ParserCombinators.ReadP (readP_to_S)
main :: IO ()
main = testMain $ testGroup "scientific"
@@ -55,6 +56,11 @@ main = testMain $ testGroup "scientific"
, testCase "reads \"(1.3 )\"" $ testReads "(1.3 )" [(1.3, "")]
, testCase "reads \"((1.3))\"" $ testReads "((1.3))" [(1.3, "")]
, testCase "reads \" 1.3\"" $ testReads " 1.3" [(1.3, "")]
+ , testCase "read \" ( (( -1.0e+3 ) ))\"" $ testRead " ( (( -1.0e+3 ) ))" (-1000.0)
+ , testCase "scientificP \"3\"" $ testScientificP "3" [(3.0, "")]
+ , testCase "scientificP \"3.0e2\"" $ testScientificP "3.0e2" [(3.0, "e2"), (300.0, "")]
+ , testCase "scientificP \"+3.0e+2\"" $ testScientificP "+3.0e+2" [(3.0, "e+2"), (300.0, "")]
+ , testCase "scientificP \"-3.0e-2\"" $ testScientificP "-3.0e-2" [(-3.0, "e-2"), (-3.0e-2, "")]
]
, testGroup "Formatting"
@@ -218,6 +224,12 @@ testMain = defaultMainWithIngredients (antXMLRunner:defaultIngredients)
testReads :: String -> [(Scientific, String)] -> Assertion
testReads inp out = reads inp @?= out
+testRead :: String -> Scientific -> Assertion
+testRead inp out = read inp @?= out
+
+testScientificP :: String -> [(Scientific, String)] -> Assertion
+testScientificP inp out = readP_to_S Scientific.scientificP inp @?= out
+
genericIsFloating :: RealFrac a => a -> Bool
genericIsFloating a = fromInteger (floor a :: Integer) /= a