mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
192165: add testcase for possibly related Stackoverflow
This commit is contained in:
parent
9874cfefe5
commit
0257c07538
3 changed files with 66 additions and 22 deletions
|
@ -0,0 +1,60 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.pdom.tests;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
public class PDOMCBugsTest extends BaseTestCase {
|
||||
ICProject cproject;
|
||||
|
||||
public static Test suite() {
|
||||
return suite(PDOMCBugsTest.class);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
cproject= CProjectHelper.createCProject("PDOMCBugsTest"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
|
||||
Bundle b = CTestPlugin.getDefault().getBundle();
|
||||
StringBuffer[] testData = TestSourceReader.getContentsForTest(b, "parser", PDOMCBugsTest.this.getClass(), getName(), 1);
|
||||
|
||||
IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), testData[0].toString());
|
||||
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
|
||||
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
||||
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
if (cproject != null) {
|
||||
cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||
}
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
// typedef typeof(T) T;
|
||||
public void _test192165() {
|
||||
// a StackOverflow occurs at this point
|
||||
}
|
||||
|
||||
public void testDummy() {}
|
||||
}
|
|
@ -16,14 +16,10 @@ import java.io.File;
|
|||
import junit.framework.Test;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.index.IIndexLocationConverter;
|
||||
|
@ -56,11 +52,11 @@ import org.eclipse.core.runtime.content.IContentType;
|
|||
/**
|
||||
* Tests bugs found in the PDOM
|
||||
*/
|
||||
public class PDOMBugsTest extends BaseTestCase {
|
||||
public class PDOMCPPBugsTest extends BaseTestCase {
|
||||
ICProject cproject;
|
||||
|
||||
public static Test suite() {
|
||||
return suite(PDOMBugsTest.class);
|
||||
return suite(PDOMCPPBugsTest.class);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
|
@ -202,7 +198,7 @@ public class PDOMBugsTest extends BaseTestCase {
|
|||
cHeaders.create(true, true, NPM);
|
||||
LanguageManager lm= LanguageManager.getInstance();
|
||||
|
||||
IFile cHeader= TestSourceReader.createFile(cHeaders, "cHeader.h", "struct S {int a; int b; };\nvoid foo(struct S s) {}\n");
|
||||
IFile cHeader= TestSourceReader.createFile(cHeaders, "cHeader.h", "extern \"C\" void foo(int i) {}\n");
|
||||
ICProjectDescription pd= CCorePlugin.getDefault().getProjectDescription(project);
|
||||
ICConfigurationDescription cfgd= pd.getDefaultSettingConfiguration();
|
||||
ProjectLanguageConfiguration plc= LanguageManager.getInstance().getLanguageConfiguration(project);
|
||||
|
@ -210,7 +206,7 @@ public class PDOMBugsTest extends BaseTestCase {
|
|||
IContentType ct= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_CHEADER);
|
||||
lm.storeLanguageMappingConfiguration(project, new IContentType[] {ct});
|
||||
|
||||
IFile cppSource= TestSourceReader.createFile(cHeaders, "cppSource.cpp", "struct S s; void ref() {foo(s);}");
|
||||
IFile cppSource= TestSourceReader.createFile(cHeaders, "cppSource.cpp", "void ref() {foo(1);}");
|
||||
|
||||
IndexerPreferences.set(project, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
|
||||
CCorePlugin.getIndexManager().reindex(cproject);
|
||||
|
@ -230,19 +226,6 @@ public class PDOMBugsTest extends BaseTestCase {
|
|||
assertEquals(1, nms.length);
|
||||
assertTrue(nms[0].getFileLocation().getFileName().endsWith(".cpp"));
|
||||
}
|
||||
|
||||
{ // test struct S has resolved to the C linkage
|
||||
IIndexBinding[] ib= pdom.findBindings(new char[][]{{'s'}}, IndexFilter.ALL, NPM);
|
||||
assertEquals(1, ib.length);
|
||||
|
||||
assertTrue(ib[0] instanceof ICPPVariable);
|
||||
ICPPVariable cppv= (ICPPVariable) ib[0];
|
||||
|
||||
IType type= cppv.getType();
|
||||
assertTrue(type instanceof ICompositeType);
|
||||
assertTrue(((ICompositeType) type).getKey() == ICompositeType.k_struct);
|
||||
assertTrue(((ICompositeType) type).getLinkage().getID().equals(ILinkage.C_LINKAGE_ID));
|
||||
}
|
||||
} finally {
|
||||
pdom.releaseReadLock();
|
||||
}
|
|
@ -27,7 +27,8 @@ public class PDOMTests extends TestSuite {
|
|||
|
||||
suite.addTest(DBTest.suite());
|
||||
suite.addTest(DBPropertiesTests.suite());
|
||||
suite.addTest(PDOMBugsTest.suite());
|
||||
suite.addTest(PDOMCBugsTest.suite());
|
||||
suite.addTest(PDOMCPPBugsTest.suite());
|
||||
suite.addTest(PDOMSearchTest.suite());
|
||||
suite.addTest(PDOMLocationTests.suite());
|
||||
suite.addTest(PDOMProviderTests.suite());
|
||||
|
|
Loading…
Add table
Reference in a new issue