packages feed

streamly-bytestring 0.1.1 → 0.1.2

raw patch · 4 files changed

+17/−3 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Changelog.md view
@@ -1,5 +1,9 @@ # Changelog for streamly-bytestring +## 0.1.2++* Fix memory bug in Strict.toArray+ ## 0.1.1  * Add `fromChunksIO` function to `Streamly.External.ByteString.Lazy` module.
src/Streamly/External/ByteString.hs view
@@ -38,7 +38,7 @@ toArray (PS fp off len) = Array nfp endPtr endPtr   where     nfp = fp `plusForeignPtr` off-    endPtr = unsafeForeignPtrToPtr fp `plusPtr` len+    endPtr = unsafeForeignPtrToPtr nfp `plusPtr` len  -- | Convert an array of 'Word8' to a 'ByteString'. This function unwraps the -- 'Array' and wraps it with 'ByteString' constructors and hence the operation
streamly-bytestring.cabal view
@@ -7,7 +7,7 @@ -- hash: af662f24c97fa6b630e84ef660885ad0de001dc9face27ef4698f5361e4e5484  name:           streamly-bytestring-version:        0.1.1+version:        0.1.2 synopsis:       Library for streamly and bytestring interoperation. description:    Please see the README on GitHub at <https://github.com/psibi/streamly-bytestring#readme> category:       Streamly, Stream, ByteString
test/Main.hs view
@@ -4,11 +4,13 @@  import Data.ByteString (ByteString) import Data.Word (Word8)+import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr) import GHC.IO.Handle (Handle)+import GHC.Ptr (minusPtr) import System.Random (randomIO) import Streamly+import Streamly.Internal.Memory.Array.Types (Array(..)) import Streamly.FileSystem.Handle (readChunks)-import Streamly.Memory.Array (Array) import System.IO (openFile, IOMode(ReadMode)) import System.IO.Temp (withSystemTempFile) import Test.Hspec@@ -92,6 +94,7 @@         S.fromList (Strict.toArray (BS.singleton h) : undefined)     return $ BSL.head lbs + main :: IO () main =     hspec $ do@@ -102,6 +105,13 @@                     ([1 .. 100] :: [Int])             prop "Strict Identity" $ \bs ->                 bs `shouldBe` Strict.fromArray (Strict.toArray bs)+            prop "Strict Identity (with offset)" $ \bs ->+                let bs' = BS.drop 5 bs+                in bs' `shouldBe` Strict.fromArray (Strict.toArray bs')+            prop "toArray never produces negative length" $ \bs ->+                -- 'BS.drop 5' to trigger non-zero offset+                let (Array nfp endPtr _) = Strict.toArray (BS.drop 5 bs)+                in (endPtr `minusPtr` unsafeForeignPtrToPtr nfp) >= 0 `shouldBe` True             prop "Lazy Identity" $ \bs -> do                 bs2 <- Lazy.fromChunks . Lazy.toChunks $ bs                 bs `shouldBe` bs2