blaze-textual 0.2.0.2 → 0.2.0.3
raw patch · 3 files changed
+96/−2 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- README.markdown +43/−1
- blaze-textual.cabal +7/−1
- tests/QC.hs +46/−0
README.markdown view
@@ -1,9 +1,51 @@-# Welcome to aeson+# Welcome to blaze-textual blaze-textual is a fast Haskell library for rendering common Haskell datatypes in text form using the [blaze-builder](http://hackage.haskell.org/package/blaze-builder) library.++# Important note for users of GHCi and Template Haskell++To achieve excellent performance for rendering floating point numbers,+this package uses the+[double-conversion](http://hackage.haskell.org/package/double-conversion)+package.++Unfortunately, due to bugs in GHC, some uses of GHCi and Template+Haskell can crash if this package is loaded.++* [5289: Can't use ghci with a library linked against+ libstdc++](http://hackage.haskell.org/trac/ghc/ticket/5289) (fixed+ in GHC 7.2.1).++* [5386: GHCi crashes with SIGFPE when using double-conversion+ package](http://hackage.haskell.org/trac/ghc/ticket/5386) (not yet+ fixed at the time of writing)++If you are affected by these problems, you should expect the 5289+crash to look like this:++ Loading package double-conversion-0.2.0.0 ... can't load .so/.DLL for: stdc++++The 5386 crash causes GHCi to die with a floating point exception+(SIGFPE).++To work around these bugs, this package includes an alternative,+slower, floating point conversion that is written in pure Haskell.+Because it is 10 times slower than the double-conversion package, it+is not the default.++To use it, reinstall this package by passing the `native` flag to+`cabal`:++ cabal install -fnative++Afterwards, you will also need to reinstall any downstream packages+that depend on this one, e.g. the [aeson JSON+library](http://hackage.haskell.org/package/aeson):++ cabal install aeson --reinstall # Join in!
blaze-textual.cabal view
@@ -1,5 +1,5 @@ name: blaze-textual-version: 0.2.0.2+version: 0.2.0.3 license: BSD3 license-file: LICENSE category: Text@@ -15,9 +15,15 @@ description: A library for efficiently rendering Haskell datatypes to bytestrings.+ .+ /Note/: if you use GHCi or Template Haskell, please see the+ @README@ file for important details about building this package,+ and other packages that depend on it:+ <https://github.com/mailrank/blaze-textual#readme> extra-source-files: README.markdown+ tests/*.hs flag developer description: operate in developer mode
+ tests/QC.hs view
@@ -0,0 +1,46 @@+module Main (main) where++import Blaze.ByteString.Builder (Builder, toByteString)+import Blaze.Text (double, float, integral)+import Data.Int (Int8, Int16, Int32, Int64)+import Data.Word (Word, Word8, Word16, Word32, Word64)+import Test.Framework (Test, defaultMain, testGroup)+import Test.Framework.Providers.QuickCheck2 (testProperty)+import qualified Data.ByteString.Char8 as B++-- Integral values should be rendered exactly as Haskell does.+t_integral :: Integral a => a -> a -> Bool+t_integral _ i = toByteString (integral i) == B.pack (show i)++-- This package doesn't render floating point numbers exactly as+-- Haskell does, but the numbers it renders should read back exactly.+-- So that's the property we check.+t_real :: (RealFloat a, Read a) => (a -> Builder) -> a -> a -> Bool+t_real f i j =+ case read (B.unpack . toByteString . f $ ij) of+ r | isNaN r -> isNaN ij+ | isInfinite r -> isInfinite ij && signum r == signum ij+ | otherwise -> r == ij+ where ij = i / j++main :: IO ()+main = defaultMain tests++tests :: [Test]+tests = [+ testGroup "int" [ testProperty "Integer" $ t_integral (undefined::Integer)+ , testProperty "Int" $ t_integral (undefined::Int)+ , testProperty "Int8" $ t_integral (undefined::Int8)+ , testProperty "Int16" $ t_integral (undefined::Int16)+ , testProperty "Int32" $ t_integral (undefined::Int32)+ , testProperty "Int64" $ t_integral (undefined::Int64)+ ]+ , testGroup "word" [ testProperty "Word" $ t_integral (undefined::Word)+ , testProperty "Word8" $ t_integral (undefined::Word8)+ , testProperty "Word16" $ t_integral (undefined::Word16)+ , testProperty "Word32" $ t_integral (undefined::Word32)+ , testProperty "Word64" $ t_integral (undefined::Word64)+ ]+ , testProperty "Double" $ t_real double+ , testProperty "Float" $ t_real float+ ]