mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Added several core parser tests to the LR parser test suite
This commit is contained in:
parent
5a0701efaa
commit
72312ab02a
16 changed files with 473 additions and 277 deletions
|
@ -33,7 +33,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
*/
|
||||
public void test4s6() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("#ifdef _ _STDC_IEC_559_ _ /* FE_UPWARD defined */\n"); //$NON-NLS-1$
|
||||
buffer.append("#ifdef __STDC_IEC_559__ /* FE_UPWARD defined */\n"); //$NON-NLS-1$
|
||||
buffer.append("fesetround(FE_UPWARD);\n"); //$NON-NLS-1$
|
||||
buffer.append("#endif\n"); //$NON-NLS-1$
|
||||
parseCandCPP(buffer.toString(), false, 0);
|
||||
|
|
|
@ -22,6 +22,10 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
|||
*/
|
||||
public class SemanticsTests extends AST2BaseTest {
|
||||
|
||||
public SemanticsTests() {}
|
||||
public SemanticsTests(String name) { super(name); }
|
||||
|
||||
|
||||
// class A {};
|
||||
// class B {};
|
||||
//
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 IBM Corporation 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:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.lrparser.tests;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
|
||||
import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
|
||||
import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2CPPSpecFailingTest;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class LRCPPSpecFailingTest extends AST2CPPSpecFailingTest {
|
||||
|
||||
public static TestSuite suite() {
|
||||
return suite(LRCPPSpecFailingTest.class);
|
||||
}
|
||||
|
||||
public LRCPPSpecFailingTest() { }
|
||||
public LRCPPSpecFailingTest(String name) { super(name); }
|
||||
|
||||
|
||||
@Override
|
||||
protected void parseCandCPP( String code, boolean checkBindings, int expectedProblemBindings ) throws ParserException {
|
||||
parse(code, ParserLanguage.C, checkBindings, expectedProblemBindings);
|
||||
parse(code, ParserLanguage.CPP, checkBindings, expectedProblemBindings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean checkBindings, int expectedProblemBindings ) throws ParserException {
|
||||
ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
|
||||
return ParseHelper.parse(code, language, true, checkBindings, expectedProblemBindings );
|
||||
}
|
||||
|
||||
protected BaseExtensibleLanguage getCLanguage() {
|
||||
return C99Language.getDefault();
|
||||
}
|
||||
|
||||
protected BaseExtensibleLanguage getCPPLanguage() {
|
||||
return ISOCPPLanguage.getDefault();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,3 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 IBM Corporation 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:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.lrparser.tests;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 IBM Corporation 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:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.lrparser.tests;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 IBM Corporation 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:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.lrparser.tests;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
|
||||
import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
|
||||
import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2CSpecFailingTest;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class LRCSpecFailingTest extends AST2CSpecFailingTest {
|
||||
|
||||
public static TestSuite suite() {
|
||||
return suite(LRCSpecFailingTest.class);
|
||||
}
|
||||
|
||||
public LRCSpecFailingTest() { }
|
||||
public LRCSpecFailingTest(String name) { super(name); }
|
||||
|
||||
|
||||
@Override
|
||||
protected void parseCandCPP( String code, boolean checkBindings, int expectedProblemBindings ) throws ParserException {
|
||||
parse(code, ParserLanguage.C, checkBindings, expectedProblemBindings);
|
||||
parse(code, ParserLanguage.CPP, checkBindings, expectedProblemBindings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean checkBindings, int expectedProblemBindings ) throws ParserException {
|
||||
ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
|
||||
return ParseHelper.parse(code, language, true, checkBindings, expectedProblemBindings );
|
||||
}
|
||||
|
||||
protected BaseExtensibleLanguage getCLanguage() {
|
||||
return C99Language.getDefault();
|
||||
}
|
||||
|
||||
protected BaseExtensibleLanguage getCPPLanguage() {
|
||||
return ISOCPPLanguage.getDefault();
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
import org.eclipse.cdt.core.parser.tests.ast2.AST2CSpecTest;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
@SuppressWarnings({"restriction", "nls"})
|
||||
public class LRCSpecTests extends AST2CSpecTest {
|
||||
|
||||
public static TestSuite suite() {
|
||||
|
@ -52,157 +52,22 @@ public class LRCSpecTests extends AST2CSpecTest {
|
|||
return ISOCPPLanguage.getDefault();
|
||||
}
|
||||
|
||||
//Assignment statements cannot exists outside of a function body
|
||||
@Override
|
||||
|
||||
@Override // example code needs to be nested in a function body
|
||||
public void test5_1_2_3s15() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("//#include <stdio.h>\n"); //$NON-NLS-1$
|
||||
buffer.append("int foo() { \n"); //$NON-NLS-1$
|
||||
buffer.append("int sum;\n"); //$NON-NLS-1$
|
||||
buffer.append("char *p;\n"); //$NON-NLS-1$
|
||||
buffer.append("sum = sum * 10 - '0' + (*p++ = getchar());\n"); //$NON-NLS-1$
|
||||
buffer.append("sum = (((sum * 10) - '0') + ((*(p++)) = (getchar())));\n"); //$NON-NLS-1$
|
||||
buffer.append("} \n"); //$NON-NLS-1$
|
||||
parseCandCPP(buffer.toString(), false, 0);
|
||||
String code =
|
||||
"//#include <stdio.h>\n" +
|
||||
"int foo() { \n" +
|
||||
"int sum;\n" +
|
||||
"char *p;\n" +
|
||||
"sum = sum * 10 - '0' + (*p++ = getchar());\n" +
|
||||
"sum = (((sum * 10) - '0') + ((*(p++)) = (getchar())));\n" +
|
||||
"} \n";
|
||||
|
||||
parseCandCPP(code, false, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Tests from AST2CSpecFailingTests
|
||||
|
||||
/**
|
||||
* TODO: This one fails, it can't resolve one of the bindings (const t) I think
|
||||
*
|
||||
[--Start Example(C 6.7.7-6):
|
||||
typedef signed int t;
|
||||
typedef int plain;
|
||||
struct tag {
|
||||
unsigned t:4;
|
||||
const t:5;
|
||||
plain r:5;
|
||||
};
|
||||
t f(t (t));
|
||||
long t;
|
||||
--End Example]
|
||||
*/
|
||||
public void test6_7_7s6() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("typedef signed int t;\n"); //$NON-NLS-1$
|
||||
buffer.append("typedef int plain;\n"); //$NON-NLS-1$
|
||||
buffer.append("struct tag {\n"); //$NON-NLS-1$
|
||||
buffer.append("unsigned t:4;\n"); //$NON-NLS-1$
|
||||
buffer.append("const t:5;\n"); //$NON-NLS-1$
|
||||
buffer.append("plain r:5;\n"); //$NON-NLS-1$
|
||||
buffer.append("};\n"); //$NON-NLS-1$
|
||||
buffer.append("t f(t (t));\n"); //$NON-NLS-1$
|
||||
buffer.append("long t;\n"); //$NON-NLS-1$
|
||||
|
||||
try {
|
||||
parse(buffer.toString(), ParserLanguage.C, true, 0);
|
||||
} catch(AssertionFailedError _) {
|
||||
// there should be an error
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
[--Start Example(C 6.10.3.5-5):
|
||||
#define x 3
|
||||
#define f(a) f(x * (a))
|
||||
#undef x
|
||||
#define x 2
|
||||
#define g f
|
||||
#define z z[0]
|
||||
#define h g(~
|
||||
#define m(a) a(w)
|
||||
#define w 0,1
|
||||
#define t(a) a
|
||||
#define p() int
|
||||
#define q(x) x
|
||||
#define r(x,y) x ## y
|
||||
#define str(x) # x
|
||||
int foo() {
|
||||
p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };
|
||||
char c[2][6] = { str(hello), str() };
|
||||
}
|
||||
--End Example]
|
||||
*/
|
||||
@Override
|
||||
public void test6_10_3_5s5() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("#define x 3\n"); //$NON-NLS-1$
|
||||
buffer.append("#define f(a) f(x * (a))\n"); //$NON-NLS-1$
|
||||
buffer.append("#undef x\n"); //$NON-NLS-1$
|
||||
buffer.append("#define x 2\n"); //$NON-NLS-1$
|
||||
buffer.append("#define g f\n"); //$NON-NLS-1$
|
||||
buffer.append("#define z z[0]\n"); //$NON-NLS-1$
|
||||
buffer.append("#define h g(~\n"); //$NON-NLS-1$
|
||||
buffer.append("#define m(a) a(w)\n"); //$NON-NLS-1$
|
||||
buffer.append("#define w 0,1\n"); //$NON-NLS-1$
|
||||
buffer.append("#define t(a) a\n"); //$NON-NLS-1$
|
||||
buffer.append("#define p() int\n"); //$NON-NLS-1$
|
||||
buffer.append("#define q(x) x\n"); //$NON-NLS-1$
|
||||
buffer.append("#define r(x,y) x ## y\n"); //$NON-NLS-1$
|
||||
buffer.append("#define str(x) # x\n"); //$NON-NLS-1$
|
||||
buffer.append("int foo() {\n"); //$NON-NLS-1$
|
||||
buffer.append("p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };\n"); //$NON-NLS-1$
|
||||
buffer.append("char c[2][6] = { str(hello), str() };\n"); //$NON-NLS-1$
|
||||
buffer.append("}\n"); //$NON-NLS-1$
|
||||
|
||||
//parseCandCPP(buffer.toString(), true, 0);
|
||||
// TODO: this only works on the C99 parser for now
|
||||
parse(buffer.toString(), ParserLanguage.C, true, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
[--Start Example(C 6.10.3.5-7):
|
||||
#define t(x,y,z) x ## y ## z
|
||||
int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),
|
||||
t(10,,), t(,11,), t(,,12), t(,,) };
|
||||
--End Example]
|
||||
*/
|
||||
@Override
|
||||
public void test6_10_3_5s7() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("#define t(x,y,z) x ## y ## z\n"); //$NON-NLS-1$
|
||||
buffer.append("int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),\n"); //$NON-NLS-1$
|
||||
buffer.append("t(10,,), t(,11,), t(,,12), t(,,) };\n"); //$NON-NLS-1$
|
||||
|
||||
// TODO: this only works on the C99 parser for now
|
||||
parse(buffer.toString(), ParserLanguage.C, true, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test seems to be incorrect in AST2SpecTests
|
||||
*/
|
||||
@Override
|
||||
public void test4s6() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("#ifdef __STDC_IEC_559__ /* FE_UPWARD defined */\n"); //$NON-NLS-1$
|
||||
buffer.append("fesetround(FE_UPWARD);\n"); //$NON-NLS-1$
|
||||
buffer.append("#endif\n"); //$NON-NLS-1$
|
||||
parseCandCPP(buffer.toString(), false, 0);
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
// public void test6_7_8s24() throws Exception { // complex isn't declared as a typedef
|
||||
// try {
|
||||
// super.test6_7_8s24();
|
||||
// fail();
|
||||
// } catch(AssertionFailedError _) { }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public void test6_7_8s34() throws Exception { // div_t isn't declared as a typedef
|
||||
// try {
|
||||
// super.test6_7_8s34();
|
||||
// fail();
|
||||
// } catch(AssertionFailedError _) { }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void test6_7_2_1s17() throws Exception { // what the heck is offsetof
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 IBM Corporation 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: IBM Corporation - initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.core.lrparser.tests;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
|
||||
import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.ImageLocationTests;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class LRImageLocationTests extends ImageLocationTests {
|
||||
|
||||
public static TestSuite suite() {
|
||||
return suite(LRImageLocationTests.class);
|
||||
}
|
||||
|
||||
public LRImageLocationTests() { }
|
||||
public LRImageLocationTests(String name) { super(name); }
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unused")
|
||||
protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions,
|
||||
boolean expectNoProblems, boolean parseComments) throws ParserException {
|
||||
ILanguage language = lang.isCPP() ? getCPPLanguage() : getC99Language();
|
||||
return ParseHelper.parse(code, language, expectNoProblems);
|
||||
}
|
||||
|
||||
protected ILanguage getC99Language() {
|
||||
return C99Language.getDefault();
|
||||
}
|
||||
|
||||
protected ILanguage getCPPLanguage() {
|
||||
return ISOCPPLanguage.getDefault();
|
||||
}
|
||||
|
||||
}
|
|
@ -47,37 +47,37 @@ public class LRKnRTests extends AST2KnRTests {
|
|||
}
|
||||
|
||||
// TODO: Failing tests, will get around to fixing these bugs
|
||||
|
||||
@Override
|
||||
public void testKRCProblem3() throws Exception {
|
||||
try {
|
||||
super.testKRCProblem3();
|
||||
fail();
|
||||
} catch(Throwable _) { }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testKRCProblem4() throws Exception {
|
||||
try {
|
||||
super.testKRCProblem4();
|
||||
fail();
|
||||
} catch(Throwable _) { }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testKRCProblem5() throws Exception {
|
||||
try {
|
||||
super.testKRCProblem5();
|
||||
fail();
|
||||
} catch(Throwable _) { }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testKRCProblem2() throws Exception {
|
||||
try {
|
||||
super.testKRCProblem2();
|
||||
fail();
|
||||
} catch(Throwable _) { }
|
||||
}
|
||||
//
|
||||
// @Override
|
||||
// public void testKRCProblem3() throws Exception {
|
||||
// try {
|
||||
// super.testKRCProblem3();
|
||||
// fail();
|
||||
// } catch(Throwable _) { }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void testKRCProblem4() throws Exception {
|
||||
// try {
|
||||
// super.testKRCProblem4();
|
||||
// fail();
|
||||
// } catch(Throwable _) { }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void testKRCProblem5() throws Exception {
|
||||
// try {
|
||||
// super.testKRCProblem5();
|
||||
// fail();
|
||||
// } catch(Throwable _) { }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void testKRCProblem2() throws Exception {
|
||||
// try {
|
||||
// super.testKRCProblem2();
|
||||
// fail();
|
||||
// } catch(Throwable _) { }
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 IBM Corporation 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:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.lrparser.tests;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
|
||||
import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.ASTNodeSelectorTest;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class LRNodeSelectorTest extends ASTNodeSelectorTest {
|
||||
|
||||
public static TestSuite suite() {
|
||||
return suite(LRNodeSelectorTest.class);
|
||||
}
|
||||
|
||||
public LRNodeSelectorTest() {}
|
||||
public LRNodeSelectorTest(String name) { super(name); }
|
||||
|
||||
|
||||
@Override
|
||||
protected IASTTranslationUnit parse( String code, ParserLanguage lang, @SuppressWarnings("unused") boolean useGNUExtensions, boolean expectNoProblems, @SuppressWarnings("unused") boolean parseComments) throws ParserException {
|
||||
ILanguage language = lang.isCPP() ? getCPPLanguage() : getC99Language();
|
||||
return ParseHelper.parse(code, language, expectNoProblems);
|
||||
}
|
||||
|
||||
protected ILanguage getC99Language() {
|
||||
return C99Language.getDefault();
|
||||
}
|
||||
|
||||
protected ILanguage getCPPLanguage() {
|
||||
return ISOCPPLanguage.getDefault();
|
||||
}
|
||||
|
||||
}
|
|
@ -29,33 +29,33 @@ public class LRParserTestSuite extends TestSuite {
|
|||
public static Test suite() {
|
||||
return new TestSuite() {{
|
||||
|
||||
addTestSuite(LRTests.class); // has some tests that do fail
|
||||
|
||||
addTestSuite(LRCSpecTests.class); // a couple of failures
|
||||
addTestSuite(LRKnRTests.class); // mostly fail due to ambiguities
|
||||
|
||||
// The majority of the content assist test are in the ui tests plugin
|
||||
addTestSuite(LRCommentTests.class);
|
||||
addTestSuite(LRCompleteParser2Tests.class);
|
||||
addTestSuite(LRCompletionBasicTest.class);
|
||||
addTestSuite(LRCompletionParseTest.class);
|
||||
// this one still has a lot of failing tests though
|
||||
addTestSuite(LRSelectionParseTest.class);
|
||||
|
||||
addTestSuite(LRDOMLocationInclusionTests.class);
|
||||
addTestSuite(LRDOMLocationTests.class);
|
||||
addTestSuite(LRDOMLocationMacroTests.class);
|
||||
addTestSuite(LRDOMPreprocessorInformationTest.class);
|
||||
addTestSuite(LRCommentTests.class);
|
||||
addTestSuite(LRDigraphTrigraphTests.class);
|
||||
addTestSuite(LRGCCTests.class);
|
||||
addTestSuite(LRUtilOldTests.class);
|
||||
addTestSuite(LRUtilTests.class);
|
||||
addTestSuite(LRCompleteParser2Tests.class);
|
||||
addTestSuite(LRTaskParserTest.class);
|
||||
|
||||
addTestSuite(LRCPPSpecFailingTest.class);
|
||||
addTestSuite(LRCPPSpecTest.class);
|
||||
addTestSuite(LRCPPTests.class);
|
||||
addTestSuite(LRCSpecFailingTest.class);
|
||||
addTestSuite(LRCSpecTests.class); // a couple of failures
|
||||
addTestSuite(LRDigraphTrigraphTests.class);
|
||||
addTestSuite(LRDOMLocationInclusionTests.class);
|
||||
addTestSuite(LRDOMLocationMacroTests.class);
|
||||
addTestSuite(LRDOMLocationTests.class);
|
||||
addTestSuite(LRDOMPreprocessorInformationTest.class);
|
||||
addTestSuite(LRGCCTests.class);
|
||||
addTestSuite(LRImageLocationTests.class);
|
||||
addTestSuite(LRKnRTests.class); // mostly fail due to ambiguities
|
||||
addTestSuite(LRNodeSelectorTest.class);
|
||||
addTestSuite(LRQuickParser2Tests.class);
|
||||
addTestSuite(LRSelectionParseTest.class); // this one still has a lot of failing tests though
|
||||
addTestSuite(LRSemanticsTests.class);
|
||||
addTestSuite(LRTaskParserTest.class);
|
||||
addTestSuite(LRTemplateTests.class);
|
||||
|
||||
addTestSuite(LRTests.class); // has some tests that do fail
|
||||
addTestSuite(LRUtilOldTests.class);
|
||||
addTestSuite(LRUtilTests.class);
|
||||
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 IBM Corporation 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: IBM Corporation - initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.core.lrparser.tests;
|
||||
|
||||
import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
|
||||
import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.QuickParser2Tests;
|
||||
|
||||
public class LRQuickParser2Tests extends QuickParser2Tests {
|
||||
|
||||
public LRQuickParser2Tests() {}
|
||||
public LRQuickParser2Tests(String name) { super(name); }
|
||||
|
||||
|
||||
@Override
|
||||
protected void parse(String code, boolean expectedToPass,
|
||||
ParserLanguage lang, @SuppressWarnings("unused") boolean gcc) throws Exception {
|
||||
ILanguage language = lang.isCPP() ? getCPPLanguage() : getC99Language();
|
||||
ParseHelper.parse(code, language, expectedToPass);
|
||||
}
|
||||
|
||||
|
||||
protected ILanguage getC99Language() {
|
||||
return C99Language.getDefault();
|
||||
}
|
||||
|
||||
protected ILanguage getCPPLanguage() {
|
||||
return ISOCPPLanguage.getDefault();
|
||||
}
|
||||
|
||||
}
|
|
@ -10,15 +10,20 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.lrparser.tests;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
|
||||
import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
|
@ -26,6 +31,7 @@ import org.eclipse.cdt.core.parser.tests.ast2.AST2SelectionParseTest;
|
|||
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class LRSelectionParseTest extends AST2SelectionParseTest {
|
||||
|
@ -86,77 +92,77 @@ public class LRSelectionParseTest extends AST2SelectionParseTest {
|
|||
}
|
||||
|
||||
|
||||
// public void testBug193185_IncludeNext() throws Exception
|
||||
// {
|
||||
// String baseFile = "int zero; \n#include \"foo.h\""; //$NON-NLS-1$
|
||||
// String i1Next = "int one; \n#include_next <foo.h>"; //$NON-NLS-1$
|
||||
// String i2Next = "int two; \n#include_next \"foo.h\""; //$NON-NLS-1$
|
||||
// String i3Next = "int three; \n"; //$NON-NLS-1$
|
||||
//
|
||||
//
|
||||
// IFile base = importFile( "base.c", baseFile ); //$NON-NLS-1$
|
||||
// importFile( "foo.h", i1Next ); //$NON-NLS-1$
|
||||
// IFolder twof = importFolder("two"); //$NON-NLS-1$
|
||||
// IFolder threef = importFolder("three"); //$NON-NLS-1$
|
||||
// importFile( "two/foo.h", i2Next ); //$NON-NLS-1$
|
||||
// importFile( "three/foo.h", i3Next ); //$NON-NLS-1$
|
||||
//
|
||||
// String[] path = new String[] {
|
||||
// twof.getRawLocation().toOSString(),
|
||||
// threef.getRawLocation().toOSString()
|
||||
// };
|
||||
//
|
||||
// IScannerInfo scannerInfo = new ExtendedScannerInfo( Collections.EMPTY_MAP, path, new String[0], path );
|
||||
//
|
||||
// IASTTranslationUnit tu = parse(base, ParserLanguage.C, scannerInfo, false, true);
|
||||
//
|
||||
// IASTDeclaration[] decls = tu.getDeclarations();
|
||||
// assertEquals(4, decls.length);
|
||||
//
|
||||
// IASTSimpleDeclaration declaration = (IASTSimpleDeclaration)decls[0];
|
||||
// assertEquals("zero", declaration.getDeclarators()[0].getName().toString()); //$NON-NLS-1$
|
||||
//
|
||||
// declaration = (IASTSimpleDeclaration)decls[1];
|
||||
// assertEquals("one", declaration.getDeclarators()[0].getName().toString()); //$NON-NLS-1$
|
||||
//
|
||||
// declaration = (IASTSimpleDeclaration)decls[2];
|
||||
// assertEquals("two", declaration.getDeclarators()[0].getName().toString()); //$NON-NLS-1$
|
||||
//
|
||||
// declaration = (IASTSimpleDeclaration)decls[3];
|
||||
// assertEquals("three", declaration.getDeclarators()[0].getName().toString()); //$NON-NLS-1$
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public void testBug193366() throws Exception
|
||||
// {
|
||||
// String baseFile =
|
||||
// "#define FOOH <foo.h> \n" + //$NON-NLS-1$
|
||||
// "#define bar blahblahblah \n" + //$NON-NLS-1$
|
||||
// "#include FOOH \n" + //$NON-NLS-1$
|
||||
// "#include <bar.h> \n"; //$NON-NLS-1$
|
||||
//
|
||||
// String fooFile = "int x; \n"; //$NON-NLS-1$
|
||||
// String barFile = "int y; \n"; //$NON-NLS-1$
|
||||
//
|
||||
//
|
||||
// IFile base = importFile( "base.c", baseFile ); //$NON-NLS-1$
|
||||
// IFolder include = importFolder("inc"); //$NON-NLS-1$
|
||||
// importFile( "inc/foo.h", fooFile ); //$NON-NLS-1$
|
||||
// importFile( "inc/bar.h", barFile ); //$NON-NLS-1$
|
||||
//
|
||||
// String[] path = new String[] { include.getRawLocation().toOSString() };
|
||||
// IScannerInfo scannerInfo = new ExtendedScannerInfo( Collections.EMPTY_MAP, path, new String[0], path );
|
||||
//
|
||||
// IASTTranslationUnit tu = parse(base, ParserLanguage.C, scannerInfo, false, true);
|
||||
//
|
||||
// IASTDeclaration[] decls = tu.getDeclarations();
|
||||
// assertEquals(2, decls.length);
|
||||
//
|
||||
// IASTSimpleDeclaration declaration = (IASTSimpleDeclaration)decls[0];
|
||||
// assertEquals("x", declaration.getDeclarators()[0].getName().toString()); //$NON-NLS-1$
|
||||
//
|
||||
// declaration = (IASTSimpleDeclaration)decls[1];
|
||||
// assertEquals("y", declaration.getDeclarators()[0].getName().toString()); //$NON-NLS-1$
|
||||
// }
|
||||
public void testBug193185_IncludeNext() throws Exception
|
||||
{
|
||||
String baseFile = "int zero; \n#include \"foo.h\""; //$NON-NLS-1$
|
||||
String i1Next = "int one; \n#include_next <foo.h>"; //$NON-NLS-1$
|
||||
String i2Next = "int two; \n#include_next \"foo.h\""; //$NON-NLS-1$
|
||||
String i3Next = "int three; \n"; //$NON-NLS-1$
|
||||
|
||||
|
||||
IFile base = importFile( "base.c", baseFile ); //$NON-NLS-1$
|
||||
importFile( "foo.h", i1Next ); //$NON-NLS-1$
|
||||
IFolder twof = importFolder("two"); //$NON-NLS-1$
|
||||
IFolder threef = importFolder("three"); //$NON-NLS-1$
|
||||
importFile( "two/foo.h", i2Next ); //$NON-NLS-1$
|
||||
importFile( "three/foo.h", i3Next ); //$NON-NLS-1$
|
||||
|
||||
String[] path = new String[] {
|
||||
twof.getRawLocation().toOSString(),
|
||||
threef.getRawLocation().toOSString()
|
||||
};
|
||||
|
||||
IScannerInfo scannerInfo = new ExtendedScannerInfo( Collections.EMPTY_MAP, path, new String[0], path );
|
||||
|
||||
IASTTranslationUnit tu = parse(base, ParserLanguage.C, scannerInfo, false, true);
|
||||
|
||||
IASTDeclaration[] decls = tu.getDeclarations();
|
||||
assertEquals(4, decls.length);
|
||||
|
||||
IASTSimpleDeclaration declaration = (IASTSimpleDeclaration)decls[0];
|
||||
assertEquals("zero", declaration.getDeclarators()[0].getName().toString()); //$NON-NLS-1$
|
||||
|
||||
declaration = (IASTSimpleDeclaration)decls[1];
|
||||
assertEquals("one", declaration.getDeclarators()[0].getName().toString()); //$NON-NLS-1$
|
||||
|
||||
declaration = (IASTSimpleDeclaration)decls[2];
|
||||
assertEquals("two", declaration.getDeclarators()[0].getName().toString()); //$NON-NLS-1$
|
||||
|
||||
declaration = (IASTSimpleDeclaration)decls[3];
|
||||
assertEquals("three", declaration.getDeclarators()[0].getName().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
public void testBug193366() throws Exception
|
||||
{
|
||||
String baseFile =
|
||||
"#define FOOH <foo.h> \n" + //$NON-NLS-1$
|
||||
"#define bar blahblahblah \n" + //$NON-NLS-1$
|
||||
"#include FOOH \n" + //$NON-NLS-1$
|
||||
"#include <bar.h> \n"; //$NON-NLS-1$
|
||||
|
||||
String fooFile = "int x; \n"; //$NON-NLS-1$
|
||||
String barFile = "int y; \n"; //$NON-NLS-1$
|
||||
|
||||
|
||||
IFile base = importFile( "base.c", baseFile ); //$NON-NLS-1$
|
||||
IFolder include = importFolder("inc"); //$NON-NLS-1$
|
||||
importFile( "inc/foo.h", fooFile ); //$NON-NLS-1$
|
||||
importFile( "inc/bar.h", barFile ); //$NON-NLS-1$
|
||||
|
||||
String[] path = new String[] { include.getRawLocation().toOSString() };
|
||||
IScannerInfo scannerInfo = new ExtendedScannerInfo( Collections.EMPTY_MAP, path, new String[0], path );
|
||||
|
||||
IASTTranslationUnit tu = parse(base, ParserLanguage.C, scannerInfo, false, true);
|
||||
|
||||
IASTDeclaration[] decls = tu.getDeclarations();
|
||||
assertEquals(2, decls.length);
|
||||
|
||||
IASTSimpleDeclaration declaration = (IASTSimpleDeclaration)decls[0];
|
||||
assertEquals("x", declaration.getDeclarators()[0].getName().toString()); //$NON-NLS-1$
|
||||
|
||||
declaration = (IASTSimpleDeclaration)decls[1];
|
||||
assertEquals("y", declaration.getDeclarators()[0].getName().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 IBM Corporation 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: IBM Corporation - initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.core.lrparser.tests;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
|
||||
import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.SemanticsTests;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class LRSemanticsTests extends SemanticsTests {
|
||||
|
||||
public static TestSuite suite() {
|
||||
return suite(LRSemanticsTests.class);
|
||||
}
|
||||
|
||||
public LRSemanticsTests() { }
|
||||
public LRSemanticsTests(String name) { super(name); }
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Override
|
||||
protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions,
|
||||
boolean expectNoProblems, boolean parseComments) throws ParserException {
|
||||
ILanguage language = lang.isCPP() ? getCPPLanguage() : getC99Language();
|
||||
return ParseHelper.parse(code, language, expectNoProblems);
|
||||
}
|
||||
|
||||
protected ILanguage getC99Language() {
|
||||
return C99Language.getDefault();
|
||||
}
|
||||
|
||||
protected ILanguage getCPPLanguage() {
|
||||
return ISOCPPLanguage.getDefault();
|
||||
}
|
||||
}
|
|
@ -1,3 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 IBM Corporation 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:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.lrparser.tests;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
|
|
@ -13,12 +13,12 @@ package org.eclipse.cdt.core.lrparser.tests;
|
|||
import junit.framework.AssertionFailedError;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
|
@ -37,7 +37,7 @@ public class ParseHelper {
|
|||
|
||||
static int testsRun = 0;
|
||||
|
||||
private static class NameResolver extends CPPASTVisitor {
|
||||
private static class NameResolver extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue