property-matchers 0.5.0.0 → 0.6.0.0
raw patch · 4 files changed
+19/−23 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- PropertyMatchers: equals :: (HasCallStack, Eq a) => a -> Prop a
+ PropertyMatchers: equals :: (HasCallStack, Show a, Eq a) => a -> Prop a
- PropertyMatchers: gt :: (HasCallStack, Ord a) => a -> Prop a
+ PropertyMatchers: gt :: (HasCallStack, Show a, Ord a) => a -> Prop a
- PropertyMatchers: gte :: (HasCallStack, Ord a) => a -> Prop a
+ PropertyMatchers: gte :: (HasCallStack, Show a, Ord a) => a -> Prop a
- PropertyMatchers: lt :: (HasCallStack, Ord a) => a -> Prop a
+ PropertyMatchers: lt :: (HasCallStack, Show a, Ord a) => a -> Prop a
- PropertyMatchers: lte :: (HasCallStack, Ord a) => a -> Prop a
+ PropertyMatchers: lte :: (HasCallStack, Show a, Ord a) => a -> Prop a
- PropertyMatchers: notEquals :: (HasCallStack, Eq a) => a -> Prop a
+ PropertyMatchers: notEquals :: (HasCallStack, Show a, Eq a) => a -> Prop a
Files
- CHANGELOG.md +3/−0
- property-matchers.cabal +1/−1
- src/PropertyMatchers.hs +12/−12
- test/PropertyMatchersSpec.hs +3/−10
CHANGELOG.md view
@@ -1,5 +1,8 @@ # Revision history for property-matchers +## 0.6+* Add `Show` constraint to `equals` and other comparison properties to improve error messages in cases where rtti-derived printing is not as good.+ ## 0.5 * Add `notEquals` property. * Delete `atIndex`, `endingWith`, and `startingWith`. These can easily be replaced by prisms via `match`, like with `match (ix k)`, `match _head`, and `match _last`.
property-matchers.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.4 name: property-matchers-version: 0.5.0.0+version: 0.6.0.0 synopsis: A library for tests, based on transforming and writing properties description: This package provides ways to write properties for testing such that they compose nicely and are easy to debug.
src/PropertyMatchers.hs view
@@ -471,45 +471,45 @@ -- | The property of being equal to some expected value. ---equals :: (HasCallStack, Eq a) => a -> Prop a+equals :: (HasCallStack, Show a, Eq a) => a -> Prop a equals expected actual | expected == actual = succeed actual- | otherwise = fail (PP.pretty (anythingToTextPretty expected)) actual+ | otherwise = fail (PP.viaShow expected) actual -- | The property of not being equal to some expected value. ---notEquals :: (HasCallStack, Eq a) => a -> Prop a+notEquals :: (HasCallStack, Show a, Eq a) => a -> Prop a notEquals expected actual | expected /= actual = succeed actual- | otherwise = fail ("not equal to " <> PP.pretty (anythingToTextPretty expected)) actual+ | otherwise = fail ("not equal to " <> PP.viaShow expected) actual -- | The property of being less than some expected value. ---lt :: (HasCallStack, Ord a) => a -> Prop a+lt :: (HasCallStack, Show a, Ord a) => a -> Prop a lt expected actual | actual < expected = succeed actual- | otherwise = fail ("less than " <> PP.pretty (anythingToTextPretty expected)) actual+ | otherwise = fail ("less than " <> PP.viaShow expected) actual -- | The property of being greater than some expected value. ---gt :: (HasCallStack, Ord a) => a -> Prop a+gt :: (HasCallStack, Show a, Ord a) => a -> Prop a gt expected actual | actual > expected = succeed actual- | otherwise = fail ("greater than " <> PP.pretty (anythingToTextPretty expected)) actual+ | otherwise = fail ("greater than " <> PP.viaShow expected) actual -- | The property of being less than or equal to some expected value. ---lte :: (HasCallStack, Ord a) => a -> Prop a+lte :: (HasCallStack, Show a, Ord a) => a -> Prop a lte expected actual | actual <= expected = succeed actual- | otherwise = fail ("less than/equal to " <> PP.pretty (anythingToTextPretty expected)) actual+ | otherwise = fail ("less than/equal to " <> PP.viaShow expected) actual -- | The property of being greater than or equal to some expected value. ---gte :: (HasCallStack, Ord a) => a -> Prop a+gte :: (HasCallStack, Show a, Ord a) => a -> Prop a gte expected actual | actual >= expected = succeed actual- | otherwise = fail ("greater than/equal to " <> PP.pretty (anythingToTextPretty expected)) actual+ | otherwise = fail ("greater than/equal to " <> PP.viaShow expected) actual -- | Sugar for tupling. -- The intended use is something like
test/PropertyMatchersSpec.hs view
@@ -41,7 +41,7 @@ propertyFails :: P.Prop Text -> P.Prop String -> P.Prop (IO a) propertyFails expectedProp actualProp =- P.fails @P.PropertyException $ \(P.PropertyFailed _ (PP.renderStrict . PP.layoutCompact -> expected) (anythingToString -> actual)) ->+ P.throws @P.PropertyException $ \(P.PropertyFailed _ (PP.renderStrict . PP.layoutCompact -> expected) (anythingToString -> actual)) -> expectedProp expected `P.and` actualProp actual check :: Testable IO a => Depth -> a -> IO ()@@ -98,16 +98,9 @@ it "fails" $ do P.fail "test string" 42- & P.fails @SomeException P.succeed+ & P.throws @SomeException P.succeed P.fail "test string" 42- & P.fails @P.PropertyException P.succeed--- it "bool" $ do- True & P.bool- propertyFails (P.equals "True") (P.equals "False") $- False & P.bool-+ & P.throws @P.PropertyException P.succeed it "equals" $ do 1 & P.equals 1