Changeset View
Changeset View
Standalone View
Standalone View
duchain/tests/duchain_multiplefiles.cpp
Context not available. | |||||
30 | #include <tests/testfile.h> | 30 | #include <tests/testfile.h> | ||
---|---|---|---|---|---|
31 | #include <language/duchain/declaration.h> | 31 | #include <language/duchain/declaration.h> | ||
32 | #include <language/duchain/problem.h> | 32 | #include <language/duchain/problem.h> | ||
33 | #include <language/duchain/types/integraltype.h> | ||||
33 | 34 | | |||
34 | QTEST_MAIN(Php::TestDUChainMultipleFiles) | 35 | QTEST_MAIN(Php::TestDUChainMultipleFiles) | ||
35 | 36 | | |||
Context not available. | |||||
294 | QCOMPARE(top->problems().at(0)->range(), RangeInRevision(2, 3, 2, 7)); | 295 | QCOMPARE(top->problems().at(0)->range(), RangeInRevision(2, 3, 2, 7)); | ||
295 | } | 296 | } | ||
296 | } | 297 | } | ||
298 | | ||||
299 | void TestDUChainMultipleFiles::testIteratorForeachReparse() { | ||||
300 | TestFile file(QStringLiteral("<?php\n/*\n\n/*\n*/\nforeach (new A() as $a) {}\nclass A implements Iterator {\npublic function current() { return 0; }\n}"), QStringLiteral("php")); | ||||
301 | | ||||
302 | auto features = TopDUContext::AllDeclarationsAndContexts; | ||||
303 | | ||||
304 | for (int i = 0; i < 2; ++i) { | ||||
305 | if (i == 1) { | ||||
306 | file.setFileContents(QStringLiteral("<?php\n/*\n*/\n\n/*\n*/\nforeach (new A() as $a) {}\nclass A implements Iterator {\npublic function current() { return 0; }\n}")); | ||||
307 | features = static_cast<TopDUContext::Features>(features | TopDUContext::ForceUpdate); | ||||
308 | } | ||||
309 | | ||||
310 | file.parse(features); | ||||
311 | QVERIFY(file.waitForParsed()); | ||||
312 | | ||||
313 | DUChainReadLocker lock; | ||||
314 | auto top = file.topContext(); | ||||
315 | QVERIFY(top); | ||||
316 | QVERIFY(top->localDeclarations().size() == 2); | ||||
317 | QCOMPARE(top->localDeclarations().at(0)->qualifiedIdentifier(), QualifiedIdentifier("a")); | ||||
318 | | ||||
319 | IntegralType::Ptr type = top->localDeclarations().at(0)->type<IntegralType>(); | ||||
320 | QVERIFY(type); | ||||
321 | //Should actually parse as an TypeInt, but this does not work. | ||||
322 | QVERIFY(type->dataType() == IntegralType::TypeMixed); | ||||
323 | } | ||||
324 | } | ||||
Context not available. |