network-arbitrary 0.4.0.7 → 1.0.0.1
raw patch · 12 files changed
Files
- COPYRIGHT +0/−1
- ChangeLog.md +60/−0
- README.md +38/−25
- Setup.hs +1/−0
- network-arbitrary.cabal +54/−77
- src/Network/Arbitrary.hs +7/−8
- src/Network/HTTP/Media/MediaType/Arbitrary.hs +55/−31
- src/Network/HTTP/Types/Method/Arbitrary.hs +16/−20
- src/Network/URI/Arbitrary.hs +143/−112
- test/Network/HTTP/Media/MediaType/ArbitrarySpec.hs +36/−21
- test/Network/HTTP/Types/Method/ArbitrarySpec.hs +31/−15
- test/Network/URI/ArbitrarySpec.hs +30/−17
− COPYRIGHT
@@ -1,1 +0,0 @@-Copyright 2018 Alex Brandt <alunduil@gmail.com>
ChangeLog.md view
@@ -1,5 +1,65 @@ # Revision history for network-arbitrary +## unreleased++## 1.0.0.1 -- 2024-05-26++### Added++* Support for base 4.20.0 and newer++### Deprecated++* GHC testing of 9.4+* GHC testing of 9.6++### Removed++* GHC testing for older than 9.4++## 1.0.0.0 -- 2024-04-24++### Added++* GHC testing for 9.2.*, 9.4.*, 9.6.*, 9.8.*+* Support for base 4.15, 4.16, 4.17, 4.18, and 4.19+* Support for bytestring 0.11.1.0 and newer, and 0.12.0.0 and newer+* Support for QuickCheck 2.15++### Changed++### Deprecated++* GHC testing for older than 9.4++### Fixed++### Removed++* GHC testing for <8.6.4++### Security++## 0.7.0.0 -- 2020-11-30++* Update project structure+ * stylish-haskell configuration+ * updated travis configuration+ * pre-commit+ * nix-shell with mkShell+* Bump base dependence version+* Generate relative references as well++## 0.6.0.0 -- 2020-04-11++* Update project structure.+* Migration to ghc 8.8+* Update travis.yml with haskell-ci++## 0.5.0.0 -- 2019-12-13++* Bump upper bounds of dependencies.+ ## 0.4.0.7 -- 2019-02-14 * Use a volume to carry configuration information forward.
README.md view
@@ -1,37 +1,50 @@-# Description+# network-arbitrary -[Arbitrary] Instances for [Network][network-category] Types+[Homepage](https://github.com/alunduil/network-arbitrary)+By Alex Brandt <alunduil@gmail.com> -I am providing code in the repository to you under an open source license.-Because this is my personal repository, the license you receive to my code is-from me and not my employer (Facebook).+## Description -# Getting Started+You can use network-arbitrary to provide Arbitrary instances for Network module types. -Documentation is available on [Hackage]. A great guide to [QuickCheck] is-<https://begriffs.com/posts/2017-01-14-design-use-quickcheck.html>.+## Terms of use -# Reporting Issues+You are free to use network-arbitrary without any conditions. See the [LICENSE]+file for details. -Any issues discovered should be recorded on [github][issues]. If you believe-you've found an error or have a suggestion for a new feature; please, ensure-that it is reported.+## How to use network-arbitrary -If you would like to contribute a fix or new feature; please, submit a pull-request. This project follows [git flow] and utilizes [travis] to automatically-check pull requests before a manual review.+```haskell+{-# LANGUAGE TypeApplications #-}+module main where -# Contributors+import Network.URI (URI)+import Network.URI.Arbitrary () -The `COPYRIGHT` file contains a list of contributors with their respective-copyrights and other information. If you submit a pull request and would like-attribution; please, add yourself to the `COPYRIGHT` file.+main = generate (arbitrary @URI) >>= print+``` -[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-arbitrary-[Haskell]: https://www.haskell.org/+## Documentation++* [Hackage][hackage]: Hackage project page for network-arbitrary+* [The Design and Use of QuickCheck](https://begriffs.com/posts/2017-01-14-design-use-quickcheck.html): An excellent guide to using QuickCheck+* [LICENSE](./LICENSE): The license governing use of network-arbitrary+* [QuickCheck Arbitrary][arbitrary]: QuickCheck's Arbitrary class documentation+* [Hackage's Network Category][network-category]: Hackage's Network category+* [QuickCheck][quickcheck]: QuickCheck's documentation++## Getting Help++* [GitHub Issues][issues]: Support requests, bug reports, and feature requests++## How to Help++* Submit [issues] for problems or questions+* Submit [pull requests] for proposed changes++[arbitrary]: https://hackage.haskell.org/package/QuickCheck/docs/Test-QuickCheck-Arbitrary.html#t:Arbitrary+[hackage]: https://hackage.haskell.org/package/network-arbitrary [issues]: https://github.com/alunduil/network-arbitrary/issues [network-category]: https://hackage.haskell.org/packages/#cat:Network-[QuickCheck]: https://hackage.haskell.org/package/QuickCheck-[travis]: https://travis-ci.org/alunduil/network-arbitrary+[pull requests]: https://github.com/alunduil/network-arbitrary/pulls+[quickcheck]: https://hackage.haskell.org/package/QuickCheck
Setup.hs view
@@ -1,2 +1,3 @@ import Distribution.Simple+ main = defaultMain
network-arbitrary.cabal view
@@ -1,95 +1,72 @@-name: network-arbitrary-version: 0.4.0.7-synopsis: Arbitrary Instances for Network Types--description: - Arbitrary instances for Network types.+cabal-version: 3.0+name: network-arbitrary+version: 1.0.0.1+license: MIT+license-file: LICENSE+copyright: (c) 2018 Alex Brandt+author: Alex Brandt+maintainer: alunduil@gmail.com+stability: stable+homepage: https://github.com/alunduil/network-arbitrary+bug-reports: https://github.com/alunduil/network-arbitrary/issues+synopsis: Arbitrary Instances for Network Types+description:+ You can use network-arbitrary to provide Arbitrary instances for Network+ module types. -homepage: https://github.com/alunduil/network-arbitrary-bug-reports: https://github.com/alunduil/network-arbitrary/issues-license: MIT-license-file: LICENSE-author: Alex Brandt-maintainer: alunduil@gmail.com-copyright: (c) 2018 Alex Brandt-category: Testing-build-type: Simple-cabal-version: >= 1.10-tested-with: GHC >= 7.6 && < 8.2.1 || > 8.2.1 && < 9.0+category: Testing+tested-with:+ GHC >=9.4 && <9.5 || >=9.6 && <9.7 || >=9.8 && <9.9 || >=9.10 && <9.11 extra-source-files:- ChangeLog.md- , COPYRIGHT- , LICENSE- , README.md- , Setup.hs+ ChangeLog.md+ README.md source-repository head type: git location: https://github.com/alunduil/network-arbitrary- branch: develop -library- default-language: Haskell2010-- ghc-options: -Wall -fwarn-tabs -fwarn-monomorphism-restriction- -fwarn-unused-do-bind-- hs-source-dirs:- src+common network-arbitrary-common+ build-depends:+ , base >=4.6 && <4.15 || ^>=4.15.0.0 || ^>=4.16.0.0 || ^>=4.17.0.0 || ^>=4.18.0.0 || ^>=4.19.0.0 || ^>=4.20.0+ , bytestring >=0.10 && <0.11 || ^>=0.11.1.0 || ^>=0.12.0.0+ , http-media >=0.6 && <0.9+ , http-types >=0.9 && <0.13+ , network-uri >=2.6 && <2.8+ , QuickCheck ^>=2.9 || ^>=2.10 || ^>=2.11 || ^>=2.12 || ^>=2.13 || ^>=2.14 || ^>=2.15 +library+ import: network-arbitrary-common exposed-modules:- Network.Arbitrary- , Network.HTTP.Media.MediaType.Arbitrary- , Network.HTTP.Types.Method.Arbitrary - , 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.13- , bytestring == 0.10.*- , http-media >= 0.6 && < 0.8- , http-types >= 0.9 && < 0.13- , network-uri == 2.6.*- , QuickCheck >= 2.9 && < 2.13-- other-extensions:- RecordWildCards--test-suite network-arbitrary-tests+ hs-source-dirs: src default-language: Haskell2010- type: exitcode-stdio-1.0- main-is: Spec.hs-- ghc-options: -Wall -fwarn-tabs -fwarn-monomorphism-restriction- -fwarn-unused-do-bind+ ghc-options: -Wall -Wcompat - hs-source-dirs:- src- , test+test-suite test+ import: network-arbitrary-common+ type: exitcode-stdio-1.0+ main-is: Spec.hs+ build-depends:+ , case-insensitive >=1.2 && <1.3+ , hspec >=2.4 && <2.8 || ^>=2.11.8+ , test-invariant >=0.4 && <0.5 + build-tool-depends: hspec-discover:hspec-discover >=2.4 && <2.8 other-modules:- Network.HTTP.Media.MediaType.Arbitrary- , Network.HTTP.Media.MediaType.ArbitrarySpec- , Network.HTTP.Types.Method.Arbitrary - , Network.HTTP.Types.Method.ArbitrarySpec- , Network.URI.Arbitrary- , Network.URI.ArbitrarySpec-- build-tool-depends:- hspec-discover:hspec-discover >= 2.4 && < 2.8-- build-depends:- base >= 4.6 && < 4.13- , bytestring == 0.10.*- , case-insensitive == 1.2.*- , hspec >= 2.4 && < 2.8- , http-media >= 0.6 && < 0.8- , http-types >= 0.9 && < 0.13- , network-uri == 2.6.*- , QuickCheck >= 2.9 && < 2.13- , test-invariant == 0.4.*+ Network.HTTP.Media.MediaType.Arbitrary+ Network.HTTP.Media.MediaType.ArbitrarySpec+ Network.HTTP.Types.Method.Arbitrary+ Network.HTTP.Types.Method.ArbitrarySpec+ Network.URI.Arbitrary+ Network.URI.ArbitrarySpec - other-extensions:- RecordWildCards+ hs-source-dirs: src test+ default-language: Haskell2010+ ghc-options: -Wall -Wcompat
src/Network/Arbitrary.hs view
@@ -1,11 +1,10 @@-{-|-Module : Network.Arbitrary-Description : Arbitrary Instances for Network-Copyright : (c) Alex Brandt, 2018-License : MIT--Arbitrary instances for "Network".--}+-- |+-- 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 ()
src/Network/HTTP/Media/MediaType/Arbitrary.hs view
@@ -1,24 +1,48 @@ {-# 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+-- 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)+import Control.Applicative+ ( (<*>),+ )+import Control.Monad+ ( replicateM,+ )+import Data.ByteString+ ( ByteString,+ append,+ concat,+ )+import Data.ByteString.Char8+ ( singleton,+ )+import Data.Functor+ ( (<$>),+ )+import Network.HTTP.Media.MediaType+ ( MediaType,+ (//),+ (/:),+ )+import Test.QuickCheck+ ( Arbitrary (arbitrary),+ Gen,+ choose,+ elements,+ listOf,+ oneof,+ sized,+ )+import Prelude hiding+ ( concat,+ ) -- --@@ -27,32 +51,32 @@ -- 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+ 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+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 ['!', '#', '$', '&', '-', '^', '_', '.', '+']- ]+restrictedNameChar =+ singleton+ <$> oneof+ [alpha, digit, elements ['!', '#', '$', '&', '-', '^', '_', '.', '+']] -- * RFC 2234 Generators alpha :: Gen Char-alpha = elements $ ['a'..'z'] ++ ['A'..'Z']+alpha = elements $ ['a' .. 'z'] ++ ['A' .. 'Z'] digit :: Gen Char-digit = elements ['0'..'9']+digit = elements ['0' .. '9']
src/Network/HTTP/Types/Method/Arbitrary.hs view
@@ -1,26 +1,22 @@ {-# 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+-- 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)+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- ]+ arbitrary =+ elements [GET, POST, HEAD, PUT, DELETE, TRACE, CONNECT, OPTIONS, PATCH]
src/Network/URI/Arbitrary.hs view
@@ -1,88 +1,115 @@ {-# LANGUAGE RecordWildCards #-}-+{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -{-|-Module : Network.URI.Arbitrary-Description : Arbitrary Instances for Network.URI-Copyright : (c) Alex Brandt, 2018-License : MIT+{-# HLINT ignore "Evaluate" #-} -Arbitrary instances for "Network.URI".--}+-- |+-- Module : Network.URI.Arbitrary+-- Description : Arbitrary Instances for Network.URI+-- Copyright : (c) Alex Brandt, 2018+-- License : MIT+--+-- Arbitrary instances for "Network.URI". module Network.URI.Arbitrary () where -import Control.Applicative ((<$>), (<*>))-import Control.Monad (replicateM)-import Data.List (intercalate)-import Network.URI (parseURIReference, URI (..), URIAuth (..), uriToString)-import Test.QuickCheck (Arbitrary (arbitrary, shrink), choose, elements, Gen, listOf, listOf1, oneof, suchThat)+import Control.Monad+ ( replicateM,+ )+import Data.List+ ( intercalate,+ )+import Network.URI+ ( URI (..),+ URIAuth (..),+ parseURIReference,+ uriToString,+ )+import Test.QuickCheck+ ( Arbitrary (arbitrary, shrink),+ Gen,+ choose,+ elements,+ listOf,+ listOf1,+ oneof,+ suchThat,+ ) instance Arbitrary URI where- arbitrary =- do uriScheme <- scheme- uriAuthority <- arbitrary :: Gen (Maybe URIAuth)- uriPath <- path (null uriScheme) $ maybe True emptyAuthority uriAuthority- uriQuery <- oneof [query, return ""]- uriFragment <- oneof [fragment, return ""]-- return URI {..}- where emptyAuthority URIAuth{..} = all null [uriUserInfo, uriRegName, uriPort]+ arbitrary = do+ uriScheme <- oneof [return "", scheme]+ uriAuthority <- arbitrary :: Gen (Maybe URIAuth)+ uriPath <- path (null uriScheme) $ maybe True emptyAuthority uriAuthority+ uriQuery <- oneof [query, return ""]+ uriFragment <- oneof [fragment, return ""] - shrink URI{..} = filter isURI [ URI uriScheme' uriAuthority' uriPath' uriQuery' uriFragment' | (uriScheme', uriAuthority', uriPath', uriQuery', uriFragment') <- shrink (uriScheme, uriAuthority, uriPath, uriQuery, uriFragment) ]- where isURI u = case parseURIReference (uriToString id u "") of- Just u' -> u' == u- Nothing -> False+ return URI {..}+ where+ emptyAuthority URIAuth {..} = all null [uriUserInfo, uriRegName, uriPort] + shrink URI {..} =+ filter+ isURI+ [ URI uriScheme' uriAuthority' uriPath' uriQuery' uriFragment'+ | (uriScheme', uriAuthority', uriPath', uriQuery', uriFragment') <-+ shrink+ (uriScheme, uriAuthority, uriPath, uriQuery, uriFragment)+ ]+ where+ isURI u = case parseURIReference (uriToString id u "") of+ Just u' -> u' == u+ Nothing -> False instance Arbitrary URIAuth where- arbitrary = URIAuth <$> userinfo- <*> host `suchThat` (not . null)- <*> port+ arbitrary = URIAuth <$> userinfo <*> host `suchThat` (not . null) <*> port - shrink URIAuth{..} = [ URIAuth uriUserInfo' uriRegName' uriPort' | (uriUserInfo', uriRegName', uriPort') <- shrink (uriUserInfo, uriRegName, uriPort) ]+ shrink URIAuth {..} =+ [ URIAuth uriUserInfo' uriRegName' uriPort'+ | (uriUserInfo', uriRegName', uriPort') <-+ shrink+ (uriUserInfo, uriRegName, uriPort)+ ] -- * RFC 3986 Generators+ ----- Some generators are handled by the 'Arbitrary' instances above, and others--- are folded into symbols that are preceeded or followed by identifying--- tokens.+-- Some generators are handled by the 'Arbitrary' instances above, and+-- others are folded into symbols that are preceded or followed by+-- identifying tokens. scheme :: Gen String-scheme =- do a <- alpha- r <- listOf $ oneof [alpha, digit, elements ['+', '-', '.']]- return $ a : (r ++ ":")+scheme = do+ a <- alpha+ r <- listOf $ oneof [alpha, digit, elements ['+', '-', '.']]+ return $ a : (r ++ ":") userinfo :: Gen String-userinfo =- do u <- concat <$> userinfo'- if null u- then return ""- else return $ u ++ "@"- where userinfo' = listOf $ oneof [ replicateM 1 $ oneof [unreserved, subDelims, return ':']- , percentEncoded- ]+userinfo = do+ u <- concat <$> userinfo'+ if null u then return "" else return $ u ++ "@"+ where+ userinfo' =+ listOf $+ oneof+ [replicateM 1 $ oneof [unreserved, subDelims, return ':'], percentEncoded] host :: Gen String-host = oneof [ ipLiteral- , ipv4Address- , regName- ]+host = oneof [ipLiteral, ipv4Address, regName] port :: Gen String-port =- do p <- listOf digit- if null p- then return ""- else return $ ':':p+port = do+ p <- listOf digit+ if null p then return "" else return $ ':' : p ipLiteral :: Gen String-ipLiteral =- do x <- oneof [ ipv6Address- --, ipvFuture- ]- return $ "[" ++ x ++ "]"+ipLiteral = do+ x <-+ oneof+ [ ipv6Address+ -- , ipvFuture+ ]+ return $ "[" ++ x ++ "]" {- TODO Check that "Network.URI" implements this correctly. ipvFuture :: Gen String@@ -93,25 +120,27 @@ -} ipv6Address :: Gen String-ipv6Address = concat <$> oneof [ sequence [b 6, ls32]- , sequence [return "::", b 5, ls32]- , sequence [h16, return "::", b 4, ls32]- , sequence [b 1, h16, return "::", b 3, ls32]- , sequence [b 2, h16, return "::", b 2, ls32]- , sequence [b 3, h16, return "::", b 1, ls32]- , sequence [b 4, h16, return "::", ls32]- , sequence [b 5, h16, return "::", h16]- , sequence [b 6, h16, return "::"]- ]- where b n = fmap concat $ replicateM n $ fmap (++ ":") h16 :: Gen String+ipv6Address =+ concat+ <$> oneof+ [ sequence [b 6, ls32],+ sequence [return "::", b 5, ls32],+ sequence [h16, return "::", b 4, ls32],+ sequence [b 1, h16, return "::", b 3, ls32],+ sequence [b 2, h16, return "::", b 2, ls32],+ sequence [b 3, h16, return "::", b 1, ls32],+ sequence [b 4, h16, return "::", ls32],+ sequence [b 5, h16, return "::", h16],+ sequence [b 6, h16, return "::"]+ ]+ where+ b n = fmap concat $ replicateM n $ fmap (++ ":") h16 :: Gen String h16 :: Gen String h16 = replicateM 4 hexdig ls32 :: Gen String-ls32 = oneof [ intercalate ":" <$> replicateM 2 h16- , ipv4Address- ]+ls32 = oneof [intercalate ":" <$> replicateM 2 h16, ipv4Address] ipv4Address :: Gen String ipv4Address = intercalate "." <$> replicateM 4 decOctet@@ -120,65 +149,67 @@ decOctet = (show :: Int -> String) <$> choose (0, 255) regName :: Gen String-regName = fmap concat $ listOf $ oneof [ replicateM 1 unreserved- , percentEncoded- , replicateM 1 subDelims- ]+regName =+ fmap concat $+ listOf $+ oneof+ [replicateM 1 unreserved, percentEncoded, replicateM 1 subDelims] path :: Bool -> Bool -> Gen String-path emptyScheme emptyURIAuth = if emptyURIAuth- then oneof [ pathAbsolute- , if emptyScheme then pathNoScheme else pathRootless- , return ""- ]- else pathAbEmpty+path emptyScheme emptyURIAuth =+ if emptyURIAuth+ then+ oneof+ [ pathAbsolute,+ if emptyScheme then pathNoScheme else pathRootless,+ return ""+ ]+ else pathAbEmpty pathAbEmpty :: Gen String-pathAbEmpty = concat <$> listOf (('/':) . concat <$> listOf pchar)+pathAbEmpty = concat <$> listOf (('/' :) . concat <$> listOf pchar) pathAbsolute :: Gen String-pathAbsolute = ('/':) <$> oneof [return "", pathRootless]+pathAbsolute = ('/' :) <$> oneof [return "", pathRootless] pathNoScheme :: Gen String pathNoScheme = concat <$> sequence [segment1nc, pathAbEmpty] pathRootless :: Gen String-pathRootless = concat <$> sequence [ concat <$> listOf1 pchar- , pathAbEmpty- ]+pathRootless = concat <$> sequence [concat <$> listOf1 pchar, pathAbEmpty] segment1nc :: Gen String-segment1nc = oneof [ replicateM 1 unreserved- , percentEncoded- , replicateM 1 subDelims- , replicateM 1 $ return '@'- ] +segment1nc =+ oneof+ [ replicateM 1 unreserved,+ percentEncoded,+ replicateM 1 subDelims,+ replicateM 1 $ return '@'+ ] pchar :: Gen String-pchar = oneof [ replicateM 1 unreserved- , percentEncoded- , replicateM 1 subDelims- , replicateM 1 $ return ':'- , replicateM 1 $ return '@'- ]+pchar =+ oneof+ [ replicateM 1 unreserved,+ percentEncoded,+ replicateM 1 subDelims,+ replicateM 1 $ return ':',+ replicateM 1 $ return '@'+ ] query :: Gen String-query = fmap (('?':) . concat) $ listOf $ oneof [ pchar- , return "/"- , return "?"- ]+query =+ fmap (('?' :) . concat) $ listOf $ oneof [pchar, return "/", return "?"] fragment :: Gen String-fragment = fmap (('#':) . concat) $ listOf $ oneof [ pchar- , return "/"- , return "?"- ]+fragment =+ fmap (('#' :) . concat) $ listOf $ oneof [pchar, return "/", return "?"] percentEncoded :: Gen String-percentEncoded = ('%':) <$> replicateM 2 hexdig+percentEncoded = ('%' :) <$> replicateM 2 hexdig unreserved :: Gen Char-unreserved = oneof [ alpha, digit, elements ['-', '.', '_', '~']]+unreserved = oneof [alpha, digit, elements ['-', '.', '_', '~']] subDelims :: Gen Char subDelims = elements ['!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=']@@ -186,10 +217,10 @@ -- * RFC 2234 Generators alpha :: Gen Char-alpha = elements $ ['a'..'z'] ++ ['A'..'Z']+alpha = elements $ ['a' .. 'z'] ++ ['A' .. 'Z'] digit :: Gen Char-digit = elements ['0'..'9']+digit = elements ['0' .. '9'] hexdig :: Gen Char-hexdig = oneof [digit, elements ['A'..'F']]+hexdig = oneof [digit, elements ['A' .. 'F']]
test/Network/HTTP/Media/MediaType/ArbitrarySpec.hs view
@@ -1,28 +1,43 @@-{-|-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)+-- |+-- 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 Data.ByteString+ ( null,+ )+import Data.CaseInsensitive+ ( original,+ )+import Network.HTTP.Media.MediaType+ ( mainType,+ subType,+ ) import Network.HTTP.Media.MediaType.Arbitrary ()+import Test.Hspec+ ( Spec,+ describe,+ hspec,+ )+import Test.Hspec.QuickCheck+ ( prop,+ )+import Prelude hiding+ ( null,+ ) 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+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
@@ -1,19 +1,32 @@-{-|-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 ((<=>))+-- |+-- 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 Network.HTTP.Types.Method.Arbitrary ()+import Test.Hspec+ ( Spec,+ describe,+ hspec,+ )+import Test.Hspec.QuickCheck+ ( prop,+ )+import Test.Invariant+ ( (<=>),+ ) main :: IO () main = hspec spec@@ -21,4 +34,7 @@ spec :: Spec spec = describe "properties" $- prop "parseMethod . renderStdMethod <=> Right" $ parseMethod . renderStdMethod <=> Right+ prop "parseMethod . renderStdMethod <=> Right" $+ parseMethod+ . renderStdMethod+ <=> Right
test/Network/URI/ArbitrarySpec.hs view
@@ -1,25 +1,38 @@-{-|-Module : Network.URI.ArbitrarySpec-Description : Tests for Network.URI.Arbitrary-Copyright : (c) Alex Brandt, 2018-License : MIT--Tests for "Network.URI.Arbitrary".--}-module Network.URI.ArbitrarySpec (main, spec) where--import Network.URI (isURIReference, parseURIReference, uriToString)-import Test.Hspec (describe, hspec, Spec)-import Test.Hspec.QuickCheck (prop)+-- |+-- Module : Network.URI.ArbitrarySpec+-- Description : Tests for Network.URI.Arbitrary+-- Copyright : (c) Alex Brandt, 2018+-- License : MIT+--+-- Tests for "Network.URI.Arbitrary".+module Network.URI.ArbitrarySpec+ ( main,+ spec,+ )+where +import Network.URI+ ( isURIReference,+ parseURIReference,+ uriToString,+ ) import Network.URI.Arbitrary ()+import Test.Hspec+ ( Spec,+ describe,+ hspec,+ )+import Test.Hspec.QuickCheck+ ( prop,+ ) main :: IO () main = hspec spec spec :: Spec-spec =- describe "properties" $- do prop "isURIReference (uriToString id u \"\")" $ \ u -> isURIReference (uriToString id u "")+spec = describe "properties" $ do+ prop "isURIReference (uriToString id u \"\")" $+ \u -> isURIReference (uriToString id u "") - prop "Just u == parseURIReference (uriToString id u \"\")" $ \ u -> Just u == parseURIReference (uriToString id u "")+ prop "Just u == parseURIReference (uriToString id u \"\")" $+ \u -> Just u == parseURIReference (uriToString id u "")