packages feed

easytest 0.1.1 → 0.2

raw patch · 5 files changed

+39/−7 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ EasyTest: expectLeft :: (Show a, HasCallStack) => Either e a -> Test ()
+ EasyTest: expectLeftNoShow :: HasCallStack => Either e a -> Test ()
+ EasyTest: expectRightNoShow :: HasCallStack => Either e a -> Test ()
- EasyTest: expectJust :: HasCallStack => Maybe a -> Test a
+ EasyTest: expectJust :: HasCallStack => Maybe a -> Test ()
- EasyTest: expectRight :: HasCallStack => Either e a -> Test a
+ EasyTest: expectRight :: (Show e, HasCallStack) => Either e a -> Test ()

Files

CHANGES.md view
@@ -1,3 +1,9 @@+## 0.2 (3/27/2018)++* [`expectRight` now shows `Left`s. `expectRightNoShow` replicates the old functionality.](https://github.com/joelburget/easytest/commit/c2d5dccc97dcdb925ebc39c36fcde9ff8d894f77)+* [Call stacks now longer show EasyTest porcelain.](https://github.com/joelburget/easytest/commit/0b7064915a5b9c9de0115ebb6fc2fa49b2c4776e)+* [`expectJust` and `expectRight` now return unit](https://github.com/joelburget/easytest/commit/ef5d4e9fd03c1008c810ee09a4f4c459d4e26bdb)+ ## 0.1.1 (3/25/2018)  * [Add ghc 7.10.3 compatibility.](https://github.com/joelburget/easytest/commit/4acfad507cefc3fb2c0d588f1fbe0e4d583a762d)
easytest.cabal view
@@ -1,6 +1,6 @@ name:          easytest category:      Testing-version:       0.1.1+version:       0.2 license:       MIT cabal-version: >= 1.8 license-file:  LICENSE
src/EasyTest/Internal.hs view
@@ -35,6 +35,7 @@ import Data.String (IsString(..)) import Data.Text (Text) import qualified Data.Text as T+import GHC.Exts (fromList, toList) #if MIN_VERSION_base(4,9,0) import GHC.Stack #else@@ -97,7 +98,10 @@ crash :: HasCallStack => Text -> Test a crash msg = do   let trace = callStack-      msg' = msg <> " " <> T.pack (prettyCallStack trace)+      trace' = fromList $ filter+        (\(_msg, loc) -> srcLocFile loc /= "src/EasyTest/Porcelain.hs")+        $ toList trace+      msg' = msg <> " " <> T.pack (prettyCallStack trace')   Test (Just <$> putResult Failed)   noteScoped ("FAILURE " <> msg')   Test (pure Nothing)
src/EasyTest/Porcelain.hs view
@@ -9,6 +9,9 @@   , expect   , expectJust   , expectRight+  , expectRightNoShow+  , expectLeft+  , expectLeftNoShow   , expectEq   , tests   , using@@ -56,13 +59,25 @@ expect False = crash "unexpected" expect True = ok -expectJust :: HasCallStack => Maybe a -> Test a+expectJust :: HasCallStack => Maybe a -> Test () expectJust Nothing = crash "expected Just, got Nothing"-expectJust (Just a) = ok >> pure a+expectJust (Just _) = ok -expectRight :: HasCallStack => Either e a -> Test a-expectRight (Left _) = crash "expected Right, got Left"-expectRight (Right a) = ok >> pure a+expectRight :: (Show e, HasCallStack) => Either e a -> Test ()+expectRight (Left e)  = crash $ "expected Right, got (Left " <> T.pack (show e) <> ")"+expectRight (Right _) = ok++expectRightNoShow :: HasCallStack => Either e a -> Test ()+expectRightNoShow (Left _)  = crash $ "expected Right, got Left"+expectRightNoShow (Right _) = ok++expectLeft :: (Show a, HasCallStack) => Either e a -> Test ()+expectLeft (Right a) = crash $ "expected Left, got (Right " <> T.pack (show a) <> ")"+expectLeft (Left _)  = ok++expectLeftNoShow :: HasCallStack => Either e a -> Test ()+expectLeftNoShow (Right _) = crash $ "expected Left, got Right"+expectLeftNoShow (Left _)  = ok  expectEq :: (Eq a, Show a, HasCallStack) => a -> a -> Test () expectEq x y = if x == y then ok else crash $
tests/Suite.hs view
@@ -36,3 +36,10 @@     , scope "x.go" (crash "never run")     ]   run reverseTest++  run $ tests+    [ expectLeft        (Left 1   :: Either Int ())+    , expectLeftNoShow  (Left 2   :: Either Int ())+    , expectRight       (Right () :: Either Int ())+    , expectRightNoShow (Right () :: Either Int ())+    ]