Assert in duchain during PHP Unit-Test

Milian Wolff mail at milianw.de
Tue May 12 15:10:32 UTC 2009


David Nolden schrieb:
> Am Dienstag 12 Mai 2009 13:56:58 schrieb Milian Wolff:
>> David Nolden schrieb:
>>> Am Montag 11 Mai 2009 22:33:48 schrieb Niko Sams:
>>>> I added because of a duchain bug that did't allow more than about
>>>> 5000(?) declarations
>>>> in one context. Then David added support for that using MonsterBuckets
>>>> or something like that.
>>>> Afaik this test passed before our hackaton - so it could be related to
>>>> the ref-count patches?
>>> I've checked the assertion, and added a comment to it. The problem: You
>>> call DUChain::self()->removeDocumentChain(..), without calling
>>> DUChain::self()-
>>>
>>>> addDocumentChain(..) first.
>>> Greetings, David
>> Thanks! Now I check if the context was added and only remove it in these
>> cases.
>>
>> Or would there be an advantage to add the context to the chain? Since
>> it's for tests only I doubt I want to add it to the chain...
> It needs to be added so that declaration lookup, indexed 
> declarations/contexts, and all that stuff works. But for that one specific 
> test, it probably doesn't matter, so you can equally as well just delete it 
> in-place.

Actually I'll revert the patch - it did not fix it 100% and the files 
contexts should all be in the chain (the parser adds them 
automatically!). Interestingly I tracked the problem down:

this works (note the sub-contexts):

void TestDUChain::testObjectWithClassName()
{

     //                 0         1         2         3         4 
   5         6         7
     // 
01234567890123456789012345678901234567890123456789012345678901234567890123456789
     {
         QByteArray method("<? class setupPage {} $setupPage = new 
setupPage; $setupPage->foo();");
         TopDUContext* top = parse(method, DumpNone, 
"testObjectWithClassName.php");
         DUChainReleaser releaseTop(top);
     }

     {
         QByteArray method2("<? $setupPage = new setupPage; 
$setupPage->foo();");
         TopDUContext* top2 = parse(method2, DumpNone, 
"testObjectWithClassName.php");
         DUChainReleaser releaseTop2(top2);
     }
}

this not:


void TestDUChain::testObjectWithClassName()
{

     //                 0         1         2         3         4 
   5         6         7
     // 
01234567890123456789012345678901234567890123456789012345678901234567890123456789
     QByteArray method("<? class setupPage {} $setupPage = new 
setupPage; $setupPage->foo();");
     TopDUContext* top = parse(method, DumpNone, 
"testObjectWithClassName.php");
     DUChainReleaser releaseTop(top);

     QByteArray method2("<? $setupPage = new setupPage; 
$setupPage->foo();");
     TopDUContext* top2 = parse(method2, DumpNone, 
"testObjectWithClassName.php");
     DUChainReleaser releaseTop2(top2);
}

Any idea? I'll commit this "workaround" (and will revert the change to 
the top-context releaser). Though an in-depth explanation would be better!

-- 
Milian Wolff
http://milianw.de




More information about the KDevelop-devel mailing list