genvalidity-property 0.2.1.0 → 0.2.1.1
raw patch · 3 files changed
+111/−14 lines, 3 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Test.Validity.Shrinking.Property: doesNotShrinkToItself :: forall a. (Show a, Eq a) => Gen a -> (a -> [a]) -> Property
+ Test.Validity.Shrinking.Property: doesNotShrinkToItselfWithLimit :: forall a. (Show a, Eq a) => Gen a -> (a -> [a]) -> Int -> Property
+ Test.Validity.Shrinking.Property: shrinkDoesNotShrinkToItself :: forall a. (Show a, Eq a, GenUnchecked a) => (a -> [a]) -> Property
+ Test.Validity.Shrinking.Property: shrinkDoesNotShrinkToItselfOnInvalid :: forall a. (Show a, Eq a, GenInvalid a) => (a -> [a]) -> Property
+ Test.Validity.Shrinking.Property: shrinkDoesNotShrinkToItselfOnInvalidWithLimit :: forall a. (Show a, Eq a, GenInvalid a) => (a -> [a]) -> Int -> Property
+ Test.Validity.Shrinking.Property: shrinkDoesNotShrinkToItselfOnValid :: forall a. (Show a, Eq a, GenValid a) => (a -> [a]) -> Property
+ Test.Validity.Shrinking.Property: shrinkDoesNotShrinkToItselfOnValidWithLimit :: forall a. (Show a, Eq a, GenValid a) => (a -> [a]) -> Int -> Property
+ Test.Validity.Shrinking.Property: shrinkDoesNotShrinkToItselfWithLimit :: forall a. (Show a, Eq a, GenUnchecked a) => (a -> [a]) -> Int -> Property
+ Test.Validity.Shrinking.Property: shrinkingPreservesWithLimit :: forall a. Show a => Gen a -> (a -> [a]) -> Int -> (a -> Bool) -> Property
Files
- genvalidity-property.cabal +12/−12
- src/Test/Validity/Operations/Commutativity.hs +2/−2
- src/Test/Validity/Shrinking/Property.hs +97/−0
genvalidity-property.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: b4c5c1e25f8ffaebf6e2edb821c698f82733cba7a41bfbbcf6d3b25be2e13734+-- hash: 7b970b7101085c6f2eda0c57833c5b53113e75326b5b1d24faeef8e6b4d102a1 name: genvalidity-property-version: 0.2.1.0+version: 0.2.1.1 synopsis: Standard properties for functions on `Validity` types description: Standard properties for functions on `Validity` types category: Testing@@ -25,14 +25,6 @@ location: https://github.com/NorfairKing/validity library- hs-source-dirs:- src- build-depends:- QuickCheck- , base >=4.7 && <5- , genvalidity >=0.5- , hspec >=2.1- , validity >=0.5 exposed-modules: Test.Validity.Functions Test.Validity.Functions.CanFail@@ -57,11 +49,21 @@ Test.Validity.Types other-modules: Paths_genvalidity_property+ hs-source-dirs:+ src+ build-depends:+ QuickCheck+ , base >=4.7 && <5+ , genvalidity >=0.5+ , hspec >=2.1+ , validity >=0.5 default-language: Haskell2010 test-suite genvalidity-property-doctests type: exitcode-stdio-1.0 main-is: DocTest.hs+ other-modules:+ Paths_genvalidity_property hs-source-dirs: doctest ghc-options: -threaded@@ -71,6 +73,4 @@ , doctest , filepath >=1.3 && <1.5 , genvalidity-property- other-modules:- Paths_genvalidity_property default-language: Haskell2010
src/Test/Validity/Operations/Commutativity.hs view
@@ -32,8 +32,8 @@ -- | ----- prop> commutative ((+) :: Double -> Double -> Double)--- prop> commutative ((*) :: Double -> Double -> Double)+-- prop> commutativeOnValids ((+) :: Double -> Double -> Double)+-- prop> commutativeOnValids ((*) :: Double -> Double -> Double) commutativeOnValids :: (Show a, Eq a, GenValid a) => (a -> a -> a) -> Property commutativeOnValids op = commutativeOnGens op genValid shrinkValid
src/Test/Validity/Shrinking/Property.hs view
@@ -12,6 +12,15 @@ , shrinkingStaysValidWithLimit , shrinkingStaysInvalid , shrinkingPreserves+ , shrinkingPreservesWithLimit+ , shrinkDoesNotShrinkToItself+ , shrinkDoesNotShrinkToItselfWithLimit+ , shrinkDoesNotShrinkToItselfOnValid+ , shrinkDoesNotShrinkToItselfOnValidWithLimit+ , shrinkDoesNotShrinkToItselfOnInvalid+ , shrinkDoesNotShrinkToItselfOnInvalidWithLimit+ , doesNotShrinkToItself+ , doesNotShrinkToItselfWithLimit ) where import Data.GenValidity@@ -64,6 +73,9 @@ -> Property shrinkingStaysValid gen s = shrinkingPreserves gen s isValid +-- |+--+-- prop> shrinkingStaysValidWithLimit (pure 5 :: Gen Double) (\d -> [d - 1, read "NaN"]) 1 shrinkingStaysValidWithLimit :: forall a. (Show a, Validity a) => Gen a@@ -94,6 +106,9 @@ -> Property shrinkingPreserves gen s p = forAll gen $ \d -> not (p d) || all p (s d) +-- |+--+-- prop> shrinkingPreservesWithLimit (pure 4) (:[]) 100 (== 4) shrinkingPreservesWithLimit :: forall a. Show a => Gen a@@ -103,3 +118,85 @@ -> Property shrinkingPreservesWithLimit gen s l p = forAll gen $ \d -> not (p d) || all p (take l $ s d)++-- |+--+-- prop> shrinkDoesNotShrinkToItself shrinkUnchecked+shrinkDoesNotShrinkToItself ::+ forall a. (Show a, Eq a, GenUnchecked a)+ => (a -> [a])+ -> Property+shrinkDoesNotShrinkToItself = doesNotShrinkToItself genUnchecked++-- |+--+-- prop> shrinkDoesNotShrinkToItselfWithLimit shrinkUnchecked 100+shrinkDoesNotShrinkToItselfWithLimit ::+ forall a. (Show a, Eq a, GenUnchecked a)+ => (a -> [a])+ -> Int+ -> Property+shrinkDoesNotShrinkToItselfWithLimit =+ doesNotShrinkToItselfWithLimit genUnchecked++-- |+--+-- prop> shrinkDoesNotShrinkToItselfOnValid shrinkValid+shrinkDoesNotShrinkToItselfOnValid ::+ forall a. (Show a, Eq a, GenValid a)+ => (a -> [a])+ -> Property+shrinkDoesNotShrinkToItselfOnValid = doesNotShrinkToItself genValid++-- |+--+-- prop> shrinkDoesNotShrinkToItselfOnValidWithLimit shrinkValid 100+shrinkDoesNotShrinkToItselfOnValidWithLimit ::+ forall a. (Show a, Eq a, GenValid a)+ => (a -> [a])+ -> Int+ -> Property+shrinkDoesNotShrinkToItselfOnValidWithLimit =+ doesNotShrinkToItselfWithLimit genValid++-- |+--+-- prop> shrinkDoesNotShrinkToItselfOnInvalid shrinkInvalid+shrinkDoesNotShrinkToItselfOnInvalid ::+ forall a. (Show a, Eq a, GenInvalid a)+ => (a -> [a])+ -> Property+shrinkDoesNotShrinkToItselfOnInvalid = doesNotShrinkToItself genInvalid++-- |+--+-- prop> shrinkDoesNotShrinkToItselfOnInvalidWithLimit shrinkInvalid 100+shrinkDoesNotShrinkToItselfOnInvalidWithLimit ::+ forall a. (Show a, Eq a, GenInvalid a)+ => (a -> [a])+ -> Int+ -> Property+shrinkDoesNotShrinkToItselfOnInvalidWithLimit =+ doesNotShrinkToItselfWithLimit genInvalid++-- |+--+-- prop> doesNotShrinkToItself (pure 5) shrinkUnchecked+doesNotShrinkToItself ::+ forall a. (Show a, Eq a)+ => Gen a+ -> (a -> [a])+ -> Property+doesNotShrinkToItself gen s = forAll gen $ \a -> all (/= a) $ s a++-- |+--+-- prop> doesNotShrinkToItselfWithLimit (pure 5) shrinkUnchecked 100+doesNotShrinkToItselfWithLimit ::+ forall a. (Show a, Eq a)+ => Gen a+ -> (a -> [a])+ -> Int+ -> Property+doesNotShrinkToItselfWithLimit gen s l =+ forAll gen $ \a -> all (/= a) $ take l $ s a