Recall the discussion a few days ago about unittests inside templates being instantiated with the template. Often that's desirable, but sometimes not - for example when you want to generate nice ddoc unittests and avoid bloating. For those cases, here's a simple solution that I don't think has been mentioned:

/** Awesome struct */
struct Awesome(T)
{
    /** Awesome function. */
    void awesome() {}

    ///
    static if (is(T == int)) unittest
    {
        Awesome awesome;
        awesome.awesome;
    }
}

The unittest documentation is nicely generated. The unittest code itself is only generated for one instantiation.


Andrei

Reply via email to