mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Add test for deduction guide template vs index issue
Add new index binding resolution test strategy SinglePDOMReindexedTestStrategy which does reindex project after adding test case sources. Clean up redundand C++17 setup helper classes from test since deduction guides are always enabled. Add test case modelling std::map resolution problem and make sure to run it with new test strategy to reproduce the issue. Bug #438
This commit is contained in:
parent
8091626ee4
commit
727430964a
2 changed files with 92 additions and 54 deletions
|
@ -631,13 +631,7 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
|
|||
|
||||
setTestSpecificFlags(sourceContents);
|
||||
|
||||
IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), headerContents);
|
||||
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
|
||||
waitForIndexer(cproject);
|
||||
|
||||
IFile cppfile = TestSourceReader.createFile(cproject.getProject(),
|
||||
new Path("references.c" + (cpp ? "pp" : "")), sourceContents);
|
||||
waitForIndexer(cproject);
|
||||
IFile cppfile = createSourceFilesAndIndex(headerContents, sourceContents);
|
||||
|
||||
if (DEBUG) {
|
||||
System.out.println("Project PDOM: " + getName());
|
||||
|
@ -650,6 +644,18 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
|
|||
ast = TestSourceReader.createIndexBasedAST(index, cproject, cppfile);
|
||||
}
|
||||
|
||||
IFile createSourceFilesAndIndex(String headerContents, String sourceContents) throws Exception {
|
||||
IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), headerContents);
|
||||
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
|
||||
waitForIndexer(cproject);
|
||||
|
||||
IFile cppfile = TestSourceReader.createFile(cproject.getProject(),
|
||||
new Path("references.c" + (cpp ? "pp" : "")), sourceContents);
|
||||
waitForIndexer(cproject);
|
||||
|
||||
return cppfile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
if (index != null) {
|
||||
|
@ -670,6 +676,35 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
|
|||
public boolean isCompositeIndex() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean getIsCPP() {
|
||||
return cpp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This strategy is similar to SinglePDOMTestStrategy but it does reindex project after adding all files.
|
||||
*/
|
||||
protected class SinglePDOMReindexedTestStrategy extends SinglePDOMTestStrategy {
|
||||
|
||||
public SinglePDOMReindexedTestStrategy(boolean cpp) {
|
||||
super(cpp);
|
||||
}
|
||||
|
||||
@Override
|
||||
IFile createSourceFilesAndIndex(String headerContents, String sourceContents) throws Exception {
|
||||
CCorePlugin.getIndexManager().setIndexerId(getCProject(), IPDOMManager.ID_FAST_INDEXER);
|
||||
waitForIndexer(getCProject());
|
||||
|
||||
TestSourceReader.createFile(getCProject().getProject(), new Path("header.h"), headerContents);
|
||||
IFile cppfile = TestSourceReader.createFile(getCProject().getProject(),
|
||||
new Path("references.c" + (getIsCPP() ? "pp" : "")), sourceContents);
|
||||
|
||||
CCorePlugin.getIndexManager().reindex(getCProject());
|
||||
waitForIndexer(getCProject());
|
||||
|
||||
return cppfile;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,6 @@ import static org.eclipse.cdt.core.parser.tests.ast2.CommonCPPTypes.double_;
|
|||
import static org.eclipse.cdt.core.parser.tests.ast2.CommonCPPTypes.int_;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.testplugin.TestScannerProvider;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
|
@ -26,53 +25,9 @@ import junit.framework.TestSuite;
|
|||
* AST tests for C++17 deduction guides via PDOM.
|
||||
*/
|
||||
public abstract class IndexDeductionGuideTest extends IndexBindingResolutionTestBase {
|
||||
private static void cxx17SetUp() {
|
||||
// Deduction guides are now enabled unconditionally
|
||||
}
|
||||
|
||||
private static void cxx17TearDown() {
|
||||
TestScannerProvider.clear();
|
||||
}
|
||||
|
||||
public class Cxx17ReferencedProject extends ReferencedProject {
|
||||
public Cxx17ReferencedProject() {
|
||||
super(true /* cpp */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
cxx17SetUp();
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
cxx17TearDown();
|
||||
}
|
||||
}
|
||||
|
||||
public class Cxx17SinglePDOMTestStrategy extends SinglePDOMTestStrategy {
|
||||
public Cxx17SinglePDOMTestStrategy() {
|
||||
super(true /* cpp */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
cxx17SetUp();
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
cxx17TearDown();
|
||||
}
|
||||
}
|
||||
|
||||
public static class IndexDeductionGuideTestSingleProject extends IndexDeductionGuideTest {
|
||||
public IndexDeductionGuideTestSingleProject() {
|
||||
setStrategy(new Cxx17SinglePDOMTestStrategy());
|
||||
setStrategy(new SinglePDOMTestStrategy(true /* cpp */));
|
||||
}
|
||||
|
||||
public static TestSuite suite() {
|
||||
|
@ -80,9 +35,19 @@ public abstract class IndexDeductionGuideTest extends IndexBindingResolutionTest
|
|||
}
|
||||
}
|
||||
|
||||
public static class IndexDeductionGuideTestSingleProjectReindexed extends IndexDeductionGuideTest {
|
||||
public IndexDeductionGuideTestSingleProjectReindexed() {
|
||||
setStrategy(new SinglePDOMReindexedTestStrategy(true /* cpp */));
|
||||
}
|
||||
|
||||
public static TestSuite suite() {
|
||||
return suite(IndexDeductionGuideTestSingleProjectReindexed.class);
|
||||
}
|
||||
}
|
||||
|
||||
public static class IndexDeductionGuideTestProjectWithDepProj extends IndexDeductionGuideTest {
|
||||
public IndexDeductionGuideTestProjectWithDepProj() {
|
||||
setStrategy(new Cxx17ReferencedProject());
|
||||
setStrategy(new ReferencedProject(true /* cpp */));
|
||||
}
|
||||
|
||||
public static TestSuite suite() {
|
||||
|
@ -92,6 +57,7 @@ public abstract class IndexDeductionGuideTest extends IndexBindingResolutionTest
|
|||
|
||||
public static void addTests(TestSuite suite) {
|
||||
suite.addTest(IndexDeductionGuideTestSingleProject.suite());
|
||||
suite.addTest(IndexDeductionGuideTestSingleProjectReindexed.suite());
|
||||
suite.addTest(IndexDeductionGuideTestProjectWithDepProj.suite());
|
||||
}
|
||||
|
||||
|
@ -135,4 +101,41 @@ public abstract class IndexDeductionGuideTest extends IndexBindingResolutionTest
|
|||
|
||||
assertType(getBindingFromASTName("convert(", 7), varDouble.getType());
|
||||
}
|
||||
|
||||
// #pragma once
|
||||
//
|
||||
// namespace test
|
||||
// {
|
||||
// typedef double result_t;
|
||||
// template<typename _Tp = void> struct Dependent;
|
||||
// }
|
||||
//
|
||||
// template<typename _Key, typename _Equal> struct Intermediate
|
||||
// {
|
||||
// public:
|
||||
// typedef test::result_t result_type;
|
||||
// };
|
||||
//
|
||||
// template<typename _Key, typename _Dependent = test::Dependent<_Key>>
|
||||
// class Base {
|
||||
// typedef Intermediate<_Key, _Dependent> _Intermediate;
|
||||
//
|
||||
// public:
|
||||
// typedef typename _Intermediate::result_type result_type;
|
||||
// };
|
||||
|
||||
// using BaseType = Base<int>::result_type; // test marker
|
||||
//
|
||||
// namespace test_std_alternative {
|
||||
// template<typename A, typename B>
|
||||
// class Unrelated;
|
||||
//
|
||||
// using namespace test;
|
||||
// template<typename _KeyInUnrelated>
|
||||
// Unrelated(_KeyInUnrelated)
|
||||
// -> Unrelated<_KeyInUnrelated, Dependent<_KeyInUnrelated>>;
|
||||
// }
|
||||
public void testDeductionGuideTemplateIssue438() throws Exception {
|
||||
getBindingFromASTName("Base<int>::result_type; // test marker", 22);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue