unittest
Sean Kelly
sean at f4.ca
Sat Dec 1 12:31:35 PST 2007
Given the dual use of "invariant" in D 2.0, I was thinking it might be
useful to do the something similar with "unittest". Make it equivalent
to "version(unittest)" and be enabled when -unittest was specified
during compilation. This seems a rather natural extension of the
keyword and the semantics would be nearly identical to how "invariant"
works right now:
unittest int x; // single declaration enabled on -unittest
unittest int fn() {} // function compiled on -unittest
unittest // everything in the block compiled on -unittest
{
import std.stdio;
int y;
void f2() {}
}
unittest() // unit test function, similar to invariant()
{
writefln( "hello" );
}
As an added bonus, this would regain consistency with the invariant
function, which has been bugging me since its adoption for use with const.
Sean
More information about the Digitalmars-d
mailing list