packages feed

scientific 0.3.3.1 → 0.3.3.2

raw patch · 4 files changed

+31/−12 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

changelog view
@@ -1,3 +1,9 @@+0.3.3.2+	* Fix parsing of empty digit string (#21).++0.3.3.1+	* Allow newer tasty, tasty-hunit and criterion.+ 0.3.3.0 	* Add the isFloating or isInteger predicates. 	  Courtesy of Zejun Wu (@watashi).
scientific.cabal view
@@ -1,5 +1,5 @@ name:                scientific-version:             0.3.3.1+version:             0.3.3.2 synopsis:            Numbers represented using scientific notation description:   @Data.Scientific@ provides a space efficient and arbitrary precision
src/Data/Scientific.hs view
@@ -588,15 +588,20 @@      return (scientific signedCoeff    expnt)  foldDigits :: (a -> Int -> a) -> a -> ReadP a-foldDigits f z = ReadP.look >>= go z-    where-      go !a [] = return a-      go !a (c:cs)-          | isDecimal c = do-              _ <- ReadP.get-              let digit = ord c - 48-              go (f a digit) cs-          | otherwise = return a+foldDigits f z = do+    c <- ReadP.satisfy isDecimal+    let digit = ord c - 48+        a = f z digit++    ReadP.look >>= go a+  where+    go !a [] = return a+    go !a (c:cs)+        | isDecimal c = do+            _ <- ReadP.get+            let digit = ord c - 48+            go (f a digit) cs+        | otherwise = return a  isDecimal :: Char -> Bool isDecimal c = c >= '0' && c <= '9'
test/test.hs view
@@ -15,7 +15,7 @@ import           Data.Scientific                    as Scientific import           Test.Tasty import           Test.Tasty.Runners.AntXML-import           Test.Tasty.HUnit+import           Test.Tasty.HUnit                          (testCase, (@?=), Assertion) import qualified Test.SmallCheck                    as SC import qualified Test.SmallCheck.Series             as SC import qualified Test.Tasty.SmallCheck              as SC  (testProperty)@@ -41,6 +41,12 @@        (QC.forAll normalizedScientificGen    $ \s ->             s /= 0 QC.==> abs (Scientific.coefficient s) `mod` 10 /= 0) +  , testGroup "Parsing"+    [ testCase "reads \"\""     $ testReads ""     []+    , testCase "reads \"1.\""   $ testReads "1."   [(1.0, ".")]+    , testCase "reads \"1.2e\"" $ testReads "1.2e" [(1.0, ".2e"), (1.2, "e")]+    ]+   , testGroup "Formatting"     [ testProperty "read . show == id" $ \s -> read (show s) === s @@ -48,7 +54,6 @@         (SC.over   nonNegativeScientificSeries toDecimalDigits_laws)         (QC.forAll nonNegativeScientificGen    toDecimalDigits_laws) -     , testGroup "Builder"       [ testProperty "Text" $ \s ->           formatScientific B.Generic Nothing s ==@@ -180,6 +185,9 @@  testMain :: TestTree -> IO () testMain = defaultMainWithIngredients (antXMLRunner:defaultIngredients)++testReads :: String -> [(Scientific, String)] -> Assertion+testReads inp out = reads inp @?= out  genericIsFloating :: RealFrac a => a -> Bool genericIsFloating a = fromInteger (floor a :: Integer) /= a