genvalidity 0.6.1.0 → 0.7.0.0
raw patch · 4 files changed
+39/−38 lines, 4 filesdep ~validityPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: validity
API changes (from Hackage documentation)
- Data.GenValidity: instance Data.GenValidity.GenInvalid GHC.Types.Double
- Data.GenValidity: instance Data.GenValidity.GenInvalid GHC.Types.Float
- Data.GenValidity: instance Data.GenValidity.GenInvalid a => Data.GenValidity.GenInvalid (GHC.Base.Maybe a)
- Data.GenValidity: instance Data.GenValidity.GenUnchecked a => Data.GenValidity.GenUnchecked (GHC.Base.Maybe a)
- Data.GenValidity: instance Data.GenValidity.GenValid a => Data.GenValidity.GenValid (GHC.Base.Maybe a)
+ Data.GenValidity: instance Data.GenValidity.GenInvalid a => Data.GenValidity.GenInvalid (GHC.Maybe.Maybe a)
+ Data.GenValidity: instance Data.GenValidity.GenUnchecked a => Data.GenValidity.GenUnchecked (GHC.Maybe.Maybe a)
+ Data.GenValidity: instance Data.GenValidity.GenValid a => Data.GenValidity.GenValid (GHC.Maybe.Maybe a)
Files
- genvalidity.cabal +3/−3
- src/Data/GenValidity.hs +16/−15
- test/Data/GenValidity/GenericSpec.hs +2/−2
- test/Data/InstanceSpec.hs +18/−18
genvalidity.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 9a0fdf5334fa38718d2c186fdefbe256697468190ad9f948af82c99a6acefb9a+-- hash: 9b00e65ce180dc767c7ee1031353879db6eb806eb0874294da45b3e3c9e9fcbc name: genvalidity-version: 0.6.1.0+version: 0.7.0.0 synopsis: Testing utilities for the validity library description: Note: There are companion instance packages for this library: .@@ -55,7 +55,7 @@ build-depends: QuickCheck >=2.7 , base >=4.7 && <5- , validity >=0.8+ , validity >=0.9 if impl(ghc >=8.0.0) ghc-options: -Wno-redundant-constraints default-language: Haskell2010
src/Data/GenValidity.hs view
@@ -46,6 +46,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE MultiWayIf #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE CPP #-} #if __GLASGOW_HASKELL__ >= 710@@ -108,7 +109,7 @@ -- -- > {-# LANGUAGE DeriveGeneric #-} -- >--- > data MyType = MyType Double String+-- > data MyType = MyType Rational String -- > deriving (Show, Eq, Generic) -- > -- > instance GenUnchecked MyType@@ -547,34 +548,34 @@ instance GenValid Word64 instance GenUnchecked Float where- genUnchecked = arbitrary+ genUnchecked = frequency [(9, arbitrary), (1, elements [read "NaN", read "Infinity", read "-Infinity", read "-0"])] #if MIN_VERSION_QuickCheck(2,9,2)- shrinkUnchecked = shrink+ shrinkUnchecked f = if+ | isInfinite f -> []+ | isNaN f -> []+ | otherwise -> shrink f #else shrinkUnchecked _ = [] #endif instance GenValid Float where- genValid = arbitrary---- | Either 'NaN' or 'Infinity'.-instance GenInvalid Float where- genInvalid = elements [read "NaN", read "Infinity", read "-Infinity"]+ genValid = genUnchecked+ shrinkValid = shrinkUnchecked instance GenUnchecked Double where- genUnchecked = frequency [(9, genValid), (1, genInvalid)]+ genUnchecked = frequency [(9, arbitrary), (1, elements [read "NaN", read "Infinity", read "-Infinity", read "-0"])] #if MIN_VERSION_QuickCheck(2,9,2)- shrinkUnchecked = shrink+ shrinkUnchecked d = if+ | isInfinite d -> []+ | isNaN d -> []+ | otherwise -> shrink d #else shrinkUnchecked _ = [] #endif instance GenValid Double where- genValid = arbitrary---- | Either 'NaN' or 'Infinity'.-instance GenInvalid Double where- genInvalid = elements [read "NaN", read "Infinity", read "-Infinity"]+ genValid = genUnchecked+ shrinkValid = shrinkUnchecked instance GenUnchecked Integer where genUnchecked = arbitrary
test/Data/GenValidity/GenericSpec.hs view
@@ -42,7 +42,7 @@ genValidstructurallySpec proxy = it (unwords ["only generates valid", "\"" ++ nameOf proxy ++ "\"s"]) $ forAll (genValidStructurally :: Gen a) $ \a ->- case prettyValidation a of+ case prettyValidate a of Right _ -> return () Left err -> expectationFailure $@@ -71,7 +71,7 @@ it (unwords ["only shrinks to valid", "\"" ++ nameOf proxy ++ "\"s"]) $ forAll (genValid :: Gen a) $ \a -> forM_ (shrinkValidStructurally a) $ \subA ->- case prettyValidation subA of+ case prettyValidate subA of Right _ -> return () Left err -> expectationFailure $
test/Data/InstanceSpec.hs view
@@ -44,17 +44,17 @@ twoTests (Proxy :: Proxy Int32) twoTests (Proxy :: Proxy Int64) twoTests (Proxy :: Proxy Integer)- threeTests (Proxy :: Proxy Float)- threeTupleTests (Proxy :: Proxy Float)- threeTests (Proxy :: Proxy Double)- threeTupleTests (Proxy :: Proxy Double)+ twoTests (Proxy :: Proxy Float)+ twoTupleTests (Proxy :: Proxy Float)+ twoTests (Proxy :: Proxy Double)+ twoTupleTests (Proxy :: Proxy Double) threeTests (Proxy :: Proxy Rational) threeTupleTests (Proxy :: Proxy Rational) modifyMaxSize (`quot` 2) $- threeTests (Proxy :: Proxy (Either Double Double))- threeTests (Proxy :: Proxy (Maybe Double))- threeTests (Proxy :: Proxy (Maybe (Maybe Double)))- threeTests (Proxy :: Proxy [Double])+ threeTests (Proxy :: Proxy (Either Rational Rational))+ threeTests (Proxy :: Proxy (Maybe Rational))+ threeTests (Proxy :: Proxy (Maybe (Maybe Rational)))+ threeTests (Proxy :: Proxy [Rational]) threeTests (Proxy :: Proxy (Ratio Integer)) threeTests (Proxy :: Proxy (Ratio Integer)) threeTupleTests (Proxy :: Proxy (Ratio Integer))@@ -84,7 +84,7 @@ twoTupleTests (Proxy :: Proxy (Ratio Int)) #endif #if MIN_VERSION_base(4,9,0)- threeTests (Proxy :: Proxy (NonEmpty Double))+ threeTests (Proxy :: Proxy (NonEmpty Rational)) #endif twoTupleTests :: forall a. (Show a, Eq a, Typeable a, GenValid a)@@ -137,7 +137,7 @@ it (unwords ["genUnchecked of", nameOf proxy, "does not crash while validating"]) $ forAll genUnchecked $ \a ->- case prettyValidation (a :: a) of+ case prettyValidate (a :: a) of Right v -> seq v True Left err -> seq err True modifyMaxSuccess (`quot` 5) $@@ -149,7 +149,7 @@ ]) $ forAll genUnchecked $ \a -> forM_ (shrinkUnchecked a) $ \v ->- case prettyValidation (v :: a) of+ case prettyValidate (v :: a) of Right v_ -> seq v_ $ pure () :: IO () Left err -> seq err $ pure () modifyMaxSuccess (`quot` 5) $@@ -163,7 +163,7 @@ forM_ (shrinkUnchecked a) $ \a' -> unless (a /= a') $ expectationFailure $- unlines ["The value", show( a ::a), "was shrunk to itself"]+ unlines ["The value", show (a :: a), "was shrunk to itself"] genValidTest :: forall a. (Show a, Eq a, Typeable a, GenValid a)@@ -172,7 +172,7 @@ genValidTest proxy = do it (unwords ["genValid of", nameOf proxy, "generates only valid values"]) $ forAll genValid $ \a ->- case prettyValidation (a :: a) of+ case prettyValidate (a :: a) of Right v -> seq v $ pure () Left err -> expectationFailure $@@ -191,7 +191,7 @@ ]) $ forAll genValid $ \a -> forM_ (shrinkValid a) $ \v ->- case prettyValidation (v :: a) of+ case prettyValidate (v :: a) of Right v_ -> seq v_ $ pure () Left err -> expectationFailure $@@ -210,7 +210,7 @@ ]) $ forAll genValid $ \a -> forM_ (shrinkValid a) $ \v ->- case prettyValidation (v :: a) of+ case prettyValidate (v :: a) of Right v_ -> seq v_ $ pure () :: IO () Left err -> seq err $ pure () modifyMaxSuccess (`quot` 5) $@@ -230,7 +230,7 @@ genInvalidTest proxy = do it (unwords ["genInvalid of", nameOf proxy, "generates only invalid values"]) $ forAll genInvalid $ \a ->- case prettyValidation (a :: a) of+ case prettyValidate (a :: a) of Right _ -> expectationFailure $ unlines@@ -245,7 +245,7 @@ ]) $ forAll genInvalid $ \a -> forM_ (shrinkInvalid a) $ \v ->- case prettyValidation (v :: a) of+ case prettyValidate (v :: a) of Right _ -> expectationFailure $ unlines@@ -262,7 +262,7 @@ ]) $ forAll genInvalid $ \a -> forM_ (shrinkInvalid a) $ \v ->- case prettyValidation (v :: a) of+ case prettyValidate (v :: a) of Right _ -> expectationFailure $ unlines