www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to run unittests?

reply al <al la.com> writes:
I have main.d:

void main()
{
}

unittest{
	assert(0);
}


I run:

dmd  -unittest main.d && ./main 

and nothing happens. 

What do I need to do to run the tests? (or get results printed?)

dmd v1.050 on OS X.
Oct 31 2009
parent reply al <al la.com> writes:
It seems that unittests are not run (I've tried putting while(1){} and writef()
there - no effect).

Even this code doesn't run assert():

import std.stdio;

int main(string[] args)
{
	assert(args.length == -1);
	writef("shouldn't work!");
	return 0;
}


I'm using:

dmd -debug -w -unittest -run main.d

Is there a secred debug switch, or is it simply a bug? Which version of DMD is
usable? (I've got v1.050)
Oct 31 2009
parent grauzone <none example.net> writes:
al wrote:
 It seems that unittests are not run (I've tried putting while(1){} and
writef() there - no effect).
 
 Even this code doesn't run assert():
 
 import std.stdio;
 
 int main(string[] args)
 {
 	assert(args.length == -1);
 	writef("shouldn't work!");
 	return 0;
 }
 
 
 I'm using:
 
 dmd -debug -w -unittest -run main.d
 
 Is there a secred debug switch, or is it simply a bug? Which version of DMD is
usable? (I've got v1.050)
 
I think it's a bug. Works for me under Linux. I guess the OSX versions of dmd are simply not in a useable state yet.
Oct 31 2009