packages feed

ip 1.1.0 → 1.1.1

raw patch · 4 files changed

+27/−18 lines, 4 filesdep ~quickcheck-classesPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: quickcheck-classes

API changes (from Hackage documentation)

+ Net.IPv4.Range: range :: IPv4 -> Word8 -> IPv4Range

Files

ip.cabal view
@@ -1,5 +1,5 @@ name: ip-version: 1.1.0+version: 1.1.1 synopsis: Library for IP and MAC addresses homepage: https://github.com/andrewthad/haskell-ip#readme license: BSD3@@ -70,7 +70,7 @@     , test-framework     , test-framework-quickcheck2     , QuickCheck-    , quickcheck-classes+    , quickcheck-classes >= 0.3 && < 0.4     , text     , bytestring     , HUnit
src/Net/IPv4.hs view
@@ -399,12 +399,12 @@ instance FromJSON IPv4 where   parseJSON = Aeson.withText "IPv4" aesonParser +#if MIN_VERSION_aeson(1,0,0)  instance ToJSONKey IPv4 where   toJSONKey = ToJSONKeyText     encode     (\addr -> Aeson.unsafeToEncoding $ BB.char7 '"' <> builderUtf8 addr <> BB.char7 '"') -#if MIN_VERSION_aeson(1,0,0)  instance FromJSONKey IPv4 where   fromJSONKey = FromJSONKeyTextParser aesonParser #endif
src/Net/IPv4/Range.hs view
@@ -8,7 +8,8 @@ {-# OPTIONS_GHC -Wall #-} module Net.IPv4.Range   ( -- * Range functions-    normalize+    range+  , normalize   , contains   , member   , lowerInclusive@@ -65,6 +66,11 @@ -- >>> instance Arbitrary IPv4 where { arbitrary = fmap IPv4 arbitrary } -- >>> instance Arbitrary IPv4Range where { arbitrary = IPv4Range <$> arbitrary <*> arbitrary } --++-- | Smart constructor for 'IPv4Range'. Ensures the mask is appropriately+--   sized and sets masked bits in the 'IPv4' to zero.+range :: IPv4 -> Word8 -> IPv4Range+range addr len = normalize (IPv4Range addr len)  -- | Checks to see if an 'IPv4' address belongs in the 'IPv4Range'. --
test/Test.hs view
@@ -9,12 +9,12 @@ import Data.Proxy (Proxy(..)) import Test.Framework (defaultMain, testGroup, Test) import Test.Framework.Providers.QuickCheck2 (testProperty)-import Test.QuickCheck (Arbitrary(..),Property,oneof,Gen,elements)+import Test.QuickCheck (Arbitrary(..),Property,oneof,Gen,elements,choose) import Test.HUnit (Assertion,(@?=)) import Numeric (showHex) import Test.QuickCheck.Property (failed,succeeded,Result(..)) import Data.Bifunctor-import Test.QuickCheck.Classes (jsonProps,showReadProps)+import Test.QuickCheck.Classes (Laws(..),jsonLaws,showReadLaws) import qualified Test.Framework.Providers.HUnit as PH  import Net.Types (IP,IPv4(..),IPv4Range(..),Mac(..),IPv6(..),MacGrouping(..),MacCodec(..))@@ -97,26 +97,30 @@     ]   , testGroup "Instances"     [ testGroup "IPv4"-      [ namedPropertiesToTest "JSON" (jsonProps (Proxy :: Proxy IPv4))-      , namedPropertiesToTest "Show Read" (showReadProps (Proxy :: Proxy IPv4))+      [ lawsToTest (jsonLaws (Proxy :: Proxy IPv4))+      , lawsToTest (showReadLaws (Proxy :: Proxy IPv4))       ]+    , testGroup "IPv4Range"+      [ lawsToTest (jsonLaws (Proxy :: Proxy IPv4Range))+      , lawsToTest (showReadLaws (Proxy :: Proxy IPv4Range))+      ]     , testGroup "IPv6"-      [ namedPropertiesToTest "JSON" (jsonProps (Proxy :: Proxy IPv6))-      , namedPropertiesToTest "Show Read" (showReadProps (Proxy :: Proxy IPv6))+      [ lawsToTest (jsonLaws (Proxy :: Proxy IPv6))+      , lawsToTest (showReadLaws (Proxy :: Proxy IPv6))       ]     , testGroup "IP"-      [ namedPropertiesToTest "JSON" (jsonProps (Proxy :: Proxy IP))-      , namedPropertiesToTest "Show Read" (showReadProps (Proxy :: Proxy IP))+      [ lawsToTest (jsonLaws (Proxy :: Proxy IP))+      , lawsToTest (showReadLaws (Proxy :: Proxy IP))       ]     , testGroup "Mac"-      [ namedPropertiesToTest "JSON" (jsonProps (Proxy :: Proxy Mac))-      , namedPropertiesToTest "Show Read" (showReadProps (Proxy :: Proxy Mac))+      [ lawsToTest (jsonLaws (Proxy :: Proxy Mac))+      , lawsToTest (showReadLaws (Proxy :: Proxy Mac))       ]     ]   ] -namedPropertiesToTest :: String -> [(String,Property)] -> Test-namedPropertiesToTest name pairs = testGroup name (map (uncurry testProperty) pairs)+lawsToTest :: Laws -> Test+lawsToTest (Laws name pairs) = testGroup name (map (uncurry testProperty) pairs)  propEncodeDecodeIso :: Eq a => (a -> b) -> (b -> Maybe a) -> a -> Bool propEncodeDecodeIso f g a = g (f a) == Just a@@ -339,8 +343,7 @@ -- This instance can generate masks that exceed the recommended -- length of 32. instance Arbitrary IPv4Range where-  arbitrary = fmap fromTuple arbitrary-    where fromTuple (a,b) = IPv4Range a b+  arbitrary = IPv4Range.range <$> arbitrary <*> choose (0,32)  instance Arbitrary MacCodec where   arbitrary = MacCodec <$> arbitrary <*> arbitrary