[Issue 10992] Trait getUnitTests skips first test if aggregate contains multiple tests.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Sep 9 13:34:56 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10992



--- Comment #7 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-09-09 13:34:54 PDT ---
I've identified the problem:

UnitTestDeclaration *unitTest = symbol->unittest ? symbol->unittest :
symbol->isUnitTestDeclaration();
printf("-- %s %d\n", symbol->toChars(), unitTest);

This prints:

-- object 0
-- __unittestL3_1 2499632
-- __unittestL4_2 2500032
-- __unittestL5_3 2500032

Note how the last unittest has the same address as the one before it.

Here's a better printf:
printf("-- %s %d %d\n", symbol->toChars(), symbol->unittest,
symbol->isUnitTestDeclaration());

And the printout:

-- __unittestL3_1 2434096 2433696
-- __unittestL4_2 2434496 2434096
-- __unittestL5_3 0       2434496

Notice that the "unitTest" varriable assign statement will end up using the
address 2434496 twice.

@Jacob: The 'unittest' field was introduced by me, but I should have documented
it better. It should only be used for the DDOC documented unittest feature,
because what it really does is assigns the next physical unittest symbol to
whatever previous symbol there is (which itself might be a unittest).

So what should really be used is:

UnitTestDeclaration *unitTest = symbol->isUnitTestDeclaration();

I'll make a pull to fix this.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list