packages feed

bytestring-short 0.0.1.0 → 0.1.0.0

raw patch · 4 files changed

+57/−144 lines, 4 filesdep ~bytestringPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: bytestring

API changes (from Hackage documentation)

- Data.ByteString.Short: data ShortByteString
- Data.ByteString.Short: empty :: ShortByteString
- Data.ByteString.Short: fromShort :: ShortByteString -> ByteString
- Data.ByteString.Short: index :: ShortByteString -> Int -> Word8
- Data.ByteString.Short: length :: ShortByteString -> Int
- Data.ByteString.Short: null :: ShortByteString -> Bool
- Data.ByteString.Short: pack :: [Word8] -> ShortByteString
- Data.ByteString.Short: toShort :: ByteString -> ShortByteString
- Data.ByteString.Short: unpack :: ShortByteString -> [Word8]

Files

bytestring-short.cabal view
@@ -1,5 +1,5 @@ name:                bytestring-short-version:             0.0.1.0+version:             0.1.0.0 synopsis:            Backport copy of ShortByteString description:         Backport copy of ShortByteString license:             BSD3@@ -15,13 +15,19 @@ -- extra-source-files: cabal-version:       >=1.10 +flag use-backport+  description: If true, use backport implementation, otherwize use bytestring 0.10.4 or newer.+  default:     True+ library-  exposed-modules:+  -- Compatible package list trick like: ... bytestring, bytestring-short ...++  if flag(use-backport)+    exposed-modules:                        Data.ByteString.Short                        Data.ByteString.Short.Internal-  -- other-modules: -  other-extensions:+    other-extensions:                        DeriveDataTypeable                        CPP                        BangPatterns@@ -31,11 +37,23 @@                        UnboxedTuples                        UnliftedFFITypes                        Unsafe+    hs-source-dirs:      src+  else+    exposed-modules: -  build-depends:         base >=4.2 && <5-                       , bytestring >=0.9.1 && <0.10.4-                       , deepseq >=1.1-  hs-source-dirs:      src++  exposed-modules:+                        Data.ByteString.Short.Compat++  if flag(use-backport)+    build-depends:         base >=4.2 && <5+                         , bytestring >=0.9.1 && <0.10.4+                         , deepseq >=1.1+  else+    build-depends:         base >=4.2 && <5+                         , bytestring >=0.10.4++  hs-source-dirs:      compat   default-language:    Haskell2010    ghc-options:@@ -49,15 +67,21 @@   install-includes:  short_fpstring.h  test-suite prop-compiled-  type:             exitcode-stdio-1.0-  main-is:          Properties.hs   hs-source-dirs:   tests-  build-depends:    base <5, bytestring-short, bytestring,-                    QuickCheck >=2   default-language: Haskell98-  c-sources:        cbits/short_fpstring.c-  include-dirs:     include +  if flag(use-backport)+    type:             exitcode-stdio-1.0+    hs-source-dirs:   tests+    main-is:          Properties.hs+    build-depends:    base <5, bytestring-short, bytestring,+                      QuickCheck >=2+    c-sources:        cbits/short_fpstring.c+    include-dirs:     include+  else+    type:             exitcode-stdio-1.0+    main-is:          TT.hs+    build-depends:    base <5  source-repository head   type:       git
+ compat/Data/ByteString/Short/Compat.hs view
@@ -0,0 +1,16 @@+-- |+-- Module      : Data.ByteString.Short.Compat+-- Copyright   : (c) Kei Hibino 2015-2016+-- License     : BSD3+--+-- Maintainer  : ex8k.hibino@gmail.com+-- Stability   : experimental+-- Portability : ghc only+--+-- Avoiding empty package and explicitly compatible module name.+-- May use the name "Data.ByteString.Short" implicitly.+module Data.ByteString.Short.Compat+       ( module Data.ByteString.Short+       ) where++import Data.ByteString.Short
− tests/Properties.hs
@@ -1,130 +0,0 @@-{-# OPTIONS_GHC -fno-warn-orphans #-}--import Data.ByteString.Char8 ()-import qualified Data.ByteString            as P-import qualified Data.ByteString.Internal   as P-import qualified Data.ByteString.Short      as Short--import Control.Applicative ((<$>))-import Control.Monad (unless)-import Data.Monoid (mappend, mconcat)-import Data.Maybe (catMaybes)-import Data.String (fromString)-import System.IO (stderr, hPutStrLn)-import Test.QuickCheck-  (Testable, Property, Result (..), quickCheckResult, label,-  Arbitrary (..), choose)---type Test = (String, Property)--testProperty :: Testable prop => String -> prop -> Test-testProperty m = (,) m . label m--runMayError :: Testable prop => (a, prop) -> IO (Maybe (a, Result))-runMayError (m, prop) = fmap ((,) m) . err <$> quickCheckResult prop  where-  err :: Result -> Maybe Result-  err (Success {})  =  Nothing-  err x             =  Just x--defaultMain :: [Test] -> IO ()-defaultMain xs = do-  es <- catMaybes <$> mapM runMayError xs-  mapM_ (\(m, r) -> hPutStrLn stderr $ m ++ ":\n" ++ show r) es-  unless (null es) $ fail "Found some failures."--main :: IO ()-main = defaultMain tests----- Arbitrary instance for only test.-instance Arbitrary P.ByteString where-  arbitrary = do-    bs <- P.pack `fmap` arbitrary-    n  <- choose (0, 2)-    return (P.drop n bs) -- to give us some with non-0 offset--prop_short_pack_unpack xs =-    (Short.unpack . Short.pack) xs == xs-prop_short_toShort_fromShort bs =-    (Short.fromShort . Short.toShort) bs == bs--prop_short_toShort_unpack bs =-    (Short.unpack . Short.toShort) bs == P.unpack bs-prop_short_pack_fromShort xs =-    (Short.fromShort . Short.pack) xs == P.pack xs--prop_short_empty =-    Short.empty == Short.toShort P.empty- && Short.empty == Short.pack []- && Short.null (Short.toShort P.empty)- && Short.null (Short.pack [])- && Short.null Short.empty--prop_short_null_toShort bs =-    P.null bs == Short.null (Short.toShort bs)-prop_short_null_pack xs =-    null xs == Short.null (Short.pack xs)--prop_short_length_toShort bs =-    P.length bs == Short.length (Short.toShort bs)-prop_short_length_pack xs =-    length xs == Short.length (Short.pack xs)--prop_short_index_pack xs =-    all (\i -> Short.pack xs `Short.index` i == xs !! i)-        [0 .. length xs - 1]-prop_short_index_toShort bs =-    all (\i -> Short.toShort bs `Short.index` i == bs `P.index` i)-        [0 .. P.length bs - 1]--prop_short_eq xs ys =-    (xs == ys) == (Short.pack xs == Short.pack ys)-prop_short_ord xs ys =-    (xs `compare` ys) == (Short.pack xs `compare` Short.pack ys)--prop_short_mappend_empty_empty =-    Short.empty `mappend` Short.empty  == Short.empty-prop_short_mappend_empty xs =-    Short.empty `mappend` Short.pack xs == Short.pack xs- && Short.pack xs `mappend` Short.empty == Short.pack xs-prop_short_mappend xs ys =-    (xs `mappend` ys) == Short.unpack (Short.pack xs `mappend` Short.pack ys)-prop_short_mconcat xss =-    mconcat xss == Short.unpack (mconcat (map Short.pack xss))--prop_short_fromString s =-    fromString s == Short.fromShort (fromString s)--prop_short_show xs =-    show (Short.pack xs) == show (map P.w2c xs)-prop_short_show' xs =-    show (Short.pack xs) == show (P.pack xs)--prop_short_read xs =-    read (show (Short.pack xs)) == Short.pack xs--tests :: [Test]-tests =-    [ testProperty "pack/unpack"              prop_short_pack_unpack-    , testProperty "toShort/fromShort"        prop_short_toShort_fromShort-    , testProperty "toShort/unpack"           prop_short_toShort_unpack-    , testProperty "pack/fromShort"           prop_short_pack_fromShort-    , testProperty "empty"                    prop_short_empty-    , testProperty "null/toShort"             prop_short_null_toShort-    , testProperty "null/pack"                prop_short_null_pack-    , testProperty "length/toShort"           prop_short_length_toShort-    , testProperty "length/pack"              prop_short_length_pack-    , testProperty "index/pack"               prop_short_index_pack-    , testProperty "index/toShort"            prop_short_index_toShort-    , testProperty "Eq"                       prop_short_eq-    , testProperty "Ord"                      prop_short_ord-    , testProperty "mappend/empty/empty"      prop_short_mappend_empty_empty-    , testProperty "mappend/empty"            prop_short_mappend_empty-    , testProperty "mappend"                  prop_short_mappend-    , testProperty "mconcat"                  prop_short_mconcat-    , testProperty "fromString"               prop_short_fromString-    , testProperty "show"                     prop_short_show-    , testProperty "show'"                    prop_short_show'-    , testProperty "read"                     prop_short_read-    ]
+ tests/TT.hs view
@@ -0,0 +1,3 @@++main :: IO ()+main = return ()