http-types 0.5.2 → 0.5.3
raw patch · 3 files changed
+26/−12 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Network/HTTP/Types.hs +1/−2
- http-types.cabal +1/−1
- runtests.hs +24/−9
Network/HTTP/Types.hs view
@@ -300,8 +300,7 @@ renderQueryBuilder :: Bool -- ^ prepend a question mark? -> Query -> A.AsciiBuilder-renderQueryBuilder False [] = mempty-renderQueryBuilder True [] = A.unsafeFromBuilder $ Blaze.copyByteString "?"+renderQueryBuilder _ [] = mempty -- FIXME replace mconcat + map with foldr renderQueryBuilder qmark' (p:ps) = mconcat $ go (if qmark' then qmark else mempty) p
http-types.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version: 0.5.2+Version: 0.5.3 -- A short (one-line) description of the package. Synopsis: Generic HTTP types for Haskell (for both client and server code).
runtests.hs view
@@ -2,15 +2,16 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE OverloadedStrings #-} {-# OPTIONS_GHC -fno-warn-orphans #-}-import Debug.Trace-import Test.Hspec-import Test.Hspec.QuickCheck-import Test.QuickCheck (Arbitrary (..))-import qualified Data.Ascii as A-import Network.HTTP.Types-import Data.Text (Text)-import qualified Data.ByteString as S-import qualified Data.Text as T+import Data.Text (Text)+import Debug.Trace+import Network.HTTP.Types+import Test.Hspec+import Test.Hspec.QuickCheck+import Test.QuickCheck (Arbitrary (..))+import qualified Data.Ascii as A+import qualified Data.ByteString as S+import qualified Data.ByteString.Char8 as S8+import qualified Data.Text as T main :: IO () main = hspec $ descriptions@@ -21,6 +22,8 @@ , describe "encode/decode query" [ it "is identity to encode and then decode" $ property propEncodeDecodeQuery+ , it "add ? in front of Query if and only if necessary"+ $ property propQueryQuestionMark ] , describe "encode/decode path segments" [ it "is identity to encode and then decode"@@ -44,6 +47,18 @@ where q = filter (\(x, _) -> not (S.null x)) q' +propQueryQuestionMark :: (Bool, Query) -> Bool+propQueryQuestionMark (useQuestionMark, query) = actual == expected+ where+ actual = case S8.uncons . A.toByteString $ renderQuery useQuestionMark query of+ Nothing -> False+ Just ('?', _) -> True+ _ -> False+ expected = case (useQuestionMark, null query) of+ (False, _) -> False+ (True, True) -> False+ (True, False) -> True+ propEncodeDecodePathSegments :: [Text] -> Bool propEncodeDecodePathSegments p' = p == decodePathSegments (A.toByteString $ A.fromAsciiBuilder $ encodePathSegments p)