packages feed

network-arbitrary 0.1.0.0 → 0.2.0.0

raw patch · 8 files changed

+179/−8 lines, 8 filesdep +bytestringdep +case-insensitivedep +http-mediaPVP ok

version bump matches the API change (PVP)

Dependencies added: bytestring, case-insensitive, http-media, http-types, test-invariant

API changes (from Hackage documentation)

+ Network.HTTP.Media.MediaType.Arbitrary: instance Test.QuickCheck.Arbitrary.Arbitrary Network.HTTP.Media.MediaType.Internal.MediaType
+ Network.HTTP.Types.Method.Arbitrary: instance Test.QuickCheck.Arbitrary.Arbitrary Network.HTTP.Types.Method.StdMethod

Files

ChangeLog.md view
@@ -1,5 +1,12 @@ # Revision history for network-arbitrary +## 0.2.0.0  -- 2018-01-06++* Add top-level module for importing everything+* Fix README+* Add http-types instances (non-exhaustive)+* Add http-media instances (non-exhaustive)+ ## 0.1.0.0  -- 2018-01-05  * First version.
README.md view
@@ -25,7 +25,7 @@  [Arbitrary]: https://hackage.haskell.org/package/QuickCheck/docs/Test-QuickCheck-Arbitrary.html#t:Arbitrary [git flow]: http://nvie.com/posts/a-successful-git-branching-model/-[Hackage]: https://hackage.haskell.org/package/network-uri-json+[Hackage]: https://hackage.haskell.org/package/network-arbitrary [Haskell]: https://www.haskell.org/ [issues]: https://github.com/alunduil/network-arbitrary/issues [network-category]: https://hackage.haskell.org/packages/#cat:Network
network-arbitrary.cabal view
@@ -1,5 +1,5 @@ name:                network-arbitrary-version:             0.1.0.0+version:             0.2.0.0 synopsis:            Arbitrary Instances for Network Types  description:         @@ -39,16 +39,23 @@       src    exposed-modules:-      Network.URI.Arbitrary+      Network.Arbitrary+    , Network.HTTP.Media.MediaType.Arbitrary+    , Network.HTTP.Types.Method.Arbitrary +    , Network.URI.Arbitrary    other-modules:    build-depends:       base        >= 4.6 && < 4.12+    , bytestring  == 0.10.*+    , http-media  >= 0.6 && < 0.8+    , http-types  == 0.9.*     , network-uri == 2.6.*     , QuickCheck  >= 2.9 && < 2.11    other-extensions:+      RecordWildCards  test-suite network-arbitrary-tests   default-language: Haskell2010@@ -63,15 +70,23 @@     , test    other-modules:-      Network.URI.ArbitrarySpec+      Network.HTTP.Media.MediaType.ArbitrarySpec+    , Network.HTTP.Types.Method.ArbitrarySpec+    , Network.URI.ArbitrarySpec    build-tool-depends:       hspec-discover:hspec-discover == 2.4.*    build-depends:-      base        >= 4.6 && < 4.12-    , hspec       == 2.4.*-    , network-uri == 2.6.*-    , QuickCheck  >= 2.9 && < 2.11+      base             >= 4.6 && < 4.12+    , bytestring       == 0.10.*+    , case-insensitive == 1.2.*+    , hspec            == 2.4.*+    , http-media       >= 0.6 && < 0.8+    , http-types       == 0.9.*+    , network-uri      == 2.6.*+    , QuickCheck       >= 2.9 && < 2.11+    , test-invariant   == 0.4.*    other-extensions:+      RecordWildCards
+ src/Network/Arbitrary.hs view
@@ -0,0 +1,13 @@+{-|+Module      : Network.Arbitrary+Description : Arbitrary Instances for Network+Copyright   : (c) Alex Brandt, 2018+License     : MIT++Arbitrary instances for "Network".+-}+module Network.Arbitrary () where++import Network.HTTP.Media.MediaType.Arbitrary ()+import Network.HTTP.Types.Method.Arbitrary ()+import Network.URI.Arbitrary ()
+ src/Network/HTTP/Media/MediaType/Arbitrary.hs view
@@ -0,0 +1,58 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}++{-|+Module      : Network.HTTP.Media.MediaType.Arbitrary+Description : Arbitrary Instances for Network.HTTP.Media.MediaType+Copyright   : (c) Alex Brandt, 2018+License     : MIT++Arbitrary instances for "Network.HTTP.Media.MediaType".+-}+module Network.HTTP.Media.MediaType.Arbitrary () where++import Prelude hiding (concat)++import Control.Applicative ((<*>))+import Control.Monad (replicateM)+import Data.ByteString (append, concat, ByteString)+import Data.ByteString.Char8 (singleton)+import Data.Functor ((<$>))+import Network.HTTP.Media.MediaType ((/:), (//), MediaType)+import Test.QuickCheck (Arbitrary (arbitrary), choose, elements, Gen, listOf, oneof, sized)++--+--+-- Note: parameter---paramter values are supposed to be unrestricted but due to+--       the way that quickcheck validates values it's best if these are+--       printable.  Until we can use the new instances in quickcheck-2.10.*, we+--       shall simply use restrictedName for the values as well.+instance Arbitrary MediaType where+  arbitrary =+    do n  <- (//) <$> restrictedName <*> restrictedName+       ps <- listOf $ (,) <$> restrictedName <*> restrictedName -- see parameter note above+       return $ foldl (/:) n ps++-- * RFC 6838 Generators++restrictedName :: Gen ByteString+restrictedName = sized $ \ s ->+  do n  <- choose (0, min 126 s)+     rs <- concat <$> replicateM n restrictedNameChar+     (`append` rs) <$> restrictedNameFirst++restrictedNameFirst :: Gen ByteString+restrictedNameFirst = singleton <$> oneof [alpha, digit]++restrictedNameChar :: Gen ByteString+restrictedNameChar = singleton <$> oneof [ alpha+                                         , digit+                                         , elements ['!', '#', '$', '&', '-', '^', '_', '.', '+']+                                         ]++-- * RFC 2234 Generators++alpha :: Gen Char+alpha = elements $ ['a'..'z'] ++ ['A'..'Z']++digit :: Gen Char+digit = elements ['0'..'9']
+ src/Network/HTTP/Types/Method/Arbitrary.hs view
@@ -0,0 +1,26 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}++{-|+Module      : Network.HTTP.Types.Method.Arbitrary+Description : Arbitrary Instances for Network.HTTP.Types.Method+Copyright   : (c) Alex Brandt, 2018+License     : MIT++Arbitrary instances for "Network.HTTP.Types.Method".+-}+module Network.HTTP.Types.Method.Arbitrary () where++import Network.HTTP.Types.Method (StdMethod (..))+import Test.QuickCheck (Arbitrary (arbitrary), elements)++instance Arbitrary StdMethod where+  arbitrary = elements [ GET+                       , POST+                       , HEAD+                       , PUT+                       , DELETE+                       , TRACE+                       , CONNECT+                       , OPTIONS+                       , PATCH+                       ]
+ test/Network/HTTP/Media/MediaType/ArbitrarySpec.hs view
@@ -0,0 +1,28 @@+{-|+Module      : Network.HTTP.Media.MediaType.ArbitrarySpec+Description : Tests for Network.HTTP.Media.MediaType.Arbitrary+Copyright   : (c) Alex Brandt, 2018+License     : MIT++Tests for "Network.HTTP.Media.MediaType.Arbitrary".+-}+module Network.HTTP.Media.MediaType.ArbitrarySpec (main, spec) where++import Prelude hiding (null)++import Data.ByteString (null)+import Data.CaseInsensitive (original)+import Network.HTTP.Media.MediaType (mainType, subType)+import Test.Hspec (describe, hspec, Spec)+import Test.Hspec.QuickCheck (prop)++import Network.HTTP.Media.MediaType.Arbitrary ()++main :: IO ()+main = hspec spec++spec :: Spec+spec =+  describe "properties" $+    do prop "not . null . mainType" $ not . null . original . mainType+       prop "not . null . subType"  $ not . null . original . subType
+ test/Network/HTTP/Types/Method/ArbitrarySpec.hs view
@@ -0,0 +1,24 @@+{-|+Module      : Network.HTTP.Types.Method.ArbitrarySpec+Description : Tests for Network.HTTP.Types.Method.Arbitrary+Copyright   : (c) Alex Brandt, 2018+License     : MIT++Tests for "Network.HTTP.Types.Method.Arbitrary".+-}+module Network.HTTP.Types.Method.ArbitrarySpec (main, spec) where++import Network.HTTP.Types.Method (parseMethod, renderStdMethod)+import Test.Hspec (describe, hspec, Spec)+import Test.Hspec.QuickCheck (prop)+import Test.Invariant ((<=>))++import Network.HTTP.Types.Method.Arbitrary ()++main :: IO ()+main = hspec spec++spec :: Spec+spec =+  describe "properties" $+    prop "parseMethod . renderStdMethod <=> Right" $ parseMethod . renderStdMethod <=> Right