packages feed

skeletest 0.4.1 → 0.4.2

raw patch · 5 files changed

+60/−3 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Skeletest.Internal.Predicate: throwsAny :: MonadUnliftIO m => Predicate m (m a)
+ Skeletest.Predicate: anyThunk :: forall a (m :: Type -> Type). Monad m => Predicate m a
+ Skeletest.Predicate: anythingDeep :: forall a (m :: Type -> Type). (MonadIO m, NFData a) => Predicate m a
+ Skeletest.Predicate: throwsAny :: MonadUnliftIO m => Predicate m (m a)

Files

CHANGELOG.md view
@@ -1,3 +1,11 @@+## v0.4.2++Bug fixes:+* Fix exporting `P.anythingDeep` / `P.anyThunk`++API changes:+* Add `P.throwsAny`+ ## v0.4.1  Bug fixes:
skeletest.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.0  name: skeletest-version: 0.4.1+version: 0.4.2 synopsis: Batteries-included, opinionated test framework description: Batteries-included, opinionated test framework. See README.md for more details. homepage: https://github.com/brandonchinn178/skeletest#readme
src/Skeletest/Internal/Predicate.hs view
@@ -68,6 +68,7 @@   -- * IO   returns,   throws,+  throwsAny,    -- * Utilities   render,@@ -94,7 +95,14 @@ import Skeletest.Internal.Utils.HList qualified as HList import Skeletest.Internal.Utils.Text (indent, parens) import UnliftIO (MonadUnliftIO)-import UnliftIO.Exception (Exception, displayException, evaluate, evaluateDeep, try)+import UnliftIO.Exception (+  Exception,+  SomeException,+  displayException,+  evaluate,+  evaluateDeep,+  try,+ ) import Prelude hiding (abs, all, and, any, elem, not, or, (&&), (||)) import Prelude qualified @@ -821,6 +829,12 @@  where   disp = "throws (" <> predicateDisp <> ")"   dispNeg = "does not throw (" <> predicateDisp <> ")"++-- | Same as 'throws', except matches any exception.+--+-- @since 0.4.2+throwsAny :: (MonadUnliftIO m) => Predicate m (m a)+throwsAny = throws @SomeException anything  {----- Utilities -----} 
src/Skeletest/Predicate.hs view
@@ -3,6 +3,8 @@    -- * General   anything,+  anythingDeep,+  anyThunk,    -- * Ord   eq,@@ -49,6 +51,7 @@   -- * IO   returns,   throws,+  throwsAny,    -- * Functions   (===),
test/Skeletest/PredicateSpec.hs view
@@ -26,11 +26,38 @@ spec :: Spec spec = do   describe "General" $ do+    let bottom = error "boom" :: ()+     describe "anything" $ do       it "matches anything" $ do-        1 `shouldSatisfy` P.anything+        (1 :: Int) `shouldSatisfy` P.anything         "hello" `shouldSatisfy` P.anything+      it "finds bottom" $ do+        let action = bottom `shouldSatisfy` P.anything+        action `shouldSatisfy` P.throwsAny+      it "ignores nested bottom" $ do+        Just bottom `shouldSatisfy` P.anything +    describe "anythingDeep" $ do+      it "matches anything" $ do+        (1 :: Int) `shouldSatisfy` P.anythingDeep+        "hello" `shouldSatisfy` P.anythingDeep+      it "finds bottom" $ do+        let action = bottom `shouldSatisfy` P.anythingDeep+        action `shouldSatisfy` P.throwsAny+      it "finds nested bottom" $ do+        let action = Just bottom `shouldSatisfy` P.anythingDeep+        action `shouldSatisfy` P.throwsAny++    describe "anyThunk" $ do+      it "matches anything" $ do+        (1 :: Int) `shouldSatisfy` P.anyThunk+        "hello" `shouldSatisfy` P.anyThunk+      it "ignores bottom" $ do+        bottom `shouldSatisfy` P.anyThunk+      it "ignores nested bottom" $ do+        Just bottom `shouldSatisfy` P.anyThunk+   describe "Ord" $ do     describe "eq" $ do       it "checks equality" $ do@@ -381,6 +408,11 @@         snapshotFailure (P.throws (exc 500)) throw404         snapshotFailure (P.throws (exc 500)) (pure 1)         snapshotFailure (P.not $ P.throws (exc 404)) throw404++    describe "throwsAny" $ do+      it "checks exception" $ do+        throwIO (HttpException 404) `shouldSatisfy` P.throwsAny+        (error "bad") `shouldSatisfy` P.throwsAny  snapshotFailure :: (HasCallStack) => Predicate IO a -> a -> IO () snapshotFailure p x = runPredicate p x `shouldSatisfy` P.returns (P.con $ PredicateFail P.matchesSnapshot)