packages feed

explainable-predicates 0.1.1.0 → 0.1.2.0

raw patch · 5 files changed

+42/−7 lines, 5 filesdep +HUnitPVP ok

version bump matches the API change (PVP)

Dependencies added: HUnit

API changes (from Hackage documentation)

+ Test.Predicates.HUnit: (@?~) :: a -> Predicate a -> Assertion
+ Test.Predicates.HUnit: assertSatisfied :: Predicate a -> a -> Assertion
+ Test.Predicates.HUnit: shouldSatisfy :: a -> Predicate a -> Assertion

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for explainable-predicates +## 0.1.2.0 -- 2021-09-25++* HUnit and Hspec integration is now available in `Test.Predicates.HUnit`.+ ## 0.1.1.0 -- 2021-09-25  * `Predicate` now has a `Contravariant` instance.
explainable-predicates.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               explainable-predicates-version:            0.1.1.0+version:            0.1.2.0 synopsis:           Predicates that can explain themselves. description:        Explainable predicates are essentially functions from types                     to 'Bool' which can additionally describe themselves and@@ -41,6 +41,11 @@     manual:            True     default:           True +flag hunit+    description:       Enable HUnit/Hspec integration+    manual:            True+    default:           True+ flag dev     description:       Developer build     manual:            True@@ -69,6 +74,10 @@     if flag(quickcheck)         build-depends:   QuickCheck >= 2.8 && < 2.15,         exposed-modules: Test.Predicates.QuickCheck++    if flag(hunit)+        build-depends:   HUnit >= 1.3.0 && < 1.7,+        exposed-modules: Test.Predicates.HUnit      if flag(dev)         ghc-options:     -Werror
src/Test/Predicates.hs view
@@ -1250,7 +1250,7 @@  -- | A combinator to lift a 'Predicate' to work on a property or computed value -- of the original value.  The explanations are less helpful that standard--- predicates like 'size'.  You can use 'qWith' instead to get better+-- predicates like 'sizeIs'.  You can use 'qWith' instead to get better -- explanations using Template Haskell. -- -- >>> accept (with abs (gt 5)) (-6)@@ -1331,7 +1331,7 @@         _ -> "Branch didn't match"     } --- A Template Haskell splice which, given a constructor for an abstract data+-- | A Template Haskell splice which, given a constructor for an abstract data -- type, writes a 'Predicate' that matches on that constructor and applies other -- 'Predicate's to its fields. --
+ src/Test/Predicates/HUnit.hs view
@@ -0,0 +1,17 @@+-- | HUnit and Hspec integration for 'Predicate'+module Test.Predicates.HUnit (assertSatisfied, (@?~), shouldSatisfy) where++import Test.HUnit (Assertion, assertFailure)+import Test.Predicates (Predicate (accept, explain))++assertSatisfied :: Predicate a -> a -> Assertion+assertSatisfied predicate val =+  if accept predicate val+    then return ()+    else assertFailure (explain predicate val)++(@?~) :: a -> Predicate a -> Assertion+(@?~) = flip assertSatisfied++shouldSatisfy :: a -> Predicate a -> Assertion+shouldSatisfy = flip assertSatisfied
src/Test/Predicates/QuickCheck.hs view
@@ -12,9 +12,14 @@  -- | QuickCheck property that checks if a predicate is satisfied. ----- prop> \(Positive x) -> [0 .. x] `satisfies` (containsAll [eq 1, eq 2])--- *** Failed! Falsified (after 1 test):--- Positive {getPositive = 1}--- Missing: 2+-- @+--   quickCheck $ \(Positive x) -> [0 .. x] 'satisfies' (containsAll [eq 1, eq 2])+-- @+--+-- @+--   *** Failed! Falsified (after 1 test):+--   Positive {getPositive = 1}+--   Missing: 2+-- @ satisfies :: a -> Predicate a -> Property x `satisfies` p = counterexample (explain p x) (accept p x)