On Sunday, 27 September 2015 at 09:24:29 UTC, Jacob Carlborg wrote:
On 2015-09-27 07:01, Jonathan M Davis wrote:
This DIP provides a way to handle unittest blocks inside of templates which works with ddoc without compiling the unittest blocks into each
instantiation.

http://wiki.dlang.org/DIP82

How would this work in the compiler? Currently it only lexes and parses uninstantiated templates. I think that Andrei also wants to make the lexing and parsing lazy.

I don't know the details of how this would be implemented in the compiler, but clearly what that the compiler currently does is enough to generate documentation from the ddoc comments inside of templates, and I wouldn't think that detecting a static unittest would be much more complicated than that. It can then do full analysis of the static unittest if it's the module with the template that's being compiled, and it's being compiled with -unittest, and otherwise, it can pretty much ignore it (or at least, ignore it as much as any other unittest block gets ignored when -unittest isn't used).

But we have a real need here if we want to be able to actually have unit tests inside of templated types next to what they're unit testing. So, I would certainly hope that it's reasonable to implement something like this without complicating the compiler much. Certainly, the fact that ddoc works inside of templates makes it seem like this should be feasible.

- Jonathan M Davis

Reply via email to