Changeset View
Changeset View
Standalone View
Standalone View
duchain/tests/duchain_multiplefiles.cpp
Show All 24 Lines | |||||
25 | #include <tests/testcore.h> | 25 | #include <tests/testcore.h> | ||
26 | #include <interfaces/ilanguagecontroller.h> | 26 | #include <interfaces/ilanguagecontroller.h> | ||
27 | #include <interfaces/icompletionsettings.h> | 27 | #include <interfaces/icompletionsettings.h> | ||
28 | #include <language/backgroundparser/backgroundparser.h> | 28 | #include <language/backgroundparser/backgroundparser.h> | ||
29 | #include <tests/testproject.h> | 29 | #include <tests/testproject.h> | ||
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 | | |||
36 | using namespace KDevelop; | 37 | using namespace KDevelop; | ||
37 | using namespace Php; | 38 | using namespace Php; | ||
38 | 39 | | |||
39 | void TestDUChainMultipleFiles::initTestCase() | 40 | void TestDUChainMultipleFiles::initTestCase() | ||
40 | { | 41 | { | ||
▲ Show 20 Lines • Show All 248 Lines • ▼ Show 20 Line(s) | 281 | for (int i = 0; i < 2; ++i) { | |||
289 | DUChainReadLocker lock; | 290 | DUChainReadLocker lock; | ||
290 | auto top = file.topContext(); | 291 | auto top = file.topContext(); | ||
291 | QVERIFY(top); | 292 | QVERIFY(top); | ||
292 | QCOMPARE(top->problems().size(), 1); | 293 | QCOMPARE(top->problems().size(), 1); | ||
293 | QCOMPARE(top->problems().at(0)->description(), QString("TODO")); | 294 | QCOMPARE(top->problems().at(0)->description(), QString("TODO")); | ||
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 | } |