Entry (main) method inside a class?

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Sun Mar 18 09:38:20 PDT 2007


Thomas Kuehne wrote:
> 
> Frits van Bommel schrieb am 2007-03-17:
>> Shouldn't unit tests be performed after all static constructors have 
>> been completed, so that the modules being tested have been initialized?
> 
> Fixed.

Interesting solution, just replacing the _moduleUnitTests() that 
normally runs them :).
(I guess that's the natural place to put it though)
Unfortunate about the ugly warning this produces ("usr/bin/ld: Warning: 
size of symbol `_moduleUnitTests' changed from 1084 in unittest_walker.o 
to 58 [...]").

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

Ah yes, forgot about that (failed unit tests aborting the program).




About your sample.d: It thinks I'm a Windows user who didn't compile 
Phobos with debug symbols :P.
In reality, I'm using GDC 0.23 on amd64 Linux.
It turns out GDC's std/math.d only declares isnormal() itself if on x86, 
otherwise it aliases gcc.config.isnormal() to do the job...
(Adding "version(GNU) if(!funcs) { funcs = "gcc.config.isnormal" in 
functions; }" right after the lookup should fix it)

Also, your struct example seems to have a typo (0x13_45_67_AB != 
0x1234567AB).

And some unit tests in flectioned.d fail:
---
$ gdmd -L--allow-multiple-definition -fall-sources -unittest -oftest 
test.d cn/kuehne/flectioned.d cn/kuehne/unittest_walker.d
/usr/bin/ld: Warning: size of symbol `_moduleUnitTests' changed from 
1084 in unittest_walker.o to 58 in 
/home/urxae/opt/gdc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.1.1/../../../../lib64/libgphobos.a(moduleinit.o)
$ ./test
[snip]
testing cn.kuehne.flectioned.TracedException.__unittest21 ... FAILED: 
(std.asserterror.AssertError) AssertError Failure 
cn/kuehne/flectioned.d(991)
testing cn.kuehne.flectioned.Trace.__unittest18 ... FAILED: 
(std.asserterror.AssertError) AssertError Failure 
cn/kuehne/flectioned.d(654)
testing cn.kuehne.flectioned.Trace.__unittest19 ... FAILED: 
(std.asserterror.AssertError) AssertError Failure 
cn/kuehne/flectioned.d(654)
testing cn.kuehne.flectioned.TracedException.__unittest22 ... FAILED: 
(std.asserterror.AssertError) AssertError Failure 
cn/kuehne/flectioned.d(654)
testing cn.kuehne.flectioned.Trace.__unittest17 ... FAILED: 
(std.asserterror.AssertError) AssertError Failure 
cn/kuehne/flectioned.d(654)
[snip]
Summary: 29/5/34 (succeeded/failed/total)
---
(test.d contains only an empty main())



More information about the Digitalmars-d mailing list