io-streams 1.0.2.1 → 1.0.2.2
raw patch · 3 files changed
+21/−5 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- io-streams.cabal +4/−1
- src/System/IO/Streams/ByteString.hs +5/−4
- test/System/IO/Streams/Tests/ByteString.hs +12/−0
io-streams.cabal view
@@ -1,5 +1,5 @@ Name: io-streams-Version: 1.0.2.1+Version: 1.0.2.2 License: BSD3 License-file: LICENSE Category: Data, Network, IO-Streams@@ -79,6 +79,9 @@ * support for spawning processes and communicating with them using streams. . /ChangeLog/+ .+ [@1.0.2.2@] Fixed a bug in which \"takeBytes 0\" was erroneously requesting+ input from the wrapped stream. . [@1.0.2.1@] Fixed a compile error on GHC 7.0.x. .
src/System/IO/Streams/ByteString.hs view
@@ -236,8 +236,6 @@ -> IO (InputStream ByteString) takeBytes k0 src = sourceToStream $ source k0 where- fromBS s = if S.null s then Nothing else Just s- eof !n = return $! SP (eofSrc n) Nothing eofSrc !n = Source (eof n) (pb n)@@ -246,15 +244,18 @@ unRead s src return $! source $! n + toEnum (S.length s) - source !k = Source (read src >>= maybe (eof k) chunk) (pb k)+ source !k = Source grab (pb k) where+ grab = if k <= 0+ then eof k+ else read src >>= maybe (eof k) chunk chunk s = let l = toEnum $ S.length s k' = k - l in if k' <= 0 then let (a,b) = S.splitAt (fromEnum k) s in do when (not $ S.null b) $ unRead b src- return $! SP (eofSrc 0) (fromBS a)+ return $! SP (eofSrc 0) (Just a) else return $! SP (source k') (Just s)
test/System/IO/Streams/Tests/ByteString.hs view
@@ -11,6 +11,7 @@ import Data.List hiding (lines, takeWhile, unlines, unwords, words)+import Data.Maybe (isJust) import Data.Monoid import Prelude hiding (lines, read, takeWhile, unlines,@@ -20,6 +21,7 @@ import System.IO.Streams hiding (filter, intersperse, mapM_) import System.IO.Streams.Tests.Common+import System.Timeout import Test.Framework import Test.Framework.Providers.HUnit import Test.Framework.Providers.QuickCheck2@@ -40,6 +42,7 @@ , testTakeBytes , testTakeBytes2 , testTakeBytes3+ , testTakeBytes4 , testThrowIfProducesMoreThan , testThrowIfProducesMoreThan2 , testThrowIfProducesMoreThan3@@ -176,6 +179,15 @@ m <- read is assertEqual "takeBytes3" Nothing m+++------------------------------------------------------------------------------+testTakeBytes4 :: Test+testTakeBytes4 = testCase "bytestring/takeBytes4" $ do+ is <- makeInputStream (threadDelay 20000000 >> return Nothing)+ >>= takeBytes 0+ mb <- timeout 100000 $ toList is+ assertBool "takeBytes4" $ isJust mb ------------------------------------------------------------------------------