genvalidity-hspec 0.2.0.0 → 0.2.0.1
raw patch · 2 files changed
+73/−5 lines, 2 filesdep ~validityPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
Dependency ranges changed: validity
API changes (from Hackage documentation)
+ Test.Validity: failsOnGens2 :: (Show a, Show b, Show c, Show (f c), CanFail f) => (a -> b -> f c) -> Gen a -> Gen b -> Property
+ Test.Validity: failsOnInvalidInput2 :: (Show a, Show b, Show c, Show (f c), GenValidity a, GenValidity b, CanFail f) => (a -> b -> f c) -> Property
+ Test.Validity: succeedsOnGens2 :: (Show a, Show b, Show c, Show (f c), CanFail f) => (a -> b -> f c) -> Gen a -> Gen b -> Property
+ Test.Validity: succeedsOnValidInput2 :: (Show a, Show b, Show c, Show (f c), GenValidity a, GenValidity b, CanFail f) => (a -> b -> f c) -> Property
+ Test.Validity: validIfSucceeds2 :: (Show a, Show b, Show c, Show (f c), GenValidity a, GenValidity b, Validity c, CanFail f) => (a -> b -> f c) -> Property
+ Test.Validity: validIfSucceedsOnGens2 :: (Show a, Show b, Show c, Show (f c), Validity c, CanFail f) => (a -> b -> f c) -> Gen a -> Gen b -> Property
Files
- genvalidity-hspec.cabal +2/−2
- src/Test/Validity.hs +71/−3
genvalidity-hspec.cabal view
@@ -1,5 +1,5 @@ name: genvalidity-hspec-version: 0.2.0.0+version: 0.2.0.1 synopsis: Standard spec's for GenValidity instances description: Please see README.md homepage: https://github.com/NorfairKing/validity#readme@@ -17,7 +17,7 @@ hs-source-dirs: src exposed-modules: Test.Validity build-depends: base < 5- , validity >= 0.2 && < 0.3+ , validity >= 0.3 && < 0.4 , genvalidity , QuickCheck , hspec >= 2.2 && < 2.3
src/Test/Validity.hs view
@@ -40,6 +40,12 @@ , failsOnInvalidInput , validIfSucceedsOnGen , validIfSucceeds+ , succeedsOnGens2+ , succeedsOnValidInput2+ , failsOnGens2+ , failsOnInvalidInput2+ , validIfSucceedsOnGens2+ , validIfSucceeds2 ) where import Data.Proxy@@ -381,11 +387,73 @@ -- | The function produces output that satisfies @isValid@ if it is given input -- that is generated by @genUnchecked@. validIfSucceeds- :: (Show a, Show b, Show (f b), GenValidity a, Validity b, CanFail f)- => (a -> f b)- -> Property+ :: (Show a, Show b, Show (f b), GenValidity a, Validity b, CanFail f)+ => (a -> f b)+ -> Property validIfSucceeds = (`validIfSucceedsOnGen` genUnchecked) +succeedsOnGens2+ :: (Show a, Show b, Show c, Show (f c),+ CanFail f)+ => (a -> b -> f c)+ -> Gen a -> Gen b+ -> Property+succeedsOnGens2 func genA genB =+ forAll genA $ \a ->+ forAll genB $ \b ->+ func a b `shouldNotSatisfy` hasFailed++succeedsOnValidInput2+ :: (Show a, Show b, Show c, Show (f c),+ GenValidity a, GenValidity b,+ CanFail f)+ => (a -> b -> f c)+ -> Property+succeedsOnValidInput2 func+ = succeedsOnGens2 func genValid genValid++failsOnGens2+ :: (Show a, Show b, Show c, Show (f c),+ CanFail f)+ => (a -> b -> f c)+ -> Gen a -> Gen b+ -> Property+failsOnGens2 func genA genB =+ forAll genA $ \a ->+ forAll genB $ \b ->+ func a b `shouldSatisfy` hasFailed++failsOnInvalidInput2+ :: (Show a, Show b, Show c, Show (f c),+ GenValidity a, GenValidity b,+ CanFail f)+ => (a -> b -> f c)+ -> Property+failsOnInvalidInput2 func+ = failsOnGens2 func genInvalid genUnchecked+ .&&. failsOnGens2 func genUnchecked genInvalid++validIfSucceedsOnGens2+ :: (Show a, Show b, Show c, Show (f c),+ Validity c, CanFail f)+ => (a -> b -> f c)+ -> Gen a -> Gen b+ -> Property+validIfSucceedsOnGens2 func genA genB =+ forAll genA $ \a ->+ forAll genB $ \b ->+ case resultIfSucceeded (func a b) of+ Nothing -> return () -- Can happen+ Just res -> res `shouldSatisfy` isValid++validIfSucceeds2+ :: (Show a, Show b, Show c, Show (f c),+ GenValidity a, GenValidity b,+ Validity c, CanFail f)+ => (a -> b -> f c)+ -> Property+validIfSucceeds2 func+ = validIfSucceedsOnGens2 func genUnchecked genUnchecked nameOf :: Typeable a => Proxy a -> String nameOf proxy =