Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module defines all the functions you will use to define your tests
Synopsis
- shouldBe :: (HasCallStack, Show a, Eq a) => a -> a -> IO ()
- shouldNotBe :: (HasCallStack, Show a, Eq a) => a -> a -> IO ()
- shouldSatisfy :: (HasCallStack, Show a) => a -> (a -> Bool) -> IO ()
- shouldSatisfyNamed :: (HasCallStack, Show a) => a -> String -> (a -> Bool) -> IO ()
- shouldNotSatisfy :: (HasCallStack, Show a) => a -> (a -> Bool) -> IO ()
- shouldNotSatisfyNamed :: (HasCallStack, Show a) => a -> String -> (a -> Bool) -> IO ()
- shouldReturn :: (HasCallStack, Show a, Eq a) => IO a -> a -> IO ()
- shouldNotReturn :: (HasCallStack, Show a, Eq a) => IO a -> a -> IO ()
- shouldStartWith :: (HasCallStack, Show a, Eq a) => [a] -> [a] -> Expectation
- shouldEndWith :: (HasCallStack, Show a, Eq a) => [a] -> [a] -> Expectation
- shouldContain :: (HasCallStack, Show a, Eq a) => [a] -> [a] -> Expectation
- shouldMatchList :: (HasCallStack, Show a, Eq a) => [a] -> [a] -> Expectation
- stringShouldBe :: HasCallStack => String -> String -> IO ()
- textShouldBe :: HasCallStack => Text -> Text -> IO ()
- stringsNotEqualButShouldHaveBeenEqual :: String -> String -> Assertion
- textsNotEqualButShouldHaveBeenEqual :: Text -> Text -> Assertion
- bytestringsNotEqualButShouldHaveBeenEqual :: ByteString -> ByteString -> Assertion
- expectationFailure :: HasCallStack => String -> IO a
- context :: String -> IO a -> IO a
- type Expectation = IO ()
- type Selector a = a -> Bool
- shouldThrow :: forall e a. (HasCallStack, Exception e) => IO a -> Selector e -> Expectation
- anyException :: Selector SomeException
- anyErrorCall :: Selector ErrorCall
- errorCall :: String -> Selector ErrorCall
- anyIOException :: Selector IOException
- anyArithException :: Selector ArithException
Documentation
shouldBe :: (HasCallStack, Show a, Eq a) => a -> a -> IO () infix 1 Source #
Assert that two values are equal according to ==
.
shouldNotBe :: (HasCallStack, Show a, Eq a) => a -> a -> IO () infix 1 Source #
Assert that two values are not equal according to ==
.
shouldSatisfy :: (HasCallStack, Show a) => a -> (a -> Bool) -> IO () infix 1 Source #
Assert that a value satisfies the given predicate.
shouldSatisfyNamed :: (HasCallStack, Show a) => a -> String -> (a -> Bool) -> IO () Source #
Assert that a value satisfies the given predicate with the given predicate name.
shouldNotSatisfy :: (HasCallStack, Show a) => a -> (a -> Bool) -> IO () infix 1 Source #
Assert that a value does not satisfy the given predicate.
shouldNotSatisfyNamed :: (HasCallStack, Show a) => a -> String -> (a -> Bool) -> IO () Source #
Assert that a value does not satisfy the given predicate with the given predicate name.
shouldReturn :: (HasCallStack, Show a, Eq a) => IO a -> a -> IO () infix 1 Source #
Assert that computation returns the given value (according to ==
).
shouldNotReturn :: (HasCallStack, Show a, Eq a) => IO a -> a -> IO () infix 1 Source #
Assert that computation returns the given value (according to ==
).
shouldStartWith :: (HasCallStack, Show a, Eq a) => [a] -> [a] -> Expectation infix 1 Source #
Assert that the given list has the given prefix
shouldEndWith :: (HasCallStack, Show a, Eq a) => [a] -> [a] -> Expectation infix 1 Source #
Assert that the given list has the given suffix
shouldContain :: (HasCallStack, Show a, Eq a) => [a] -> [a] -> Expectation infix 1 Source #
Assert that the given list has the given infix
shouldMatchList :: (HasCallStack, Show a, Eq a) => [a] -> [a] -> Expectation Source #
Assert that the given list contains all elements from the other given list and only them, perhaps in a different order.
stringShouldBe :: HasCallStack => String -> String -> IO () Source #
textShouldBe :: HasCallStack => Text -> Text -> IO () Source #
bytestringsNotEqualButShouldHaveBeenEqual :: ByteString -> ByteString -> Assertion Source #
An assertion that says two ByteString
s should have been equal according to ==
.
expectationFailure :: HasCallStack => String -> IO a Source #
Make a test fail
Note that this is mostly backward compatible, but it has return type a
instead of ()
because execution will not continue beyond this function.
In this way it is not entirely backward compatible with hspec because now there could be an ambiguous type error.
context :: String -> IO a -> IO a Source #
Annotate a given action with a context, for contextual assertions
This is a completely different function from the function with the same name in hspec. In hspec, context is a synonym for describe, but in sydtest, context is used for contextual failures.
type Expectation = IO () Source #
For easy hspec migration
shouldThrow :: forall e a. (HasCallStack, Exception e) => IO a -> Selector e -> Expectation infix 1 Source #
Assert that a given IO action throws an exception that matches the given exception