Metaprogramming in D : Some Real-world Examples
Don
nospam at nospam.com
Wed Nov 11 04:15:46 PST 2009
Christopher Wright wrote:
> grauzone wrote:
>> You're not testing for types, you're testing if it compiles. Inside
>> the tested block of code, all sorts of things could go wrong. You
>> can't know if is(typeof(...)) really did what you wanted, or if
>> something broke.
You're testing, "is everything inside that OK?". If you want to know WHY
it's wrong, you'd better make sure you're testing something simple.
> So it requires caution, and you want to keep the contents small. It's
> useful, but it requires caution.
I don't even think it particularly requires caution. If it passes, you
know everything is OK. It's just that it's an all-or-nothing test.
IMHO, one of the best features of it, is that you can have negative
compile-time unit tests. You can create tests which must be rejected at
compile time. I don't know of any other clean way to do that.
More information about the Digitalmars-d-announce
mailing list