packages feed

genvalidity-property 0.2.0.2 → 0.2.1.0

raw patch · 4 files changed

+47/−21 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Test.Validity.Shrinking.Property: shrinkingStaysValidWithLimit :: forall a. (Show a, Validity a) => Gen a -> (a -> [a]) -> Int -> Property

Files

doctest/DocTest.hs view
@@ -17,8 +17,8 @@ listFilesRecur :: FilePath -> IO [FilePath] listFilesRecur dir = do     entries <--        (map (dir </>) .-         filter (\f -> f /= "." && f /= ".." && takeExtension f /= ".swp")) <$>+        map (dir </>) .+        filter (\f -> f /= "." && f /= ".." && takeExtension f /= ".swp") <$>         getDirectoryContents dir     dirs <- filterM doesDirectoryExist entries     files <- filterM doesFileExist entries
genvalidity-property.cabal view
@@ -1,18 +1,19 @@--- This file has been generated from package.yaml by hpack version 0.20.0.+-- This file has been generated from package.yaml by hpack version 0.28.2. -- -- see: https://github.com/sol/hpack ----- hash: aae9c606fdf34070a15eb4769cec6a4dc52565cb0fc08d3b2afc5f8e5add661b+-- hash: b4c5c1e25f8ffaebf6e2edb821c698f82733cba7a41bfbbcf6d3b25be2e13734  name:           genvalidity-property-version:        0.2.0.2+version:        0.2.1.0 synopsis:       Standard properties for functions on `Validity` types description:    Standard properties for functions on `Validity` types category:       Testing homepage:       https://github.com/NorfairKing/validity#readme bug-reports:    https://github.com/NorfairKing/validity/issues author:         Tom Sydney Kerckhove-maintainer:     syd.kerckhove@gmail.com+maintainer:     syd.kerckhove@gmail.com,+                nick.van.den.broeck666@gmail.com copyright:      Copyright: (c) 2016-2018 Tom Sydney Kerckhove license:        MIT license-file:   LICENSE
src/Test/Validity/Property/Utils.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE CPP #-}+ module Test.Validity.Property.Utils     ( forAllUnchecked     , forAllValid@@ -8,13 +10,12 @@     , (===>)     ) where -import Control.Monad (unless)-+import Data.GenValidity import Test.Hspec import Test.QuickCheck--import Data.GenValidity-+#if !MIN_VERSION_base(4,8,0)+import Control.Applicative (pure)+#endif forAllUnchecked ::        (Show a, GenUnchecked a, Testable prop) => (a -> prop) -> Property forAllUnchecked = forAllShrink genUnchecked shrinkUnchecked@@ -33,23 +34,27 @@ (<==>) a b = a ===> b && b ===> a  shouldBeValid :: (Show a, Validity a) => a -> Expectation-shouldBeValid a = do+shouldBeValid a =     case prettyValidation a of         Right _ -> pure ()         Left err ->             expectationFailure $             unlines-                [ "'validate' reported this value to be invalid: " ++ show a+                [ "'validate' reported this value to be invalid: "+                , show a+                , "with explanation"                 , err                 , ""                 ]-    unless (isValid a) $-        expectationFailure $-        unlines-            [ "isValid considered this value invalid: " ++ show a-            , "This is odd because 'validate' reported no issues."-            , "Are you sure 'Validity' is implemented correctly?"-            ]  shouldBeInvalid :: (Show a, Validity a) => a -> Expectation-shouldBeInvalid a = a `shouldNotSatisfy` isValid+shouldBeInvalid a =+    case prettyValidation a of+        Right _ ->+            expectationFailure $+            unlines+                [ "'validate' reported this value to be valid: "+                , show a+                , "where we expected it to be invalid"+                ]+        Left _ -> pure ()
src/Test/Validity/Shrinking/Property.hs view
@@ -9,6 +9,7 @@     , shrinkValidPreservesValid     , shrinkInvalidPreservesInvalid     , shrinkingStaysValid+    , shrinkingStaysValidWithLimit     , shrinkingStaysInvalid     , shrinkingPreserves     ) where@@ -63,6 +64,15 @@     -> Property shrinkingStaysValid gen s = shrinkingPreserves gen s isValid +shrinkingStaysValidWithLimit ::+       forall a. (Show a, Validity a)+    => Gen a+    -> (a -> [a])+    -> Int+    -> Property+shrinkingStaysValidWithLimit gen s l =+    shrinkingPreservesWithLimit gen s l isValid+ -- | -- -- prop> shrinkingStaysInvalid (pure (1/0) :: Gen Double) (:[])@@ -83,3 +93,13 @@     -> (a -> Bool)     -> Property shrinkingPreserves gen s p = forAll gen $ \d -> not (p d) || all p (s d)++shrinkingPreservesWithLimit ::+       forall a. Show a+    => Gen a+    -> (a -> [a])+    -> Int+    -> (a -> Bool)+    -> Property+shrinkingPreservesWithLimit gen s l p =+    forAll gen $ \d -> not (p d) || all p (take l $ s d)