Entry (main) method inside a class?
Thomas Kuehne
thomas-dloop at kuehne.cn
Sun Mar 18 08:04:31 PDT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Frits van Bommel schrieb am 2007-03-17:
> Thomas Kuehne wrote:
>> Frits van Bommel schrieb am 2007-03-16:
>>> Though I could see uses for this, like to run unittests (similarly to
>>> what running Python modules "stand-alone" often does).
>>> D has gone another way there though, using explicit unittest {} blocks.
>>> Unfortunately, there is currently no way to run these separately (esp.
>>> right after compilation) that I know of.
>>
>> Flectioned's unittest walker does exactly that:
>>
>> dmd -unittest -g -c <your source>
>> dmd flectioned.d unittest_walker.d -ofwhatever <your objects>
>> ./whatever
>>
>> http://flectioned.kuehne.cn
>
> Interesting, I wasn't aware of that.
> Looking at the source though, is there any particular reason the code is
> in a static this() instead of in the empty void main() at the end?
Yes, "int main(char[][])" isn't executed until after the unittests are
run.
> Shouldn't unit tests be performed after all static constructors have
> been completed, so that the modules being tested have been initialized?
Fixed.
> But what exactly is the use case here? To just run the unit tests and
> avoid running main()?
> Wouldn't that be more easily accomplished by just letting the unit tests
> run "manually" and providing an empty main()?
> Of course, that wouldn't provide as nice an example of flectioned use :P .
Normaly the first failing unittest would terminate the programm,
unittest_walker however executes all unittests and displays their
failure/success.
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFF/WDHLK5blCcjpWoRApitAJ9pcL+SBhFasCR0OsYzwFP3z5gP7ACfdW77
4EtvBlKRjhcsqCdPmWyuDR0=
=M526
-----END PGP SIGNATURE-----
More information about the Digitalmars-d
mailing list