How to unittest nested functions
Andrej Mitrovic
andrej.mitrovich at gmail.com
Thu Jul 4 16:31:50 PDT 2013
On Wednesday, 9 May 2012 at 21:37:13 UTC, Era Scarecrow wrote:
> An idea is coming to mind to change it all to a struct
You don't even need to convert it all to a struct. Since having
function-nested unittests is just a parser issue, you can do this:
-----
int foo()
{
static int bar()
{
return 42;
}
struct _
{
unittest {
assert(bar() == 42);
}
}
return bar();
}
-----
However 'bar' must be marked static in order for this to work.
More information about the Digitalmars-d-learn
mailing list