bytestring 0.10.4.0 → 0.10.4.1
raw patch · 15 files changed
+184/−261 lines, 15 filesdep +HUnitdep +test-frameworkdep +test-framework-hunitdep ~QuickCheckdep ~basedep ~deepseq
Dependencies added: HUnit, test-framework, test-framework-hunit, test-framework-quickcheck2
Dependency ranges changed: QuickCheck, base, deepseq
Files
- Data/ByteString.hs +0/−3
- Data/ByteString/Builder.hs +4/−11
- Data/ByteString/Builder/ASCII.hs +7/−1
- Data/ByteString/Builder/Internal.hs +1/−1
- Data/ByteString/Builder/Prim/Internal.hs +2/−2
- Data/ByteString/Internal.hs +37/−7
- Data/ByteString/Lazy.hs +26/−14
- Data/ByteString/Lazy/Internal.hs +1/−1
- Data/ByteString/Short/Internal.hs +1/−1
- Data/ByteString/Unsafe.hs +4/−4
- README +0/−205
- README.md +38/−0
- bytestring.cabal +37/−10
- tests/Regressions.hs +25/−0
- tests/builder/Data/ByteString/Builder/Tests.hs +1/−1
Data/ByteString.hs view
@@ -1937,9 +1937,6 @@ -- files > half of available memory, this may lead to memory exhaustion. -- Consider using 'readFile' in this case. ----- As with 'hGet', the string representation in the file is assumed to--- be ISO-8859-1.--- -- The Handle is closed once the contents have been read, -- or if an exception is thrown. --
Data/ByteString/Builder.hs view
@@ -226,15 +226,13 @@ , doubleLE -- ** Character encodings+ -- | Conversion from 'Char' and 'String' into 'Builder's in various encodings. -- *** ASCII (Char7) -- | The ASCII encoding is a 7-bit encoding. The /Char7/ encoding implemented here -- works by truncating the Unicode codepoint to 7-bits, prefixing it -- with a leading 0, and encoding the resulting 8-bits as a single byte.- -- For the codepoints 0-127 this corresponds the ASCII encoding. In- -- "Data.ByteString.Builder.ASCII", we also provide efficient- -- implementations of ASCII-based encodings of numbers (e.g., decimal and- -- hexadecimal encodings).+ -- For the codepoints 0-127 this corresponds the ASCII encoding. , char7 , string7 @@ -242,19 +240,14 @@ -- | The ISO/IEC 8859-1 encoding is an 8-bit encoding often known as Latin-1. -- The /Char8/ encoding implemented here works by truncating the Unicode codepoint -- to 8-bits and encoding them as a single byte. For the codepoints 0-255 this corresponds- -- to the ISO/IEC 8859-1 encoding. Note that you can also use- -- the functions from "Data.ByteString.Builder.ASCII", as the ASCII encoding- -- and ISO/IEC 8859-1 are equivalent on the codepoints 0-127.+ -- to the ISO/IEC 8859-1 encoding. , char8 , string8 -- *** UTF-8 -- | The UTF-8 encoding can encode /all/ Unicode codepoints. We recommend -- using it always for encoding 'Char's and 'String's unless an application- -- really requires another encoding. Note that you can also use the- -- functions from "Data.ByteString.Builder.ASCII" for UTF-8 encoding,- -- as the ASCII encoding is equivalent to the UTF-8 encoding on the Unicode- -- codepoints 0-127.+ -- really requires another encoding. , charUtf8 , stringUtf8
Data/ByteString/Builder/ASCII.hs view
@@ -14,7 +14,13 @@ -- module Data.ByteString.Builder.ASCII (- -- ** ASCII text+ -- ** Formatting numbers as text+ -- | Formatting of numbers as ASCII text.+ --+ -- Note that you can also use these functions for the ISO/IEC 8859-1 and+ -- UTF-8 encodings, as the ASCII encoding is equivalent on the + -- codepoints 0-127.+ -- *** Decimal numbers -- | Decimal encoding of numbers using ASCII encoded characters. int8Dec
Data/ByteString/Builder/Internal.hs view
@@ -1,5 +1,5 @@ {-# LANGUAGE ScopedTypeVariables, CPP, BangPatterns, RankNTypes #-}-#if __GLASGOW_HASKELL__ >= 701+#if __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Unsafe #-} #endif {-# OPTIONS_HADDOCK hide #-}
Data/ByteString/Builder/Prim/Internal.hs view
@@ -1,5 +1,5 @@ {-# LANGUAGE ScopedTypeVariables, CPP, BangPatterns #-}-#if __GLASGOW_HASKELL__ >= 701+#if __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Unsafe #-} #endif {-# OPTIONS_HADDOCK hide #-}@@ -69,7 +69,7 @@ import Foreign import Prelude hiding (maxBound) -#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 611+#if !(__GLASGOW_HASKELL__ >= 612) -- ghc-6.10 and older do not support {-# INLINE CONLIKE #-} #define CONLIKE #endif
Data/ByteString/Internal.hs view
@@ -2,7 +2,7 @@ #if __GLASGOW_HASKELL__ {-# LANGUAGE UnliftedFFITypes, MagicHash, UnboxedTuples, DeriveDataTypeable #-}-#if __GLASGOW_HASKELL__ >= 701+#if __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Unsafe #-} #endif #endif@@ -530,12 +530,21 @@ concat [bs] = bs concat bss0 = unsafeCreate totalLen $ \ptr -> go bss0 ptr where- totalLen = List.sum [ len | (PS _ _ len) <- bss0 ]+ totalLen = checkedSum "concat" [ len | (PS _ _ len) <- bss0 ] go [] !_ = return () go (PS fp off len:bss) !ptr = do withForeignPtr fp $ \p -> memcpy ptr (p `plusPtr` off) len go bss (ptr `plusPtr` len) +-- | Add a list of non-negative numbers. Errors out on overflow.+checkedSum :: String -> [Int] -> Int+checkedSum fun = go 0+ where go !a (x:xs)+ | ax >= 0 = go ax xs+ | otherwise = overflowError fun+ where ax = a + x+ go a _ = a+ ------------------------------------------------------------------------ -- | Conversion between 'Word8' and 'Char'. Should compile to a no-op.@@ -579,13 +588,35 @@ c == '\xa0' {-# INLINE isSpaceChar8 #-} +overflowError :: String -> a+overflowError fun = error $ "Data.ByteString." ++ fun ++ ": size overflow"+ ------------------------------------------------------------------------ --- | Just like unsafePerformIO, but we inline it. Big performance gains as--- it exposes lots of things to further inlining. /Very unsafe/. In--- particular, you should do no memory allocation inside an--- 'inlinePerformIO' block. On Hugs this is just @unsafePerformIO@.+-- | This \"function\" has a superficial similarity to 'unsafePerformIO' but+-- it is in fact a malevolent agent of chaos. It unpicks the seams of reality+-- (and the 'IO' monad) so that the normal rules no longer apply. It lulls you+-- into thinking it is reasonable, but when you are not looking it stabs you+-- in the back and aliases all of your mutable buffers. The carcass of many a+-- seasoned Haskell programmer lie strewn at its feet. --+-- Witness the trail of destruction:+--+-- * <https://github.com/haskell/bytestring/commit/71c4b438c675aa360c79d79acc9a491e7bbc26e7>+--+-- * <https://github.com/haskell/bytestring/commit/210c656390ae617d9ee3b8bcff5c88dd17cef8da>+--+-- * <https://ghc.haskell.org/trac/ghc/ticket/3486>+--+-- * <https://ghc.haskell.org/trac/ghc/ticket/3487>+--+-- * <https://ghc.haskell.org/trac/ghc/ticket/7270>+--+-- Do not talk about \"safe\"! You do not know what is safe!+--+-- Yield not to its blasphemous call! Flee traveller! Flee or you will be+-- corrupted and devoured!+-- {-# INLINE inlinePerformIO #-} inlinePerformIO :: IO a -> a #if defined(__GLASGOW_HASKELL__)@@ -657,4 +688,3 @@ foreign import ccall unsafe "static fpstring.h fps_count" c_count :: Ptr Word8 -> CULong -> Word8 -> IO CULong-
Data/ByteString/Lazy.hs view
@@ -14,7 +14,7 @@ -- Maintainer : dons00@gmail.com, duncan@community.haskell.org -- Stability : stable -- Portability : portable--- +-- -- A time and space-efficient implementation of lazy byte vectors -- using lists of packed 'Word8' arrays, suitable for high performance -- use, both in terms of large data quantities, or high speed@@ -263,7 +263,7 @@ singleton w = Chunk (S.singleton w) Empty {-# INLINE singleton #-} --- | /O(n)/ Convert a '[Word8]' into a 'ByteString'. +-- | /O(n)/ Convert a '[Word8]' into a 'ByteString'. pack :: [Word8] -> ByteString pack = packBytes @@ -295,7 +295,7 @@ toStrict (Chunk c Empty) = c toStrict cs0 = S.unsafeCreate totalLen $ \ptr -> go cs0 ptr where- totalLen = foldlChunks (\a c -> a + S.length c) 0 cs0+ totalLen = checkedSum "Lazy.toStrict" . L.map S.length . toChunks $ cs0 go Empty !_ = return () go (Chunk (S.PS fp off len) cs) !destptr =@@ -303,6 +303,18 @@ S.memcpy destptr (p `plusPtr` off) len go cs (destptr `plusPtr` len) +-- just here in 0.10.4.x, in later version it's exported from .Internal+checkedSum :: String -> [Int] -> Int+checkedSum fun = go 0+ where go !a (x:xs)+ | ax >= 0 = go ax xs+ | otherwise = overflowError fun+ where ax = a + x+ go a _ = a++overflowError :: String -> a+overflowError fun = error $ "Data.ByteString." ++ fun ++ ": size overflow"+ ------------------------------------------------------------------------ {-@@ -479,7 +491,7 @@ foldl' f z = go z where go a _ | a `seq` False = undefined go a Empty = a- go a (Chunk c cs) = go (S.foldl f a c) cs+ go a (Chunk c cs) = go (S.foldl' f a c) cs {-# INLINE foldl' #-} -- | 'foldr', applied to a binary operator, a starting value@@ -689,7 +701,7 @@ splitAt' _ Empty = (Empty, Empty) splitAt' n (Chunk c cs) = if n < fromIntegral (S.length c)- then (Chunk (S.take (fromIntegral n) c) Empty + then (Chunk (S.take (fromIntegral n) c) Empty ,Chunk (S.drop (fromIntegral n) c) cs) else let (cs', cs'') = splitAt' (n - fromIntegral (S.length c)) cs in (Chunk c cs', cs'')@@ -738,7 +750,7 @@ -- | 'breakByte' breaks its ByteString argument at the first occurence -- of the specified byte. It is more efficient than 'break' as it is -- implemented with @memchr(3)@. I.e.--- +-- -- > break (=='c') "abcd" == breakByte 'c' "abcd" -- breakByte :: Word8 -> ByteString -> (ByteString, ByteString)@@ -798,12 +810,12 @@ -- > split '\n' "a\nb\nd\ne" == ["a","b","d","e"] -- > split 'a' "aXaXaXa" == ["","X","X","X",""] -- > split 'x' "x" == ["",""]--- +-- -- and -- -- > intercalate [c] . split c == id -- > split == splitWith . (==)--- +-- -- As for all splitting functions in this library, this function does -- not copy the substrings, it just constructs new 'ByteStrings' that -- are slices of the original.@@ -821,7 +833,7 @@ {- -- | Like 'splitWith', except that sequences of adjacent separators are -- treated as a single separator. eg.--- +-- -- > tokens (=='a') "aabbaca" == ["bb","c"] -- tokens :: (Word8 -> Bool) -> ByteString -> [ByteString]@@ -888,13 +900,13 @@ index cs0 i = index' cs0 i where index' Empty n = moduleError "index" ("index too large: " ++ show n) index' (Chunk c cs) n- | n >= fromIntegral (S.length c) = + | n >= fromIntegral (S.length c) = index' cs (n - fromIntegral (S.length c)) | otherwise = S.unsafeIndex c (fromIntegral n) -- | /O(n)/ The 'elemIndex' function returns the index of the first -- element in the given 'ByteString' which is equal to the query--- element, or 'Nothing' if there is no such element. +-- element, or 'Nothing' if there is no such element. -- This implementation uses memchr(3). elemIndex :: Word8 -> ByteString -> Maybe Int64 elemIndex w cs0 = elemIndex' 0 cs0@@ -910,7 +922,7 @@ -- element, or 'Nothing' if there is no such element. The following -- holds: ----- > elemIndexEnd c xs == +-- > elemIndexEnd c xs == -- > (-) (length xs - 1) `fmap` elemIndex c (reverse xs) -- elemIndexEnd :: Word8 -> ByteString -> Maybe Int@@ -1057,7 +1069,7 @@ -- | /O(n)/ The 'isSuffixOf' function takes two ByteStrings and returns 'True' -- iff the first is a suffix of the second.--- +-- -- The following holds: -- -- > isSuffixOf x y == reverse x `isPrefixOf` reverse y@@ -1142,7 +1154,7 @@ -- Lazy ByteString IO -- -- Rule for when to close: is it expected to read the whole file?--- If so, close when done. +-- If so, close when done. -- -- | Read entire handle contents /lazily/ into a 'ByteString'. Chunks
Data/ByteString/Lazy/Internal.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE CPP, ForeignFunctionInterface, BangPatterns #-} #if __GLASGOW_HASKELL__ {-# LANGUAGE DeriveDataTypeable #-}-#if __GLASGOW_HASKELL__ >= 701+#if __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Unsafe #-} #endif #endif
Data/ByteString/Short/Internal.hs view
@@ -2,7 +2,7 @@ ForeignFunctionInterface, MagicHash, UnboxedTuples, UnliftedFFITypes #-} {-# OPTIONS_GHC -fno-warn-name-shadowing #-}-#if __GLASGOW_HASKELL__ >= 701+#if __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Unsafe #-} #endif {-# OPTIONS_HADDOCK hide #-}
Data/ByteString/Unsafe.hs view
@@ -224,7 +224,7 @@ -- collected by Haskell. This operation has /O(1)/ complexity as we -- already know the final size, so no /strlen(3)/ is required. ----- This funtion is /unsafe/. If the original @CStringLen@ is later+-- This function is /unsafe/. If the original @CStringLen@ is later -- modified, this change will be reflected in the resulting @ByteString@, -- breaking referential transparency. --@@ -236,7 +236,7 @@ -- | /O(n)/ Build a @ByteString@ from a malloced @CString@. This value will -- have a @free(3)@ finalizer associated to it. ----- This funtion is /unsafe/. If the original @CString@ is later+-- This function is /unsafe/. If the original @CString@ is later -- modified, this change will be reflected in the resulting @ByteString@, -- breaking referential transparency. --@@ -250,10 +250,10 @@ len <- c_strlen cstr return $! PS fp 0 (fromIntegral len) --- | /O(n)/ Build a @ByteString@ from a malloced @CStringLen@. This+-- | /O(1)/ Build a @ByteString@ from a malloced @CStringLen@. This -- value will have a @free(3)@ finalizer associated to it. ----- This funtion is /unsafe/. If the original @CString@ is later+-- This function is /unsafe/. If the original @CString@ is later -- modified, this change will be reflected in the resulting @ByteString@, -- breaking referential transparency. --
− README
@@ -1,205 +0,0 @@-------------------------------------------------------------------------- ByteString : Fast, packed strings of bytes---------------------------------------------------------------------------This library provides the Data.ByteString library -- strict and lazy-byte arrays manipulable as strings -- providing very time and space-efficient string and IO operations.--For very large data requirements, or constraints on heap size,-Data.ByteString.Lazy is provided, a lazy list of bytestring chunks.-Efficient processing of multi-gigabyte data can be achieved this way.--Requirements:- > Cabal- > GHC 6.4 or greater, or hugs--Building:- > runhaskell Setup.lhs configure --prefix=/f/g- > runhaskell Setup.lhs build- > runhaskell Setup.lhs install--After installation, you can run the testsuite as follows:- - > cd tests ; make- or- > cd tests ; make hugs--For the full test and benchmark suite, you need GHC and Hugs:-- > cd tests ; make everything--Authors:- ByteString was derived from the GHC PackedString library,- originally written by Bryan O'Sullivan, and then by Simon Marlow.- It was adapted, and greatly extended for darcs by David Roundy, and- others. Don Stewart cleaned up and further extended the implementation.- Duncan Coutts wrote much of the .Lazy code. Don, Duncan and Roman- Leshchinskiy wrote the fusion system.----------------------------------------------------------------------------Performance, some random numbers (with GHC):--This table compares the performance of common operations ByteString,-from various string libraries.--Size of test data: 21256k, Linux 3.2Ghz P4-- FPS7 SPS PS [a] -++ 0.028 ! ! 1.288 -length 0.000 0.000 0.000 0.131 -pack 0.303 0.502 0.337 - -unpack 3.319* 1.630 7.445 - -compare 0.000 0.000 0.000 0.000 -index 0.000 0.000 0.000 0.000 -map 2.762* 2.917 4.813 7.286 -filter 0.304 2.805 0.954 0.305 -take 0.000 0.000 0.024 0.005 -drop 0.000 0.000 11.768 0.130 -takeWhile 0.000 1.498 0.000 0.000 -dropWhile 0.000 1.985 8.447 0.130 -span 0.000 9.289 11.144 0.131 -break 0.000 9.383 11.268 0.133 -lines 0.052 1.114 1.367 2.790 -unlines 0.048 ! ! 10.950 -words 1.344 2.128 5.644 4.184 -unwords 0.016 ! ! 1.305 -reverse 0.024 12.997 13.018 1.622 -concat 0.000 12.701 11.459 1.163 -cons 0.016 2.064 8.358 0.131 -empty 0.000 0.000 0.000 0.000 -head 0.000 0.000 0.000 0.000 -tail 0.000 0.000 14.490 0.130 -elem 0.000 1.490 0.001 0.000 -last 0.000 - - 0.143 -init 0.000 - - 1.147 -inits 0.414 - - ! -tails 0.460 - - 1.136 -intersperse 0.040 - - 10.517 -any 0.000 - - 0.000 -all 0.000 - - 0.000 -sort 0.168 - - !-maximum 0.024 - - 0.183-minimum 0.025 - - 0.185-replicate 0.000 - - 0.053 -findIndex 0.096-find 0.120 - - 0.000 -elemIndex 0.000 - - 0.000 -elemIndicies 0.008 - - 0.314 -foldl 0.148-spanEnd 0.000-snoc 0.016-filterChar 0.031 -filterNotChar 0.124-join 0.016 -split 0.032 -findIndices 0.408 -splitAt 0.000 -lineIndices 0.029 -breakOn 0.000 -breakSpace 0.000 -splitWith 0.329 -dropSpace 0.000 -dropSpaceEnd 0.000 -joinWithChar 0.017-join / 0.016 -zip 0.960 -zipWith 0.892 -isSubstringOf 0.039 -isPrefixOf 0.000 -isSuffixOf 0.000-count 0.021--Key: FPS6 = FPS 0.6- SPS = Simon Marlow's packedstring prototype- PS = Data.PackedString- [a] = [Char]-- - = no function exists- ! = stack or memory exhaustion----------------------------------------------------------------------------== Stress testing really big strings--Doing some stress testing of FPS, here are some results for 0.5G strings.--3.2Ghz box, 2G physical mem.--Size of test data: 524288k-Size of test data: 524288k- Char8 Word8--Effectively O(1) or O(m) where m < n- all 0.000 0.000 - any 0.000 0.004 - break 0.000 0.000 - breakChar 0.000 0.000 - breakSpace 0.000 - compare 0.000 - concat 0.000 - drop 0.000 - dropSpace 0.000 - dropSpaceEnd 0.000 - dropWhile 0.000 0.000 - elem 0.000 0.000 - elemIndex 0.000 0.000 - elemIndexLast 0.000 0.000 - empty 0.000 - head 0.000 0.000 - index 0.000 0.000 - init 0.000 - last 0.000 0.000 - length 0.000 - notElem 0.000 0.000 - span 0.000 0.000 - spanChar 0.000 0.000 - spanEnd 0.000 0.000 - splitAt 0.000 - tail 0.000 - take 0.000 - takeWhile 0.000 0.000 - isPrefixOf 0.000 - isSuffixOf 0.000 - addr1 0.000 - addr2 0.000 --O(n)- ++ 0.676 - map 6.080 5.868 - cons 0.396 0.396 - snoc 0.400 0.400 - find 3.240 - split 1.204 1.200 - lines 2.000 - foldl 3.804 - unwords 0.552 - reverse 0.884 - findIndex 3.128 - filterChar 0.756 0.732 - filter/='f' 8.265 7.012 - filterNotChar 4.456 3.388 - join 0.400 - sort 4.344 - maximum 0.776 0.764 - minimum 0.772 0.776 - replicate 0.008 0.000 - elemIndices 0.240 0.240 - lineIndices 1.092 - joinWithChar 0.400 0.400 - isSubstringOf 0.052 - count 0.748 --slow O(n)- words 38.722 - group 77.261 - groupBy 96.226 - inits 32.430 - tails 23.225 - findIndices 13.841 15.825 - splitWith 18.445 19.225 - zip 33.926 - zipWith 33.562 --
+ README.md view
@@ -0,0 +1,38 @@+## ByteString: Fast, Packed Strings of Bytes++[](http://travis-ci.org/haskell/bytestring)++This library provides the `Data.ByteString` module -- strict and lazy+byte arrays manipulable as strings -- providing very time/space-efficient +string and IO operations.++For very large data requirements, or constraints on heap size,+`Data.ByteString.Lazy` is provided, a lazy list of bytestring chunks.+Efficient processing of multi-gigabyte data can be achieved this way.++The library also provides `Data.ByteString.Builder` for efficient construction+of `ByteString` values from smaller pieces during binary serialization.++Requirements:++ * Cabal 1.10 or greater+ * cabal-install+ * GHC 6.12 or greater++Building:+```+cabal install+```++You can run the testsuite as follows:+``` +cabal test+```++### Authors+`ByteString` was derived from the GHC `PackedString` library,+originally written by Bryan O'Sullivan, and then by Simon Marlow.+It was adapted and greatly extended for darcs by David Roundy and+others. Don Stewart and Duncan Coutts cleaned up and further extended+the implementation and added the `.Lazy` code. Simon Meier contributed+the `Builder` feature.
bytestring.cabal view
@@ -1,5 +1,5 @@ Name: bytestring-Version: 0.10.4.0+Version: 0.10.4.1 Synopsis: Fast, compact, strict and lazy byte strings with a list interface Description: An efficient compact, immutable byte string type (both strict and lazy)@@ -51,14 +51,13 @@ Author: Don Stewart, Duncan Coutts-Maintainer: Don Stewart <dons00@gmail.com>,- Duncan Coutts <duncan@community.haskell.org>+Maintainer: Duncan Coutts <duncan@community.haskell.org> Homepage: https://github.com/haskell/bytestring Bug-reports: https://github.com/haskell/bytestring/issues Tested-With: GHC==7.8.1, GHC==7.6.3, GHC==7.4.2, GHC==7.0.4, GHC==6.12.3 Build-Type: Simple Cabal-Version: >= 1.10-extra-source-files: README TODO+extra-source-files: README.md TODO source-repository head type: git@@ -67,7 +66,8 @@ source-repository this type: git location: https://github.com/haskell/bytestring- tag: 0.10.4.0+ branch: 0.10.4.x+ tag: 0.10.4.1 flag integer-simple description: Use the simple integer library instead of GMP@@ -158,11 +158,14 @@ TestFramework hs-source-dirs: . tests build-depends: base, ghc-prim, deepseq, random, directory,- QuickCheck >= 2.3 && < 3+ test-framework, test-framework-quickcheck2,+ QuickCheck >= 2.3 && < 2.7 c-sources: cbits/fpstring.c include-dirs: include ghc-options: -fwarn-unused-binds -fno-enable-rewrite-rules+ -threaded -rtsopts+ cpp-options: -DHAVE_TEST_FRAMEWORK=1 default-language: Haskell98 -- older ghc had issues with language pragmas guarded by cpp if impl(ghc < 7)@@ -170,6 +173,26 @@ DeriveDataTypeable, BangPatterns, NamedFieldPuns +test-suite regressions+ -- temporarily disabled as it allocates too much memory+ buildable: False+ type: exitcode-stdio-1.0+ main-is: Regressions.hs+ hs-source-dirs: . tests+ build-depends: base, ghc-prim, deepseq, random, directory,+ test-framework, test-framework-hunit, HUnit+ c-sources: cbits/fpstring.c+ include-dirs: include+ ghc-options: -fwarn-unused-binds+ -fno-enable-rewrite-rules+ -threaded -rtsopts+ default-language: Haskell98+ -- older ghc had issues with language pragmas guarded by cpp+ if impl(ghc < 7)+ default-extensions: CPP, MagicHash, UnboxedTuples,+ DeriveDataTypeable, BangPatterns,+ NamedFieldPuns+ test-suite test-builder type: exitcode-stdio-1.0 hs-source-dirs: . tests tests/builder@@ -181,13 +204,18 @@ build-depends: base, ghc-prim, deepseq,- QuickCheck >= 2.4 && < 3,+ QuickCheck >= 2.4 && < 2.7, byteorder == 1.0.*, dlist == 0.5.*, directory,- mtl >= 2.0 && < 2.2+ mtl >= 2.0 && < 2.2,+ HUnit,+ test-framework,+ test-framework-hunit,+ test-framework-quickcheck2 - ghc-options: -Wall -fwarn-tabs+ ghc-options: -Wall -fwarn-tabs -threaded -rtsopts+ cpp-options: -DHAVE_TEST_FRAMEWORK=1 default-language: Haskell98 -- older ghc had issues with language pragmas guarded by cpp@@ -201,4 +229,3 @@ include-dirs: include includes: fpstring.h install-includes: fpstring.h-
+ tests/Regressions.hs view
@@ -0,0 +1,25 @@+{-# LANGUAGE ScopedTypeVariables #-}++import Control.Exception (SomeException, handle)+import Test.HUnit (assertBool, assertEqual, assertFailure)+import qualified Data.ByteString as B+import qualified Test.Framework as F+import qualified Test.Framework.Providers.HUnit as F++-- Try to generate arguments to concat that are big enough to cause an+-- Int to overflow.+concat_overflow :: IO ()+concat_overflow =+ handle (\(_::SomeException) -> return ()) $+ B.concat (replicate lsize (B.replicate bsize 0)) `seq`+ assertFailure "T.replicate should crash"+ where+ (lsize, bsize) | maxBound == (2147483647::Int) = (2^14, 2^18)+ | otherwise = (2^34, 2^29)++tests :: [F.Test]+tests = [+ F.testCase "concat_overflow" concat_overflow+ ]++main = F.defaultMain tests
tests/builder/Data/ByteString/Builder/Tests.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP, ScopedTypeVariables, BangPatterns #-}+{-# LANGUAGE CPP, FlexibleContexts, ScopedTypeVariables, BangPatterns #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- |