sydtest-0.17.0.2: A modern testing framework for Haskell with good defaults and advanced testing features.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Syd.Expectation

Description

This module defines all the functions you will use to define your tests

Synopsis

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 #

Assert that two Values are equal according to ==.

Note that using function could mess up the colours in your terminal if the Texts contain ANSI codes. In that case you may want to show your values first or use shouldBe instead.

textShouldBe :: HasCallStack => Text -> Text -> IO () Source #

Assert that two Texts are equal according to ==.

Note that using function could mess up the colours in your terminal if the Texts contain ANSI codes. In that case you may want to show your values first or use shouldBe instead.

stringsNotEqualButShouldHaveBeenEqual :: String -> String -> Assertion Source #

An assertion that says two Values should have been equal according to ==.

Note that using function could mess up the colours in your terminal if the Texts contain ANSI codes. In that case you may want to show your values first or use shouldBe instead.

textsNotEqualButShouldHaveBeenEqual :: Text -> Text -> Assertion Source #

An assertion that says two Texts should have been equal according to ==.

Note that using function could mess up the colours in your terminal if the Texts contain ANSI codes. In that case you may want to show your values first or use shouldBe instead.

bytestringsNotEqualButShouldHaveBeenEqual :: ByteString -> ByteString -> Assertion Source #

An assertion that says two ByteStrings 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

type Selector a = a -> Bool 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