More than one main

Kagamin spam at here.lot
Thu Mar 24 12:53:16 PDT 2011


bearophile Wrote:

> Kagamin:
> 
> > unittests should be able to be a demo code for the module. Sometimes they say that unittests do demonstrate, how the module should work.<
> 
> For me the code inside unittests and the demo code inside the main (and the functions called just by the main) have different purposes. A demo may open a GUI, interact on the command line with the user, allow the module to be used stand alone with some kind of little interface, show graphs on the screen, etc. While unittests are mostly to test the module is working correctly and they are not supposed to be interactive or to be show graphs, etc. One my real example: in a module that plots functions on the screen, in the main I generate and show some function plots to the user. This is not done in unittests.
> 

you can switch on version matching the module name, or something similar that will be easy to switch in a makefile.

module modu;
version(modu)
void main()
{
  //...
}


More information about the Digitalmars-d mailing list