DIP82: static unittest blocks
Jonathan M Davis via Digitalmars-d
digitalmars-d at puremagic.com
Mon Sep 28 02:16:00 PDT 2015
On Monday, 28 September 2015 at 09:06:52 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
>
> I assume you won't have access to the template parameters?
No. It wouldn't make sense to, since it's not an instantiation of
the template and thus there are no template arguments. Basically,
aside from ddoc, this should be the same as if the unittest block
were outside of the template, but by having a unittest block
inside of the template, it can be immediately after the function
that it's testing, allowing it to be used for generating the
examples for ddoc as well as making it easier to find and
maintain the tests that go with each function.
It would be kind of like how with a static function in a
class/struct, you don't have access to the this
pointer/reference, since you're not dealing with an actual
instance. Only in this case, it's the template arguments which
you wouldn't have access to, not the this pointer/reference,
because you're not dealing with an actual instantiation of the
template.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list