www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - [D1, unittest] Cannot turn on unittest version

reply %u <e ee.com> writes:
See subject^^
And why does the spec say that -unittest turns on asserts?

http://www.digitalmars.com/d/1.0/dmd-windows.html#switches
 -unittest
  compile in unittest code, turns on asserts, and sets the unittest version
identifier

http://www.digitalmars.com/d/1.0/unittest.html
 The version identifier unittest is predefined if the compilation is done with
unit tests enabled.

dmd -unittest
--
import std.stdio;

void main(){
  auto a = false;
  version (unittest){ // identifier or integer expected, not unittest.
D_unittest compiles, but still fails.
    writefln("a:",a);
  }
  assert(a); // assert is on, even without -unittest
}

unittest{
  auto b = true;
  writefln("b:",b);
}
Oct 21 2010
parent reply Don <nospam nospam.com> writes:
%u wrote:
 See subject^^
 And why does the spec say that -unittest turns on asserts?
 
 http://www.digitalmars.com/d/1.0/dmd-windows.html#switches
  -unittest
   compile in unittest code, turns on asserts, and sets the unittest version
 identifier
 
 http://www.digitalmars.com/d/1.0/unittest.html
  The version identifier unittest is predefined if the compilation is done with
 unit tests enabled.

That's true in D2 only. Shouldn't be in the D1 spec.
Oct 21 2010
parent %u <e ee.com> writes:
== Quote from Don (nospam nospam.com)'s article
 That's true in D2 only. Shouldn't be in the D1 spec.

Oct 21 2010