Repository : ssh://darcs.haskell.org//srv/darcs/packages/bytestring On branch : master
http://hackage.haskell.org/trac/ghc/changeset/727e6405ae5c83f7da40a1866c7b9c6a98441797 >--------------------------------------------------------------- commit 727e6405ae5c83f7da40a1866c7b9c6a98441797 Author: Duncan Coutts <[email protected]> Date: Mon Nov 7 11:30:08 2011 +0000 Include non-0 offset in instance Arbitrary Strict.ByteString And fix a test that breaks. >--------------------------------------------------------------- Data/ByteString/Internal.hs | 2 +- tests/Properties.hs | 4 +++- tests/QuickCheckUtils.hs | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Data/ByteString/Internal.hs b/Data/ByteString/Internal.hs index bc91146..d9a3baf 100644 --- a/Data/ByteString/Internal.hs +++ b/Data/ByteString/Internal.hs @@ -317,7 +317,7 @@ unpackAppendCharsStrict (PS fp off len) xs = -- | The 0 pointer. Used to indicate the empty Bytestring. nullForeignPtr :: ForeignPtr Word8 #ifdef __GLASGOW_HASKELL__ -nullForeignPtr = ForeignPtr nullAddr# undefined --TODO: should ForeignPtrContents be strict? +nullForeignPtr = ForeignPtr nullAddr# (error "nullForeignPtr") --TODO: should ForeignPtrContents be strict? #else nullForeignPtr = unsafePerformIO $ newForeignPtr_ nullPtr {-# NOINLINE nullForeignPtr #-} diff --git a/tests/Properties.hs b/tests/Properties.hs index 0237ebf..d50e970 100644 --- a/tests/Properties.hs +++ b/tests/Properties.hs @@ -1537,7 +1537,9 @@ prop_packMallocCString (CByteString x) = unsafePerformIO $ do let !z = y == x free ptr `seq` return z -prop_unsafeFinalize x = unsafePerformIO $ do +prop_unsafeFinalize x = + P.length x > 0 ==> + unsafePerformIO $ do x <- P.unsafeFinalize x return (x == ()) diff --git a/tests/QuickCheckUtils.hs b/tests/QuickCheckUtils.hs index 075dca6..4c61216 100644 --- a/tests/QuickCheckUtils.hs +++ b/tests/QuickCheckUtils.hs @@ -89,7 +89,10 @@ instance CoArbitrary L.ByteString where coarbitrary s = coarbitrary (L.unpack s) instance Arbitrary P.ByteString where - arbitrary = P.pack `fmap` arbitrary + arbitrary = do + bs <- P.pack `fmap` arbitrary + n <- choose (0, 2) + return (P.drop n bs) -- to give us some with non-0 offset instance CoArbitrary P.ByteString where coarbitrary s = coarbitrary (P.unpack s) _______________________________________________ Cvs-libraries mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-libraries
