Unit tests in D

bearophile bearophileHUGS at lycos.com
Wed May 5 11:01:52 PDT 2010


Don:

>It seems pretty useless to me. Wanting to make a distinction between "this will not compile" and "this will not compile _because it hits a static assert_" is an *extremely* niche feature. Because the only times I can imagine that you'd care would be because you wanted to ensure it gave a "nice" error message. And to do that, you'd have to actually check the test of the static assert.<

Let's assume you are right, that making such distinction is generally useless.

In my unittests I write one or two tests every time something contains a static assert (plus other tests for other compile time errors). So even if you are right, I have to use a syntax like this often enough inside unittests:

static assert(!__traits(compiles, foo(10)));

So for this I'd like a simpler syntax.


>And the idea of creating a whole heirarchy of compile-time exceptions for this ...<

No hierarchy required, sorry, the examples I have written for 'static throws' were all wrong.

Thank you for your answers,
bye,
bearophile


More information about the Digitalmars-d mailing list