<div dir="ltr">As beginner to beginner, so take this with a kg of salt  ... isn't what you're looking for a construction of the Either sort? <div><br></div><div>That way you get Right and Left and you can check for Left.</div><div><br></div><div><br><div><br></div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno mar 11 giu 2019 alle ore 05:45 Hilco Wijbenga <<a href="mailto:hilco.wijbenga@gmail.com">hilco.wijbenga@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all,<br>
<br>
I have a function that may call "error" if the input represents a bug<br>
in my program. (Think something like PositiveInt -1; this should never<br>
happen so Maybe or Either are not applicable.)<br>
<br>
f :: Whatever<br>
f = error "This should never happen."<br>
<br>
spec :: Spec<br>
spec =<br>
    describe "f" $<br>
        it "error" $<br>
            return f `shouldThrow` anyErrorCall<br>
<br>
The above does not work, I get "did not get expected exception:<br>
ErrorCall". Using "anyException" doesn't work either.<br>
<br>
How can I write a test for this? And (assuming I can get the test to<br>
work), how do I check that the error message is indeed what I expect?<br>
<br>
Cheers,<br>
Hilco<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div>