module Test.Hspec.Expectations.Lifted (
expectationFailure
, shouldBe
, shouldSatisfy
, shouldStartWith
, shouldEndWith
, shouldContain
, shouldMatchList
, shouldReturn
, shouldNotBe
, shouldNotSatisfy
, shouldNotContain
, shouldNotReturn
, HasCallStack
) where
import Control.Monad.IO.Class
import qualified Test.Hspec.Expectations as E
import Test.Hspec.Expectations (HasCallStack)
infix 1 `shouldBe`, `shouldSatisfy`, `shouldStartWith`, `shouldEndWith`, `shouldContain`, `shouldMatchList`, `shouldReturn`
infix 1 `shouldNotBe`, `shouldNotSatisfy`, `shouldNotContain`, `shouldNotReturn`
liftIO2 :: MonadIO m => (a -> b -> IO r) -> a -> b -> m r
liftIO2 action a = liftIO . action a
expectationFailure :: (HasCallStack, MonadIO m) => String -> m ()
expectationFailure = liftIO . E.expectationFailure
shouldBe :: (HasCallStack, MonadIO m, Show a, Eq a) => a -> a -> m ()
shouldBe = liftIO2 E.shouldBe
shouldSatisfy :: (HasCallStack, MonadIO m, Show a) => a -> (a -> Bool) -> m ()
shouldSatisfy = liftIO2 E.shouldSatisfy
shouldStartWith :: (HasCallStack, MonadIO m, Show a, Eq a) => [a] -> [a] -> m ()
shouldStartWith = liftIO2 E.shouldStartWith
shouldEndWith :: (HasCallStack, MonadIO m, Show a, Eq a) => [a] -> [a] -> m ()
shouldEndWith = liftIO2 E.shouldEndWith
shouldContain :: (HasCallStack, MonadIO m, Show a, Eq a) => [a] -> [a] -> m ()
shouldContain = liftIO2 E.shouldContain
shouldMatchList :: (HasCallStack, MonadIO m, Show a, Eq a) => [a] -> [a] -> m ()
shouldMatchList = liftIO2 E.shouldMatchList
shouldReturn :: (HasCallStack, MonadIO m, Show a, Eq a) => m a -> a -> m ()
shouldReturn action expected = action >>= liftIO . (`E.shouldBe` expected)
shouldNotBe :: (HasCallStack, MonadIO m, Show a, Eq a) => a -> a -> m ()
shouldNotBe = liftIO2 E.shouldNotBe
shouldNotSatisfy :: (HasCallStack, MonadIO m, Show a) => a -> (a -> Bool) -> m ()
shouldNotSatisfy = liftIO2 E.shouldNotSatisfy
shouldNotContain :: (HasCallStack, MonadIO m, Show a, Eq a) => [a] -> [a] -> m ()
shouldNotContain = liftIO2 E.shouldNotContain
shouldNotReturn :: (HasCallStack, MonadIO m, Show a, Eq a) => m a -> a -> m ()
shouldNotReturn action expected = action >>= liftIO . (`E.shouldNotBe` expected)