sandwich-0.3.0.2: Yet another test framework for Haskell
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Sandwich.Expectations

Description

Functions for making assertions about test behavior.

Synopsis

Manually fail a test or mark as pending

expectationFailure :: (HasCallStack, MonadIO m) => String -> m a Source #

General-purpose function to throw a test exception with a String.

pending :: (HasCallStack, MonadIO m) => m a Source #

Throws a Pending exception, which will cause the test to be marked as pending.

pendingWith :: (HasCallStack, MonadIO m) => String -> m a Source #

Throws a Pending exception with a message to add additional details.

xit :: (HasCallStack, MonadIO m) => String -> ExampleT context m1 () -> SpecFree context m () Source #

Shorthand for a pending test example. You can quickly mark an it node as pending by putting an "x" in front of it.

Expecting failures

shouldFail :: (HasCallStack, MonadUnliftIO m) => m () -> m () Source #

Assert that a given action should fail with some FailureReason.

shouldFailPredicate :: (HasCallStack, MonadUnliftIO m) => (FailureReason -> Bool) -> m () -> m () Source #

Assert that a given action should fail with some FailureReason matching a predicate.

shouldThrow Source #

Arguments

:: (HasCallStack, MonadUnliftIO m, Exception e) 
=> m a

The action to run.

-> (e -> Bool)

A predicate on the exception to determine if it's as expected.

-> m () 

Asserts that an action should throw an exception. Accepts a predicate to determine if the exception matches.

Assertions

shouldBe :: (HasCallStack, MonadIO m, Eq a, Show a) => a -> a -> m () Source #

Asserts that two things are equal.

shouldNotBe :: (HasCallStack, MonadIO m, Eq a, Show a) => a -> a -> m () Source #

Asserts that two things are not equal.

shouldContain :: (HasCallStack, MonadIO m, Eq a, Show a) => [a] -> [a] -> m () Source #

Asserts that the given list contains a subsequence.

shouldContainPredicate :: (HasCallStack, MonadIO m, Show a) => [a] -> (a -> Bool) -> m () Source #

Asserts that the given list contains an item matching a predicate.

shouldNotContain :: (HasCallStack, MonadIO m, Eq a, Show a) => [a] -> [a] -> m () Source #

Asserts that the given list does not contain a subsequence.

shouldBeSet :: (HasCallStack, MonadIO m, Ord a, Show a) => [a] -> [a] -> m () Source #

Asserts that the given lists are equal as sets.

shouldNotContainPredicate :: (HasCallStack, MonadIO m, Show a) => [a] -> (a -> Bool) -> m () Source #

Asserts that the given list contains an item matching a predicate.

shouldBeNothing :: (HasCallStack, MonadIO m, Show a) => Maybe a -> m () Source #

Asserts that the given Maybe is Nothing.

shouldBeJust :: (HasCallStack, MonadIO m) => Maybe a -> m () Source #

Asserts that the given Maybe is Just.

shouldBeLeft :: (HasCallStack, MonadIO m, Show a, Show b) => Either a b -> m () Source #

Asserts that the given Either is Left.

shouldBeRight :: (HasCallStack, MonadIO m, Show a, Show b) => Either a b -> m () Source #

Asserts that the given Either is Right.

textShouldContain :: (HasCallStack, MonadIO m) => Text -> Text -> m () Source #

Asserts that the given text contains a substring.

textShouldNotContain :: (HasCallStack, MonadIO m) => Text -> Text -> m () Source #

Asserts that the given text does not contain a substring.