Changeset View
Changeset View
Standalone View
Standalone View
duchain/tests/uses.cpp
Show First 20 Lines • Show All 1095 Lines • ▼ Show 20 Line(s) | 1038 | { | |||
---|---|---|---|---|---|
1096 | 1096 | | |||
1097 | dec = top->findDeclarations(QualifiedIdentifier(QStringLiteral("verylong::b"))).first(); | 1097 | dec = top->findDeclarations(QualifiedIdentifier(QStringLiteral("verylong::b"))).first(); | ||
1098 | compareUses(dec, RangeInRevision(8, 19, 8, 20)); | 1098 | compareUses(dec, RangeInRevision(8, 19, 8, 20)); | ||
1099 | 1099 | | |||
1100 | dec = top->findDeclarations(QualifiedIdentifier(QStringLiteral("verylong::C"))).first(); | 1100 | dec = top->findDeclarations(QualifiedIdentifier(QStringLiteral("verylong::C"))).first(); | ||
1101 | compareUses(dec, RangeInRevision(8, 30, 8, 31)); | 1101 | compareUses(dec, RangeInRevision(8, 30, 8, 31)); | ||
1102 | } | 1102 | } | ||
1103 | 1103 | | |||
1104 | | ||||
1105 | void TestUses::useNamespaceFunctionConst() | ||||
1106 | { | ||||
1107 | // 0 1 2 3 4 5 6 7 | ||||
1108 | // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 | ||||
1109 | TopDUContext* top = parse("<?php\n" | ||||
1110 | /* 1*/ "namespace Foo\\Bar {function A(){} const B = 1;}\n" | ||||
1111 | /* 2*/ "namespace Qux {function F(){} const C = 2;}\n" | ||||
1112 | /* 3*/ "namespace Baz {function F(){} const C = 3;}\n" | ||||
1113 | /* 4*/ "namespace {\n" | ||||
1114 | /* 5*/ "use function Foo\\Bar\\A;\n" | ||||
1115 | /* 6*/ "use const Foo\\Bar\\B;\n" | ||||
1116 | /* 7*/ "use function Qux\\F as QuxF, Baz\\F as BazF;\n" | ||||
pprkut: This doesn't seem to be working. "BazD" isn't a constant in the new context, i.e. "echo BazD;"… | |||||
1117 | /* 8*/ "use const Qux\\C as QuxC, Baz\\C as BazC;\n" | ||||
1118 | /* 9*/ "echo A();\n" | ||||
1119 | /*10*/ "echo B;\n" | ||||
1120 | /*11*/ "echo QuxF();\n" | ||||
1121 | /*12*/ "echo QuxC;\n" | ||||
1122 | /*13*/ "echo BazF();\n" | ||||
1123 | /*14*/ "echo BazC;\n" | ||||
1124 | "}\n", DumpNone); | ||||
1125 | QVERIFY(top); | ||||
1126 | DUChainReleaser releaseTop(top); | ||||
1127 | DUChainWriteLocker lock; | ||||
1128 | | ||||
1129 | Declaration* dec; | ||||
1130 | dec = top->findDeclarations(QualifiedIdentifier(QStringLiteral("a"))).first(); | ||||
1131 | QVERIFY(dec); | ||||
1132 | QCOMPARE(dec->kind(), Declaration::Type); | ||||
1133 | compareUses(dec, QList<RangeInRevision>() << RangeInRevision(5, 21, 5, 22) << RangeInRevision(9, 5, 9, 6)); | ||||
1134 | | ||||
This is fine as a duchain test (within duchain.cpp), but for uses you should compare that the actual references are correct. See calls to compareUses() in other tests here pprkut: This is fine as a duchain test (within duchain.cpp), but for uses you should compare that the… | |||||
1135 | dec = top->findDeclarations(QualifiedIdentifier(QStringLiteral("B"))).first(); | ||||
1136 | QVERIFY(dec); | ||||
1137 | QCOMPARE(dec->kind(), Declaration::Instance); | ||||
1138 | compareUses(dec, QList<RangeInRevision>() << RangeInRevision(6, 18, 6, 19) << RangeInRevision(10, 5, 10, 6)); | ||||
1139 | | ||||
1140 | dec = top->findDeclarations(QualifiedIdentifier(QStringLiteral("quxf"))).first(); | ||||
1141 | QVERIFY(dec); | ||||
1142 | QCOMPARE(dec->kind(), Declaration::Type); | ||||
1143 | compareUses(dec, QList<RangeInRevision>() << RangeInRevision(7, 17, 7, 18) << RangeInRevision(11, 5, 11, 9)); | ||||
1144 | | ||||
1145 | dec = top->findDeclarations(QualifiedIdentifier(QStringLiteral("bazf"))).first(); | ||||
1146 | QVERIFY(dec); | ||||
1147 | QCOMPARE(dec->kind(), Declaration::Type); | ||||
1148 | compareUses(dec, QList<RangeInRevision>() << RangeInRevision(7, 32, 7, 33) << RangeInRevision(13, 5, 13, 9)); | ||||
1149 | | ||||
1150 | dec = top->findDeclarations(QualifiedIdentifier(QStringLiteral("QuxC"))).first(); | ||||
1151 | QVERIFY(dec); | ||||
1152 | QCOMPARE(dec->kind(), Declaration::Instance); | ||||
1153 | compareUses(dec, QList<RangeInRevision>() << RangeInRevision(8, 14, 8, 15) << RangeInRevision(12, 5, 12, 9)); | ||||
1154 | | ||||
1155 | dec = top->findDeclarations(QualifiedIdentifier(QStringLiteral("BazC"))).first(); | ||||
1156 | QVERIFY(dec); | ||||
1157 | QCOMPARE(dec->kind(), Declaration::Instance); | ||||
1158 | compareUses(dec, QList<RangeInRevision>() << RangeInRevision(8, 29, 8, 30) << RangeInRevision(14, 5, 14, 9)); | ||||
1159 | } | ||||
1160 | | ||||
1104 | void TestUses::lateStatic() | 1161 | void TestUses::lateStatic() | ||
1105 | { | 1162 | { | ||
1106 | // 0 1 2 3 4 5 6 7 | 1163 | // 0 1 2 3 4 5 6 7 | ||
1107 | // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 | 1164 | // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 | ||
1108 | TopDUContext* top = parse("<?php class a { function b() { static::b(); } }", DumpAll); | 1165 | TopDUContext* top = parse("<?php class a { function b() { static::b(); } }", DumpAll); | ||
1109 | QVERIFY(top); | 1166 | QVERIFY(top); | ||
1110 | DUChainReleaser releaseTop(top); | 1167 | DUChainReleaser releaseTop(top); | ||
1111 | DUChainWriteLocker lock; | 1168 | DUChainWriteLocker lock; | ||
▲ Show 20 Lines • Show All 623 Lines • Show Last 20 Lines |
This doesn't seem to be working. "BazD" isn't a constant in the new context, i.e. "echo BazD;" has no highlighting for BazD.