I want to use Control.Exception.Assert to get custom error messages.
And I want to test these with HSpec.
In the repl I can see:
λ: import Control.Exception
λ: import Control.Exception.Assert
λ: (byEq assert "Bool" True True ())
()
λ: (byEq assert "Bool" False True ())
*** Exception: <interactive>:6:7-12: Assertion failed "Bool", False ≠ True
How does one test that the exception and message are correct? In other word, for the case where byEq
throws an exception I want to test both the exception type and the exception message are what are expected.
Something like:
main = hspec $ do
describe "Assertions" $ do
it "assert" $ do
evaluate (byEq assert "Bool" False True ()) `shouldThrow` ????