
11 Jun
2019
11 Jun
'19
3:44 a.m.
Hi all, I have a function that may call "error" if the input represents a bug in my program. (Think something like PositiveInt -1; this should never happen so Maybe or Either are not applicable.) f :: Whatever f = error "This should never happen." spec :: Spec spec = describe "f" $ it "error" $ return f `shouldThrow` anyErrorCall The above does not work, I get "did not get expected exception: ErrorCall". Using "anyException" doesn't work either. How can I write a test for this? And (assuming I can get the test to work), how do I check that the error message is indeed what I expect? Cheers, Hilco