[Haskell-cafe] HUnit Control.Exception assertFailure?

Mark Spezzano mark.spezzano at chariot.net.au
Sat Nov 13 06:14:19 EST 2010


Hi,

I'm trying to follow some examples of HUnit from a webpage. Basically I want my _application_ code to call the "error" function when a certain condition is met (namely when a supplied String to a function is longer than 80 characters). 

I want my _test_ code to "catch" this error. Unfortunately the example code that I'm following uses the older style of Exception handling. Does anyone know how to catch this exception using the newer Control.Exception module?

Basically I want to 

1. Call error msg when String length > 80 for some function

2. Catch thrown error from step 1 and do absolutely nothing. (i.e. the "expected failure" was caught)

3. If the error is uncaught (in step 2; for whatever reason) then call "assertFailure somemsg" and my _test_ code should fail since the error it was expecting to occur didn't happen.

Thanks,

Mark Spezzano



More information about the Haskell-Cafe mailing list