unittest

BCS ao at pathlink.com
Sun Dec 2 13:51:37 PST 2007


Reply to Sean,

> 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
> 

an interesting idea, I can't say I'm totally for it, but I'd like to see 
it considered.





More information about the Digitalmars-d mailing list