hspec-expectations-pretty-diff-0.7.2.4: Catchy combinators for HUnit

Safe HaskellNone
LanguageHaskell2010

Test.Hspec.Expectations.Pretty

Contents

Description

Synopsis

Setting expectations

shouldBe :: (?loc :: CallStack) => (Show a, Eq a) => a -> a -> Expectation infix 1 Source #

actual `shouldBe` expected sets the expectation that actual is equal to expected.

shouldSatisfy :: (?loc :: CallStack) => Show a => a -> (a -> Bool) -> Expectation infix 1 Source #

v `shouldSatisfy` p sets the expectation that p v is True.

shouldStartWith :: (?loc :: CallStack) => (Show a, Eq a) => [a] -> [a] -> Expectation infix 1 Source #

list `shouldStartWith` prefix sets the expectation that list starts with prefix,

shouldEndWith :: (?loc :: CallStack) => (Show a, Eq a) => [a] -> [a] -> Expectation infix 1 Source #

list `shouldEndWith` suffix sets the expectation that list ends with suffix,

shouldContain :: (?loc :: CallStack) => (Show a, Eq a) => [a] -> [a] -> Expectation infix 1 Source #

list `shouldContain` sublist sets the expectation that sublist is contained, wholly and intact, anywhere in list.

shouldMatchList :: (?loc :: CallStack) => (Show a, Eq a) => [a] -> [a] -> Expectation infix 1 Source #

xs `shouldMatchList` ys sets the expectation that xs has the same elements that ys has, possibly in another order

shouldReturn :: (?loc :: CallStack) => (Show a, Eq a) => IO a -> a -> Expectation infix 1 Source #

action `shouldReturn` expected sets the expectation that action returns expected.

shouldNotBe :: (?loc :: CallStack) => (Show a, Eq a) => a -> a -> Expectation infix 1 Source #

actual `shouldNotBe` notExpected sets the expectation that actual is not equal to notExpected

shouldNotSatisfy :: (?loc :: CallStack) => Show a => a -> (a -> Bool) -> Expectation infix 1 Source #

v `shouldNotSatisfy` p sets the expectation that p v is False.

shouldNotContain :: (?loc :: CallStack) => (Show a, Eq a) => [a] -> [a] -> Expectation infix 1 Source #

list `shouldNotContain` sublist sets the expectation that sublist is not contained anywhere in list.

shouldNotReturn :: (?loc :: CallStack) => (Show a, Eq a) => IO a -> a -> Expectation infix 1 Source #

action `shouldNotReturn` notExpected sets the expectation that action does not return notExpected.

Expecting exceptions

shouldThrow :: (?loc :: CallStack) => Exception e => IO a -> Selector e -> Expectation infix 1 Source #

action `shouldThrow` selector sets the expectation that action throws an exception. The precise nature of the expected exception is described with a Selector.

Selecting exceptions

type Selector a = a -> Bool Source #

A Selector is a predicate; it can simultaneously constrain the type and value of an exception.

Predefined type-based selectors

There are predefined selectors for some standard exceptions. Each selector is just const True with an appropriate type.

Combinators for defining value-based selectors

Some exceptions (most prominently ErrorCall) have no Eq instance. Selecting a specific value would require pattern matching.

For such exceptions, combinators that construct selectors are provided. Each combinator corresponds to a constructor; it takes the same arguments, and has the same name (but starting with a lower-case letter).