On Mon, Jul 15, 2013 at 10:34 AM, Jacob Carlborg <span dir="ltr"><<a href="mailto:doob@me.com" target="_blank">doob@me.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Recently I added a new trait to get all the unit tests functions from a module. With this in place, among other things, it's possible to do unit tests for CTFE functions. Here's a quick try:<br>
<br>
<a href="http://pastebin.com/Kk0in3bD" target="_blank">http://pastebin.com/Kk0in3bD</a><br>
<br></blockquote><div>great, thanks</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What's missing is CTFE-able "writeln".<br></blockquote><div><br></div><div>awaiting <a href="https://github.com/D-Programming-Language/dmd/pull/692">https://github.com/D-Programming-Language/dmd/pull/692</a> or CTFE exec</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It's also possible to implement named unit tests in library code, now when it's possible to access UDA's from the unit test functions.</blockquote><div><br></div><div>I would still prefer the short and sweet syntax: </div>
<div>unittest(myunittestname){...}</div><div>rather than the cumbersome:</div><div>@named("myunittestname")</div><div>unittest{...}</div><div><br></div><div>These named unittests would ideally be referable to inside DDOC (as opposed to current horrible practice of duplicating examples inside documentation, which are never in sync) </div>
<div><br></div><div>Later, for a more complete testing infrastructure, we would need additional attributes indicating for example whether the unittest is near-instantaneous or takes a long time to run (to filter out slow ones when needed)</div>
</div>