On 2010-05-04 21:24:50 -0400, bearophile <bearophileh...@lycos.com> said:
There are ways to partially implement this for run-time asserts, but badly:
void throws(Exceptions, TCallable, string filename=__FILE__, int line=__LINE__)
(lazy TCallable callable) {
try
callable();
catch (Exception e) {
if (cast(Exceptions)e !is null)
return;
}
assert(0, text(filename, "(", line, "): doesn't throw any of the
specified exceptions."));
}
Your 'throws' template seems good. Should create std.testing and
include it there.
Also, perhaps it'd work to use a double-template for this:
template throws(Exceptions...) {
void throws(TCallable, string filename=__FILE__, int
line=__LINE__)
(lazy TCallable callable) {
...
}
}
I know this trick was working in D1, but I'm not sure if it wasn't
broken in D2.
--
Michel Fortin
michel.for...@michelf.com
http://michelf.com/