[Issue 4644] assertExceptionThrown to assert that a particular exception was thrown

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 17 12:08:53 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4644



--- Comment #11 from Jonathan M Davis <jmdavisProg at gmail.com> 2010-08-17 12:08:49 PDT ---
I'm not sure that I understand your question about the msg parameter. If you
put it in with the function arguments, then you _have_ to give a message every
time because you can't use default parameters for the first argument. And since
it would likely be the rare case to add an additional message, that would be
annoying. With it as an additional template argument, you can have two
templates - the normal one which omits the message and the more rarely used one
which includes it.

I'd argue that for simplicity's sake, your lineFile struct really shouldn't
need to be declared. You should just be able to make a function call (be it a
standalone function or a static one on the struct itself) and have it return
the struct. I think that the struct should get in the way as little as possible
(since ideally, it wouldn't even be there at all). You could probably just use
opCall() and do this:

assertExceptionThrown!(AssertError, myfunc)(LineInfo(), 5);

Also, we might want to rename the template functions to assertExcThrown() and
assertExcNotThrown() just because the names are painfully long, albeit nicely
descriptive.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list