Commit d4a791c6 authored by Milian Wolff's avatar Milian Wolff

partial clang completion tests: remove self-assignment results

Recent versions of clang won't suggest self-assignment anymore.
I.e. previously when one wrote

    foo bar =

one would get `bar` as a code completion suggestion, which is
obviously broken. Adapt the tests now that this is correctly
filtered out within clang.

This may break testing on older libclang, I don't care.
parent 8c631f09
......@@ -333,9 +333,8 @@ void TestCodeCompletion::testClangCodeCompletion_data()
QTest::newRow("assignment")
<< "int foo = 5; \nint bar = "
<< CompletionItems{{1,9}, {
"bar",
"foo",
}, {"bar","foo"}};
}, {"foo"}};
QTest::newRow("dotmemberaccess")
<< "class Foo { public: void foo() {} bool operator=(Foo &&) }; int main() { Foo f; \nf. "
<< CompletionItems{{1, 2}, {
......@@ -419,14 +418,14 @@ void TestCodeCompletion::testClangCodeCompletion_data()
QTest::newRow("look-ahead int")
<< "struct LookAhead { int intItem;}; int main() {LookAhead* pInstance; LookAhead instance; int i =\n }"
<< CompletionItems{{1, 0}, {
"LookAhead", "i", "instance",
"LookAhead", "instance",
"instance.intItem", "main",
"pInstance", "pInstance->intItem",
}};
QTest::newRow("look-ahead class")
<< "class Class{}; struct LookAhead {Class classItem;}; int main() {LookAhead* pInstance; LookAhead instance; Class cl =\n }"
<< CompletionItems{{1, 0}, {
"Class", "LookAhead", "cl",
"Class", "LookAhead",
"instance", "instance.classItem",
"main", "pInstance", "pInstance->classItem",
}};
......@@ -453,7 +452,7 @@ void TestCodeCompletion::testClangCodeCompletion_data()
<< "typedef double DOUBLE; struct LookAhead {DOUBLE doubleItem;};"
"int main() {LookAhead* pInstance; LookAhead instance; double i =\n "
<< CompletionItems{{1, 0}, {
"DOUBLE", "LookAhead", "i",
"DOUBLE", "LookAhead",
"instance", "instance.doubleItem",
"main", "pInstance", "pInstance->doubleItem",
}};
......@@ -461,7 +460,7 @@ void TestCodeCompletion::testClangCodeCompletion_data()
<< "struct LookAhead {int* pInt;};"
"int main() {LookAhead* pInstance; LookAhead instance; int* i =\n "
<< CompletionItems{{1, 0}, {
"LookAhead", "i", "instance",
"LookAhead", "instance",
"instance.pInt", "main",
"pInstance", "pInstance->pInt",
}};
......@@ -469,7 +468,7 @@ void TestCodeCompletion::testClangCodeCompletion_data()
<< "template <typename T> struct LookAhead {int intItem;};"
"int main() {LookAhead<int>* pInstance; LookAhead<int> instance; int i =\n "
<< CompletionItems{{1, 0}, {
"LookAhead", "i", "instance",
"LookAhead", "instance",
"instance.intItem", "main",
"pInstance", "pInstance->intItem",
}};
......@@ -477,7 +476,7 @@ void TestCodeCompletion::testClangCodeCompletion_data()
<< "template <typename T> struct LookAhead {T itemT;};"
"int main() {LookAhead<int>* pInstance; LookAhead<int> instance; int i =\n "
<< CompletionItems{{1, 0}, {
"LookAhead", "i", "instance",
"LookAhead", "instance",
"instance.itemT", "main",
"pInstance", "pInstance->itemT",
}};
......@@ -487,7 +486,7 @@ void TestCodeCompletion::testClangCodeCompletion_data()
<< CompletionItems{{1, 0}, {
"Class", "cl",
"cl.publicInt",
"i", "main",
"main",
}};
QTest::newRow("look-ahead auto item")
......@@ -495,7 +494,6 @@ void TestCodeCompletion::testClangCodeCompletion_data()
"int main() {auto instance = LookAhead(); int i = \n "
<< CompletionItems{{1, 0}, {
"LookAhead",
"i",
"instance",
"instance.intItem",
"main"
......@@ -1176,12 +1174,12 @@ void TestCodeCompletion::testCompletionPriority_data()
QTest::newRow("primary-types")
<< "class A{}; int main(){A a; int b; bool c = \n "
<< CompletionPriorityItems{{1,0}, {{"a", 0, 34}, {"b", 8, 0}, {"c", 9, 0}}};
<< CompletionPriorityItems{{1,0}, {{"a", 0, 34}, {"b", 8, 0}}};
QTest::newRow("reference")
<< "class A{}; class B{}; class C : public B{};"
"int main(){A tmp; A& a = tmp; C tmp2; C& c = tmp2; B& b =\n ;}"
<< CompletionPriorityItems{{1,0}, {{"a", 0, 21}, {"b", 9, 0},
<< CompletionPriorityItems{{1,0}, {{"a", 0, 21},
{"c", 8, 0, QStringLiteral("Reference to derived class is not added to the Best Matches group")}}};
QTest::newRow("typedef")
......@@ -1196,7 +1194,7 @@ void TestCodeCompletion::testCompletionPriority_data()
QTest::newRow("template")
<< "template <typename T> class Class{}; template <typename T> class Class2{};"
"int main(){ Class<int> a; Class2<int> b =\n }"
<< CompletionPriorityItems{{1,0}, {{"b", 9, 0}, {"a", 0, 21}}};
<< CompletionPriorityItems{{1,0}, {{"a", 0, 21}}};
QTest::newRow("protected-access")
<< "class Base { protected: int m_protected; };"
......@@ -1227,7 +1225,7 @@ void TestCodeCompletion::testVariableScope()
lock.lock();
const auto tester = ClangCodeCompletionItemTester(context);
QCOMPARE(tester.items.size(), 4);
QCOMPARE(tester.items.size(), 3);
auto item = tester.findItem(QStringLiteral("var"));
VERIFY(item);
QCOMPARE(item->declaration()->range().start, CursorInRevision(1, 14));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment