packages feed

network-uri-json 0.1.1.0 → 0.1.2.0

raw patch · 5 files changed

+16/−229 lines, 5 filesdep +network-arbitraryPVP ok

version bump matches the API change (PVP)

Dependencies added: network-arbitrary

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,5 +1,9 @@ # Revision history for network-uri-json +## 0.1.2.0  -- 2018-01-06++* Externalize network-arbitrary dependency+ ## 0.1.1.0  -- 2017-12-21  * Bump dependencies on aeson and QuickCheck
network-uri-json.cabal view
@@ -1,9 +1,9 @@ name:                network-uri-json-version:             0.1.1.0+version:             0.1.2.0 synopsis:            FromJSON and ToJSON Instances for Network.URI  description:-  FromJSON and ToJSON instancse for Network.URI.+  FromJSON and ToJSON instances for Network.URI.  homepage:            https://github.com/alunduil/network-uri-json bug-reports:         https://github.com/alunduil/network-uri-json/issues@@ -65,22 +65,21 @@     , test    other-modules:-      External.Network.URI.Arbitrary-    , External.Network.URI.ArbitrarySpec-    , Network.URI.JSON+      Network.URI.JSON     , Network.URI.JSONSpec    build-tool-depends:       hspec-discover:hspec-discover == 2.4.*    build-depends:-      aeson          >= 0.8 && < 1.3-    , base           >= 4.6 && < 4.12-    , hspec          == 2.4.*-    , network-uri    == 2.6.*-    , QuickCheck     >= 2.9 && < 2.11-    , test-invariant == 0.4.*-    , text           == 1.2.*+      aeson             >= 0.8 && < 1.3+    , base              >= 4.6 && < 4.12+    , hspec             == 2.4.*+    , network-arbitrary == 0.1.*+    , network-uri       == 2.6.*+    , QuickCheck        >= 2.9 && < 2.11+    , test-invariant    == 0.4.*+    , text              == 1.2.*    other-extensions:       OverloadedStrings
− test/External/Network/URI/Arbitrary.hs
@@ -1,191 +0,0 @@-{-# LANGUAGE RecordWildCards #-}--{-# OPTIONS_GHC -fno-warn-orphans #-}--{-|-Module      : External.Network.URI.Arbitrary-Description : Arbitrary Instances for Network.URI-Copyright   : (c) Alex Brandt, 2017-License     : MIT--Arbitrary instances for "Network.URI".--}-module External.Network.URI.Arbitrary () where--import Control.Applicative ((<$>), (<*>))-import Control.Monad (replicateM)-import Data.List (intercalate)-import Network.URI (URI (..), URIAuth (..))-import Test.QuickCheck (Arbitrary (arbitrary, shrink), choose, elements, Gen, 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]--  shrink URI{..} = [ URI uriScheme' uriAuthority' uriPath' uriQuery' uriFragment' | (uriScheme', uriAuthority', uriPath', uriQuery', uriFragment') <- shrink (uriScheme, uriAuthority, uriPath, uriQuery, uriFragment) ]--instance Arbitrary URIAuth where-  arbitrary = URIAuth <$> userinfo-                      <*> host `suchThat` (not . null)-                      <*> port--  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.--scheme :: Gen String-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-                                   ]--host :: Gen String-host = oneof [ ipLiteral-             , ipv4Address-             , regName-             ]--port :: Gen String-port =-  do p <- listOf digit-     if null p-        then return ""-        else return $ ':':p--ipLiteral :: Gen String-ipLiteral =-  do x <- oneof [ ipv6Address-                --, ipvFuture-                ]-     return $ "[" ++ x ++ "]"--{- TODO Check that "Network.URI" implements this correctly.-ipvFuture :: Gen String-ipvFuture =-  do h <- hexdig-     o <- oneof [ unreserved, subDelims, return ':' ]-     return ['v', h, '.', o]--}--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--h16 :: Gen String-h16 = replicateM 4 hexdig--ls32 :: Gen String-ls32 = oneof [ intercalate ":" <$> replicateM 2 h16-             , ipv4Address-             ]--ipv4Address :: Gen String-ipv4Address = intercalate "." <$> replicateM 4 decOctet--decOctet :: Gen String-decOctet = (show :: Int -> String) <$> choose (0, 255)--regName :: Gen String-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--pathAbEmpty :: Gen String-pathAbEmpty = concat <$> listOf ((('/':) . concat) <$> listOf pchar)--pathAbsolute :: Gen String-pathAbsolute = ('/':) <$> oneof [return "", pathRootless]--pathNoScheme :: Gen String-pathNoScheme = concat <$> sequence [segment1nc, pathAbEmpty]--pathRootless :: Gen String-pathRootless = concat <$> sequence [ concat <$> listOf1 pchar-                                   , pathAbEmpty-                                   ]--segment1nc :: Gen String-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 '@'-              ]--query :: Gen String-query = fmap (('?':) . concat) $ listOf $ oneof [ pchar-                                                , return "/"-                                                , return "?"-                                                ]--fragment :: Gen String-fragment = fmap (('#':) . concat) $ listOf $ oneof [ pchar-                                                   , return "/"-                                                   , return "?"-                                                   ]--percentEncoded :: Gen String-percentEncoded = ('%':) <$> replicateM 2 hexdig--unreserved :: Gen Char-unreserved = oneof [ alpha, digit, elements ['-', '.', '_', '~']]--subDelims :: Gen Char-subDelims = elements ['!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=']---- * RFC 2234 Generators--alpha :: Gen Char-alpha = elements $ ['a'..'z'] ++ ['A'..'Z']--digit :: Gen Char-digit = elements ['0'..'9']--hexdig :: Gen Char-hexdig = oneof [digit, elements ['A'..'F']]
− test/External/Network/URI/ArbitrarySpec.hs
@@ -1,25 +0,0 @@-{-|-Module      : External.Network.URI.ArbitrarySpec-Description : Tests for External.Network.URI.Arbitrary-Copyright   : (c) Alex Brandt, 2017-License     : MIT--Tests for "External.Network.URI.Arbitrary".--}-module External.Network.URI.ArbitrarySpec (main, spec) where--import Network.URI (isURIReference, parseURIReference, uriToString)-import Test.Hspec (describe, hspec, Spec)-import Test.Hspec.QuickCheck (prop)--import External.Network.URI.Arbitrary ()--main :: IO ()-main = hspec spec--spec :: Spec-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 "")
test/Network/URI/JSONSpec.hs view
@@ -10,12 +10,12 @@  import Data.Aeson (decode, encode) import Data.Maybe (fromJust)+import Network.URI.Arbitrary () import Network.URI (URI) import Test.Hspec (describe, hspec, Spec) import Test.Hspec.QuickCheck (prop) import Test.Invariant ((<=>)) -import External.Network.URI.Arbitrary () import Network.URI.JSON ()  main :: IO ()