packages feed

quickcheck-assertions 0.2.0 → 0.3.0

raw patch · 4 files changed

+80/−21 lines, 4 filesdep +pretty-show

Dependencies added: pretty-show

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# 0.3.0++* Changelog added+* Use pretty-show for error descriptions (usefull with huge test+  cases)
+ README.md view
@@ -0,0 +1,49 @@+Module provides convenient functions to do some assertions in QuickCheck+properties with pretty printed reasons.  For example you can do something like+that:++```haskell+module Main where++import Test.Hspec+import Test.Hspec.QuickCheck+import Test.QuickCheck.Assertions+import Test.QuickCheck.Property++someProp :: Int -> Int -> Result+someProp a b = (a ?> b)++someOtherProp :: Double -> Double -> Result+someOtherProp a b = (a ?== b)+               +main = hspec $ describe "failing test" $ do+  prop "must fail" $ someProp+  prop "must fail again" $ someOtherProp+```++And receive pretty printed fail message when testing:++```+failing test+  - must fail FAILED [1]                    +  - must fail again FAILED [2]                             ++1) failing test must fail FAILED+*** Failed! (after 1 test): +>>>>>>>>>>>>>> the value+0+>>>>>>>>>>>>>> should be greater than value+0+0+0+++2) failing test must fail again FAILED+*** Failed! (after 2 tests and 4 shrinks): +>>>>>>>>>>>>>> expected+0.0+>>>>>>>>>>>>>> but got+1.0+0.0+1.0+```
Test/QuickCheck/Assertions.hs view
@@ -66,27 +66,27 @@   , Result   ) where -import Test.QuickCheck.Property import Data.AEq----binAsrt ::   String -- ^ The reason of fail-           -> Bool   -- ^ If True then test pass-           -> Result -- ^ The result with fail reason-binAsrt fmt pre = if pre-                   then succeeded-                   else failed {reason = fmt}+import Test.QuickCheck.Property+import Text.Show.Pretty +binAsrt+  :: String -- ^ The reason of fail+  -> Bool   -- ^ If True then test pass+  -> Result -- ^ The result with fail reason+binAsrt fmt pre =+  if pre+  then succeeded+  else failed {reason = fmt}  -- | Left argument should be equal to right (?==) :: (Eq a, Show a) => a -> a -> Result (?==) a b = binAsrt s (a == b)   where     s = "\n>>>>>>>>>>>>>> expected\n" -- very stupid formater for now-        ++ show b +++        ++ ppShow b ++         "\n>>>>>>>>>>>>>> but got\n"-        ++ show a+        ++ ppShow a  -- | Right argument should be equal to left (==?) :: (Eq a, Show a) => a -> a -> Result@@ -97,9 +97,9 @@ (?/=) a b = binAsrt s (a /= b)   where     s = "\n>>>>>>>>>>>>>> expected the value\n"-        ++ show a +++        ++ ppShow a ++         "\n>>>>>>>>>>>>>> should not equal to\n"-        ++ show b+        ++ ppShow b  -- | Right argument should not equal to left (/=?) :: (Eq a, Show a) => a -> a -> Result@@ -115,9 +115,9 @@ binOrdering pre fmt a b = binAsrt s (pre $ compare a b)   where     s = "\n>>>>>>>>>>>>>> the value\n"-        ++ show a +++        ++ ppShow a ++         "\n>>>>>>>>>>>>>> should be " ++ fmt ++ " than value\n"-        ++ show b+        ++ ppShow b   -- | Left argument is greater than right@@ -157,9 +157,9 @@ (?~==) a b = binAsrt s (a ~== b)   where     s = "\n>>>>>>>>>>>>>> The value\n"-        ++ show a +++        ++ ppShow a ++         "\n>>>>>>>>>>>>>> should be almost equal to\n"-        ++ show b+        ++ ppShow b  -- | Right value is almost equal to left (~==?) :: (AEq a, Show a) => a -> a -> Result
quickcheck-assertions.cabal view
@@ -1,5 +1,5 @@ name:                quickcheck-assertions-version:             0.2.0+version:             0.3.0 synopsis:            HUnit like assertions for QuickCheck description:         Library with convenient assertions for QuickCheck properties like in HUnit license:             LGPL-3@@ -11,6 +11,10 @@ build-type:          Simple cabal-version:       >=1.8 homepage:            https://github.com/s9gf4ult/quickcheck-assertions++extra-source-files: CHANGELOG.md+                  , README.md+ source-repository head   type:           git   location:       git://github.com/s9gf4ult/quickcheck-assertions.git@@ -19,9 +23,10 @@ library   exposed-modules:     Test.QuickCheck.Assertions   -- other-modules:-  build-depends:       base == 4.*-                     , QuickCheck >= 2.3+  build-depends:       QuickCheck >= 2.3+                     , base == 4.*                      , ieee754+                     , pretty-show   ghc-options:     -Wall  test-suite main