Changeset View
Changeset View
Standalone View
Standalone View
duchain/tests/duchain.cpp
Context not available. | |||||
28 | #include <language/duchain/types/functiontype.h> | 28 | #include <language/duchain/types/functiontype.h> | ||
---|---|---|---|---|---|
29 | #include <language/duchain/types/integraltype.h> | 29 | #include <language/duchain/types/integraltype.h> | ||
30 | #include <language/duchain/types/unsuretype.h> | 30 | #include <language/duchain/types/unsuretype.h> | ||
31 | #include <language/duchain/types/arraytype.h> | ||||
31 | #include <language/duchain/namespacealiasdeclaration.h> | 32 | #include <language/duchain/namespacealiasdeclaration.h> | ||
32 | #include <language/editor/documentrange.h> | 33 | #include <language/editor/documentrange.h> | ||
33 | 34 | | |||
Context not available. | |||||
44 | 45 | | |||
45 | #include "../types/structuretype.h" | 46 | #include "../types/structuretype.h" | ||
46 | #include "../types/integraltypeextended.h" | 47 | #include "../types/integraltypeextended.h" | ||
47 | #include "../types/indexedcontainer.h" | | |||
48 | 48 | | |||
49 | #include <QStandardPaths> | 49 | #include <QStandardPaths> | ||
50 | 50 | | |||
Context not available. | |||||
1012 | 1012 | | |||
1013 | AbstractType::Ptr arg = fun->arguments().first(); | 1013 | AbstractType::Ptr arg = fun->arguments().first(); | ||
1014 | QVERIFY(arg); | 1014 | QVERIFY(arg); | ||
1015 | QVERIFY(arg.cast<IndexedContainer>()); | 1015 | QVERIFY(arg.cast<KDevelop::ArrayType>()); | ||
1016 | QCOMPARE(arg.cast<IndexedContainer>()->typesCount(), 1); | | |||
1017 | QCOMPARE(arg.cast<IndexedContainer>()->prettyName().str(), QStringLiteral("array")); | | |||
1018 | 1016 | | |||
1019 | AbstractType::Ptr typehint = arg.cast<IndexedContainer>()->typeAt(0).abstractType(); | 1017 | AbstractType::Ptr typehint = arg.cast<KDevelop::ArrayType>()->elementType(); | ||
1020 | QVERIFY(typehint); | 1018 | QVERIFY(typehint); | ||
1021 | QVERIFY(IntegralType::Ptr::dynamicCast(typehint)); | 1019 | QVERIFY(IntegralType::Ptr::dynamicCast(typehint)); | ||
1022 | QVERIFY(IntegralType::Ptr::dynamicCast(typehint)->dataType() == IntegralType::TypeMixed); | 1020 | QVERIFY(IntegralType::Ptr::dynamicCast(typehint)->dataType() == IntegralType::TypeMixed); | ||
Context not available. | |||||
1039 | 1037 | | |||
1040 | AbstractType::Ptr arg = fun->arguments().first(); | 1038 | AbstractType::Ptr arg = fun->arguments().first(); | ||
1041 | QVERIFY(arg); | 1039 | QVERIFY(arg); | ||
1042 | QVERIFY(arg.cast<IndexedContainer>()); | 1040 | QVERIFY(arg.cast<KDevelop::ArrayType>()); | ||
1043 | QCOMPARE(arg.cast<IndexedContainer>()->typesCount(), 1); | | |||
1044 | QCOMPARE(arg.cast<IndexedContainer>()->prettyName().str(), QStringLiteral("array")); | | |||
1045 | 1041 | | |||
1046 | AbstractType::Ptr typehint = arg.cast<IndexedContainer>()->typeAt(0).abstractType(); | 1042 | AbstractType::Ptr typehint = arg.cast<KDevelop::ArrayType>()->elementType(); | ||
1047 | QVERIFY(typehint); | 1043 | QVERIFY(typehint); | ||
1048 | QCOMPARE(typehint->toString(), QStringLiteral("A")); | 1044 | QCOMPARE(typehint->toString(), QStringLiteral("A")); | ||
1049 | } | 1045 | } | ||
Context not available. | |||||
2739 | QCOMPARE(aDec->uses().begin()->size(), 4); | 2735 | QCOMPARE(aDec->uses().begin()->size(), 4); | ||
2740 | } | 2736 | } | ||
2741 | 2737 | | |||
2738 | void TestDUChain::foreachArray() | ||||
2739 | { | ||||
2740 | { | ||||
2741 | QByteArray code = "<?\n" | ||||
2742 | "class Foo {};\n" | ||||
2743 | "/// @param Foo[]\n" | ||||
2744 | "function bar($a) {\n" | ||||
2745 | " foreach($a as $e){ $e; }\n" | ||||
2746 | "}\n"; | ||||
2747 | TopDUContext* top = parse(code, DumpNone); | ||||
2748 | DUChainReleaser releaseTop(top); | ||||
2749 | DUChainWriteLocker lock(DUChain::lock()); | ||||
2750 | | ||||
2751 | DUContext* barContext = top->childContexts().last(); | ||||
2752 | QCOMPARE(barContext->localScopeIdentifier(), QualifiedIdentifier("bar")); | ||||
2753 | | ||||
2754 | Declaration* eDec = barContext->localDeclarations().first(); | ||||
2755 | QCOMPARE(eDec->qualifiedIdentifier(), QualifiedIdentifier("bar::e")); | ||||
2756 | QVERIFY(eDec->type<StructureType>()); | ||||
2757 | QCOMPARE(eDec->type<StructureType>()->qualifiedIdentifier(), QualifiedIdentifier("foo")); | ||||
2758 | } | ||||
2759 | } | ||||
2760 | | ||||
2742 | void TestDUChain::returnThis() | 2761 | void TestDUChain::returnThis() | ||
2743 | { | 2762 | { | ||
2744 | QByteArray code("<? class A { \n/**\n * @return $this\n */\npublic function x() {} } "); | 2763 | QByteArray code("<? class A { \n/**\n * @return $this\n */\npublic function x() {} } "); | ||
Context not available. |