[Haskell-beginners] HUnit - testing for failed pattern match

Edward Z. Yang ezyang at MIT.EDU
Wed Feb 23 14:31:33 CET 2011


Excerpts from Xavier Shay's message of Tue Feb 22 20:25:28 -0500 2011:
> 
> On 23/02/11 10:35 AM, Edward Z. Yang wrote:
> > What you describe is one of the cases when a partial function is ok
> > (though it's probably better to do something like:
> >
> > giveMeThree x
> > | x == 3 = True
> > | otherwise = error "giveMeThree: not three"
> >
> > It's frequently not possible, but if you can arrange your types so that
> > the invalid values are not possible, even better.)
> ah that's good, I can give a helpful error message.
> 
> Still would like a way to test it though...
> 

Check the section "Testing for expected errors" herE:

    http://leiffrenzel.de/papers/getting-started-with-hunit.html

Edward



More information about the Beginners mailing list