
31 Oct
2015
31 Oct
'15
10:37 a.m.
On Sat, Oct 31, 2015, at 11:16 AM, Roelof Wobben wrote:
[...] But is there a way I can test if the error message is shown when a negative number is being used ?
Something like (untested) ``` import qualified Control.Exception as E isErrorCall :: String -> a -> IO Bool isErrorCall s x = (E.evaluate x >> return False) `E.catch` (\(E.ErrorCall e) -> return $ e == s) myTest = isErrorCall "This will only run for positive numbers" . f2 {-
myTest (-1) = return True myTest 100 = return False -}
HTH,
Joachim