Static unittests?
Jacob Carlborg
doob at me.com
Mon Aug 5 07:36:12 PDT 2013
On Monday, 5 August 2013 at 12:25:36 UTC, Bosak wrote:
> Are compile-time unittests possible in D? Maybe something like:
>
> static unittest {
> assert(2 == 1 + 1);
> }
>
> So that every assert in the unittest is translated to static
> assert. And no normal asserts to be allowed in static unittest?
> So the above code would be executed at compile time and
> translated to:
>
> unittest {
> static assert(2 == 1 + 1);
> }
Not exactly as you describe but you can do unit tests for CTFE
functions. Have a look at this thread:
http://forum.dlang.org/thread/ks1brj$1l6c$1@digitalmars.com
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list