On 01/25/2011 12:16 AM, Nick Sabalausky wrote:
"Andrej Mitrovic"<[email protected]>  wrote in message
news:[email protected]...
It's often the case that you want documentation examples to be short,
but also correct. But you still want to write complex unittests that
you don't want to put in the documentation. Sounds like a perfect
candidate for named unittests:

unittest(ddoc)
{
   // outputted in documentation
}

Here "ddoc" would be a predefined identifier, kind of like X86 is for
version() statements.

unittest // our own complex unittest that we don't want to output in
the documentation
{
    // ...
}

That also provides a good solution for unittests that belong in the examples
of more than one item:

unittest(foo, bar)
{
   // Use both foo and bar
   // outputted in documentation
}



...and now you need to also maintain annotation list in addition to unittest body, and keep both in sync. Reminds me a prototype-implementation idiom from some languages.

Reply via email to