Unit tests in D
Michel Fortin
michel.fortin at michelf.com
Wed May 5 04:58:57 PDT 2010
On 2010-05-05 07:46:46 -0400, bearophile <bearophileHUGS at lycos.com> said:
> Michel Fortin:
>
>> Can't you do:
>> static assert(throws!OtherException(sqrt(-5)));
>> ?
>
> Some of those examples of mine were wrong because the main purpose of a
> 'static throws' is to catch static asserts, not to catch exceptions at
> compile time, sorry:
Am I right that what you want is this?
static assert(!__traits(compiles, foo(10)));
I agree that the __traits syntax leaves a lot of room for improvement.
> (And currently try-catch statements are not supported in CTFE, see
> http://d.puremagic.com/issues/show_bug.cgi?id=4067 ).
Indeed.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list