Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests')
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCPPSpecTest.java88
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCPPTests.java137
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCSpecTests.java102
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCommentTests.java78
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCompleteParser2Tests.java151
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCompletionBasicTest.java102
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCompletionParseTest.java415
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMLocationInclusionTests.java72
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMLocationMacroTests.java65
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMLocationTests.java91
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMPreprocessorInformationTest.java47
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDigraphTrigraphTests.java186
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRGCCCompleteParseExtensionsTest.java51
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRGCCTests.java51
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRImageLocationTests.java54
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRKnRTests.java84
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRNodeSelectorTest.java62
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRParserTestSuite.java55
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRQuickParser2Tests.java181
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRSelectionParseTest.java96
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRSemanticsTests.java53
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRTaskParserTest.java52
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRTemplateTests.java51
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRTests.java168
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRUtilOldTests.java56
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRUtilTests.java55
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/ParseHelper.java215
27 files changed, 2818 insertions, 0 deletions
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCPPSpecTest.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCPPSpecTest.java
new file mode 100644
index 00000000000..cf63addaa62
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCPPSpecTest.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.AST2CPPSpecTest;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+@SuppressWarnings("restriction")
+public class LRCPPSpecTest extends AST2CPPSpecTest {
+
+ public static TestSuite suite() {
+ return suite(LRCPPSpecTest.class);
+ }
+
+ public LRCPPSpecTest() { }
+ public LRCPPSpecTest(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 parseWithErrors(String code, ParserLanguage lang) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setCheckBindings(false);
+ options.setCheckPreprocessorProblems(false);
+ options.setCheckSyntaxProblems(false);
+ return ParseHelper.parse(code, language, options);
+ }
+
+ @Override
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean checkBindings, int expectedProblemBindings ) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setCheckBindings(checkBindings);
+ options.setExpectedProblemBindings(expectedProblemBindings);
+ return ParseHelper.parse(code, language, options);
+ }
+
+ @Override
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, @SuppressWarnings("unused") boolean useGNUExtensions, boolean expectNoProblems, boolean skipTrivialInitializers) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setCheckSyntaxProblems(expectNoProblems);
+ options.setCheckPreprocessorProblems(expectNoProblems);
+ options.setSkipTrivialInitializers(skipTrivialInitializers);
+ return ParseHelper.parse(code, language, options);
+ }
+
+ @Override
+ protected IASTTranslationUnit parse(String code, ParserLanguage lang, String[] problems) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setProblems(problems);
+ return ParseHelper.parse(code, language, options);
+ }
+
+
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCPPTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCPPTests.java
new file mode 100644
index 00000000000..e5bec7fb1a3
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCPPTests.java
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.AST2CPPTests;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+@SuppressWarnings("restriction")
+public class LRCPPTests extends AST2CPPTests {
+
+
+ public static TestSuite suite() {
+ return suite(LRCPPTests.class);
+ }
+
+ public LRCPPTests() {
+
+ }
+
+ public LRCPPTests(String name) {
+ super(name);
+ }
+
+
+ @Override
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, @SuppressWarnings("unused") boolean useGNUExtensions, boolean expectNoProblems, boolean skipTrivialInitializers) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setCheckSyntaxProblems(expectNoProblems);
+ options.setCheckPreprocessorProblems(expectNoProblems);
+ options.setSkipTrivialInitializers(skipTrivialInitializers);
+ return ParseHelper.parse(code, language, options);
+ }
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+
+ @Override
+ public void testBug98704() throws Exception {
+ // this one gets stuck in infinite loop
+
+ }
+
+// @Override
+// public void testBug87424() throws Exception { // gcc extension
+// try {
+// super.testBug87424();
+// fail();
+// } catch(AssertionFailedError _) {
+// }
+// }
+//
+//
+// @Override
+// public void testBug95757() throws Exception { // gcc extension
+// try {
+// super.testBug95757();
+// fail();
+// } catch(AssertionFailedError _) {
+// }
+// }
+//
+// @Override
+// public void testBug108202() throws Exception { // gcc attributes not supported
+// try {
+// super.testBug108202();
+// fail();
+// } catch(AssertionFailedError _) {
+// }
+// }
+//
+//
+// @Override
+// public void testBug195701() throws Exception { // gcc attributes not supported
+// try {
+// super.testBug195701();
+// fail();
+// } catch(AssertionFailedError _) {
+// }
+// }
+//
+// @Override
+// public void testBug179712() throws Exception { // gcc attributes not supported
+// try {
+// super.testBug179712();
+// fail();
+// } catch(AssertionFailedError _) {
+// }
+// }
+//
+// @Override
+// public void testBug240567() throws Exception { // gcc
+// try {
+// super.testBug240567();
+// fail();
+// } catch(AssertionFailedError _) {
+// }
+// }
+//
+// @Override
+// public void testLiteralsViaOverloads_225534() throws Exception { // gcc, I think
+// try {
+// super.testLiteralsViaOverloads_225534();
+// fail();
+// } catch(AssertionFailedError _) {
+// }
+// }
+
+
+ @Override
+ public void testNestedTemplateIDAmbiguity_259501() throws Exception {
+ // this test hangs, not sure I'll ever fix it
+ }
+
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCSpecTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCSpecTests.java
new file mode 100644
index 00000000000..5cb7b86b629
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCSpecTests.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+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", "nls"})
+public class LRCSpecTests extends AST2CSpecTest {
+
+ public static TestSuite suite() {
+ return suite(LRCSpecTests.class);
+ }
+
+ public LRCSpecTests() { }
+ public LRCSpecTests(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();
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setCheckSyntaxProblems(true);
+ options.setCheckPreprocessorProblems(true);
+ options.setCheckBindings(checkBindings);
+ options.setExpectedProblemBindings(expectedProblemBindings);
+ return ParseHelper.parse(code, language, options);
+ }
+
+ @Override
+ protected IASTTranslationUnit parse(String code, ParserLanguage lang, String[] problems) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setProblems(problems);
+ options.setCheckSyntaxProblems(true);
+ options.setCheckPreprocessorProblems(true);
+ return ParseHelper.parse(code, language, options);
+ }
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+
+ @Override // example code needs to be nested in a function body
+ public void test5_1_2_3s15() throws Exception {
+ 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);
+ }
+
+
+
+// @Override
+// public void test6_7_2_1s17() throws Exception { // what the heck is offsetof
+// try {
+// super.test6_7_2_1s17();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+
+
+ public void testBug276360() throws Exception {
+ String code =
+ "int foo(int*[]) {} ";
+
+ parseCandCPP(code, false, 0);
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCommentTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCommentTests.java
new file mode 100644
index 00000000000..b9566ea3e80
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCommentTests.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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.IASTComment;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.CommentTests;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+@SuppressWarnings("restriction")
+public class LRCommentTests extends CommentTests {
+
+ public static TestSuite suite() {
+ return suite(LRCommentTests.class);
+ }
+
+
+ @Override
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ return ParseHelper.parse(code, language, expectNoProblems);
+ }
+
+
+ @Override
+ protected IASTTranslationUnit parse(String code, ParserLanguage lang,
+ boolean useGNUExtensions, boolean expectNoProblems,
+ boolean skipTrivialInitializers) throws ParserException {
+
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setCheckSyntaxProblems(expectNoProblems);
+ options.setCheckPreprocessorProblems(expectNoProblems);
+ options.setSkipTrivialInitializers(skipTrivialInitializers);
+ return ParseHelper.commentParse(code, language);
+ }
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+
+ @SuppressWarnings("nls")
+ public void testBug191266() throws Exception {
+ String code =
+ "#define MACRO 1000000000000 \n" +
+ "int x = MACRO; \n" +
+ "//comment\n";
+
+ IASTTranslationUnit tu = parse(code, ParserLanguage.C, false, false, true);
+
+ IASTComment[] comments = tu.getComments();
+ assertEquals(1, comments.length);
+
+ IASTFileLocation location = comments[0].getFileLocation();
+ assertEquals(code.indexOf("//"), location.getNodeOffset());
+ assertEquals("//comment".length(), location.getNodeLength());
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCompleteParser2Tests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCompleteParser2Tests.java
new file mode 100644
index 00000000000..e7059e9f854
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCompleteParser2Tests.java
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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;
+import junit.framework.TestSuite;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.CompleteParser2Tests;
+
+public class LRCompleteParser2Tests extends CompleteParser2Tests {
+
+ public static TestSuite suite() {
+ return suite(LRCompleteParser2Tests.class);
+ }
+
+ public LRCompleteParser2Tests() {
+ }
+
+ public LRCompleteParser2Tests(String name) {
+ super(name);
+ }
+
+ @Override
+ protected IASTTranslationUnit parse(String code, boolean expectedToPass,
+ ParserLanguage lang, boolean gcc) throws Exception {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ return ParseHelper.parse(code, language, expectedToPass);
+ }
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+
+ // Tests that are failing at this point
+
+// @Override
+// public void testBug39676_tough() { // is this C99?
+// try {
+// super.testBug39676_tough();
+// } catch(AssertionFailedError _) {
+// return;
+// } catch(Exception _) {
+// return;
+// }
+// fail();
+// }
+
+// public void testPredefinedSymbol_bug70928_infinite_loop_test1() throws Exception { // gcc extension
+// try {
+// super.testPredefinedSymbol_bug70928_infinite_loop_test1();
+// fail();
+// } catch(AssertionError _) { }
+// }
+//
+// public void testPredefinedSymbol_bug70928_infinite_loop_test2() throws Exception { // gcc extension
+// try {
+// super.testPredefinedSymbol_bug70928_infinite_loop_test2();
+// fail();
+// } catch(AssertionError _) { }
+// }
+
+
+// @Override
+// public void testBug102376() throws Exception { // gcc extension
+// try {
+// super.testBug102376();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+
+// @Override
+// public void test158192_declspec_in_declarator() throws Exception {
+// try {
+// super.test158192_declspec_in_declarator();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+//
+// @Override
+// public void test158192_declspec_on_class() throws Exception {
+// try {
+// super.test158192_declspec_on_class();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+//
+// @Override
+// public void test158192_declspec_on_variable() throws Exception {
+// try {
+// super.test158192_declspec_on_variable();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+//
+// @Override
+// public void testPredefinedSymbol_bug70928() throws Exception {
+// try {
+// super.testPredefinedSymbol_bug70928();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+
+ @Override
+ public void testBug64010() throws Exception { // 10000 else-ifs, busts LPG's stack
+ try {
+ //super.testBug64010();
+ //fail();
+ } catch(AssertionFailedError _) { }
+ }
+
+//
+// @Override
+// public void testGNUASMExtension() throws Exception {
+// try {
+// super.testGNUASMExtension();
+// fail();
+// } catch(AssertionFailedError _) {
+// } catch(AssertionError _) {
+// }
+// }
+//
+// @Override
+// public void testBug39551B() throws Exception {
+// try {
+// super.testBug39551B();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+//
+//
+//
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCompletionBasicTest.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCompletionBasicTest.java
new file mode 100644
index 00000000000..07c3a841b46
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCompletionBasicTest.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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.IASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IFunction;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.prefix.BasicCompletionTest;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+@SuppressWarnings({"restriction", "nls"})
+public class LRCompletionBasicTest extends BasicCompletionTest {
+
+ public static TestSuite suite() {
+ return new TestSuite(LRCompletionBasicTest.class);
+ }
+
+ public LRCompletionBasicTest() { }
+
+
+ @Override
+ @SuppressWarnings("unused")
+ protected IASTCompletionNode getCompletionNode(String code,
+ ParserLanguage lang, boolean useGNUExtensions)
+ throws ParserException {
+
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ return ParseHelper.getCompletionNode(code, language);
+ }
+
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+
+ @Override
+ public void testFunction() throws Exception {
+ String code =
+ "void func(int x) { }" +
+ "void func2() { fu";
+
+ // C++
+ IASTCompletionNode node = getGPPCompletionNode(code);
+ IBinding[] bindings = LRCompletionParseTest.getBindings(node.getNames());
+
+ assertEquals(2, bindings.length);
+ assertEquals("func", ((IFunction)bindings[0]).getName());
+ assertEquals("func2", ((IFunction)bindings[1]).getName());
+
+ // C
+ node = getGCCCompletionNode(code);
+ bindings = LRCompletionParseTest.getBindings(node.getNames());
+
+ assertEquals(2, bindings.length);
+ assertEquals("func", ((IFunction)bindings[0]).getName());
+ assertEquals("func2", ((IFunction)bindings[1]).getName());
+ }
+
+
+ @Override
+ public void testTypedef() throws Exception {
+ String code =
+ "typedef int blah;" +
+ "bl";
+
+ // C++
+ IASTCompletionNode node = getGPPCompletionNode(code);
+ IBinding[] bindings = LRCompletionParseTest.getBindings(node.getNames());
+
+ assertEquals(1, bindings.length);
+ assertEquals("blah", ((ITypedef)bindings[0]).getName());
+
+ // C
+ node = getGCCCompletionNode(code);
+ bindings = LRCompletionParseTest.getBindings(node.getNames());
+
+ assertEquals(1, bindings.length);
+ assertEquals("blah", ((ITypedef)bindings[0]).getName());
+ }
+
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCompletionParseTest.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCompletionParseTest.java
new file mode 100644
index 00000000000..373d3c2a213
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCompletionParseTest.java
@@ -0,0 +1,415 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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 java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IEnumerator;
+import org.eclipse.cdt.core.dom.ast.IField;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.IVariable;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GCCLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+
+
+/**
+ * Reuse the completion parse tests from the old parser for now.
+ */
+@SuppressWarnings("nls")
+public class LRCompletionParseTest extends TestCase {
+
+ public static TestSuite suite() {
+ return new TestSuite(LRCompletionParseTest.class);
+ }
+
+
+ public LRCompletionParseTest() { }
+ public LRCompletionParseTest(String name) { super(name); }
+
+
+ protected IASTCompletionNode parse(String code, int offset) throws Exception {
+ return ParseHelper.getCompletionNode(code, getCLanguage(), offset);
+ }
+
+
+ private static final Comparator<IBinding> BINDING_COMPARATOR = new Comparator<IBinding>() {
+ public int compare(IBinding b1, IBinding b2) {
+ return b1.getName().compareTo(b2.getName());
+ }
+ };
+
+
+ public static IBinding[] getBindings(IASTName[] names) {
+ List<IBinding> bindings = new ArrayList<IBinding>();
+
+ for(IASTName name : names) {
+ if(name.getTranslationUnit() == null)
+ continue;
+
+ for(IBinding binding : name.getCompletionContext().findBindings(name, true))
+ bindings.add(binding);
+ }
+
+ Collections.sort(bindings, BINDING_COMPARATOR);
+ return bindings.toArray(new IBinding[bindings.size()]);
+ }
+
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+
+ // First steal tests from CompletionParseTest
+
+
+ public void testCompletionStructField() throws Exception {
+ String code =
+ "int aVar; " +
+ "struct D{ " +
+ " int aField1; " +
+ " int aField2; " +
+ "}; " +
+ "void foo(){" +
+ " struct D d; " +
+ " d.a " +
+ "}\n";
+
+ int index = code.indexOf( "d.a" );
+
+ IASTCompletionNode node = parse( code, index + 3 );
+ assertNotNull( node );
+
+ String prefix = node.getPrefix();
+ assertNotNull( prefix );
+ assertEquals( prefix, "a" );
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(2, bindings.length);
+ assertEquals("aField1", ((IField)bindings[0]).getName());
+ assertEquals("aField2", ((IField)bindings[1]).getName());
+ }
+
+ public void testCompletionStructFieldPointer() throws Exception {
+ String code =
+ "struct Cube { " +
+ " int nLen; " +
+ " int nWidth; " +
+ " int nHeight; " +
+ "}; " +
+ "int volume( struct Cube * pCube ) { " +
+ " pCube->SP ";
+
+ IASTCompletionNode node = parse( code, code.indexOf("SP"));
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(3, bindings.length);
+ assertEquals("nHeight", ((IField)bindings[0]).getName());
+ assertEquals("nLen", ((IField)bindings[1]).getName());
+ assertEquals("nWidth", ((IField)bindings[2]).getName());
+ }
+
+
+ public void testCompletionParametersAsLocalVariables() throws Exception{
+ String code =
+ "int foo( int aParameter ){" +
+ " int aLocal;" +
+ " if( aLocal != 0 ){" +
+ " int aBlockLocal;" +
+ " a \n";
+
+ int index = code.indexOf( " a " );
+
+ IASTCompletionNode node = parse( code, index + 2 );
+ assertNotNull( node );
+
+ assertEquals("a", node.getPrefix()); //$NON-NLS-1$
+
+ IASTName[] names = node.getNames();
+ assertEquals(2, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(3, bindings.length);
+ assertEquals("aBlockLocal", ((IVariable)bindings[0]).getName());
+ assertEquals("aLocal", ((IVariable)bindings[1]).getName());
+ assertEquals("aParameter", ((IVariable)bindings[2]).getName());
+ }
+
+
+ public void testCompletionTypedef() throws Exception {
+ String code =
+ "typedef int Int; " +
+ "InSP";
+
+ int index = code.indexOf( "SP" );
+
+ IASTCompletionNode node = parse( code, index );
+ assertNotNull(node);
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ assertEquals("In", node.getPrefix());
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(1, bindings.length);
+ assertEquals("Int", ((ITypedef)bindings[0]).getName());
+ }
+
+ public void testCompletion() throws Exception {
+ String code =
+ "#define GL_T 0x2001\n" +
+ "#define GL_TRUE 0x1\n" +
+ "typedef unsigned char GLboolean;\n" +
+ "static GLboolean should_rotate = GL_T";
+
+ int index = code.indexOf("= GL_T");
+
+ IASTCompletionNode node = parse( code, index + 6);
+ assertNotNull(node);
+
+ assertEquals("GL_T", node.getPrefix()); //$NON-NLS-1$
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+ }
+
+ public void testCompletionInTypeDef() throws Exception {
+ String code =
+ "struct A { int name; }; \n" +
+ "typedef struct A * PA; \n" +
+ "int main() { \n" +
+ " PA a; \n" +
+ " a->SP \n" +
+ "} \n";
+
+ int index = code.indexOf("SP"); //$NON-NLS-1$
+
+ IASTCompletionNode node = parse( code, index );
+ assertNotNull( node );
+
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(1, bindings.length);
+ assertEquals("name", ((IField)bindings[0]).getName());
+ }
+
+
+ public void _testCompletionFunctionCall() throws Exception {
+ String code =
+ "struct A { \n" +
+ " int f2; \n" +
+ " int f4; \n" +
+ "}; \n" +
+ "const A * foo(){} \n" +
+ "void main( ) \n" +
+ "{ \n" +
+ " foo()->SP \n";
+
+ int index = code.indexOf( "SP" );
+
+ IASTCompletionNode node = parse( code, index );
+ assertNotNull( node );
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(2, bindings.length);
+ assertEquals("f2", ((IField)bindings[0]).getName());
+ assertEquals("f4", ((IField)bindings[1]).getName());
+ }
+
+
+ public void _testCompletionSizeof() throws Exception {
+ String code =
+ "int f() {\n" +
+ "short blah;\n" +
+ "int x = sizeof(bl";
+
+ int index = code.indexOf( "of(bl" );
+
+ IASTCompletionNode node = parse( code, index + 5);
+ assertNotNull( node );
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(1, bindings.length);
+ assertEquals("blah", ((IVariable)bindings[0]).getName());
+ }
+
+
+ public void testCompletionForLoop() throws Exception {
+ String code =
+ "int f() {\n" +
+ " int biSizeImage = 5;\n" +
+ "for (int i = 0; i < bi ";
+
+ int index = code.indexOf("< bi");
+
+ IASTCompletionNode node = parse( code, index + 4);
+ assertNotNull( node );
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(1, bindings.length);
+ assertEquals("biSizeImage", ((IVariable)bindings[0]).getName());
+ }
+
+
+
+ public void testCompletionStructPointer() throws Exception {
+ String code =
+ " struct Temp { char * total; };" +
+ " int f(struct Temp * t) {" +
+ " t->t[5] = t->";
+
+ int index = code.indexOf("= t->");
+
+ IASTCompletionNode node = parse( code, index + 5);
+ assertNotNull( node );
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(1, bindings.length);
+ assertEquals("total", ((IVariable)bindings[0]).getName());
+ }
+
+
+ public void testCompletionEnum() throws Exception {
+ String code =
+ "typedef int DWORD;\n" +
+ "typedef char BYTE;\n" +
+ "#define MAKEFOURCC(ch0, ch1, ch2, ch3) \\\n" +
+ "((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \\\n" +
+ "((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))\n" +
+ "enum e {\n" +
+ "blah1 = 5,\n" +
+ "blah2 = MAKEFOURCC('a', 'b', 'c', 'd'),\n" +
+ "blah3\n" +
+ "};\n" +
+ "e mye = bl\n";
+
+ int index = code.indexOf("= bl");
+
+ IASTCompletionNode node = parse( code, index + 4);
+ assertNotNull( node );
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(3, bindings.length);
+ assertEquals("blah1", ((IEnumerator)bindings[0]).getName());
+ assertEquals("blah2", ((IEnumerator)bindings[1]).getName());
+ assertEquals("blah3", ((IEnumerator)bindings[2]).getName());
+ }
+
+
+ public void testCompletionStructArray() throws Exception {
+ String code =
+ "struct packet { int a; int b; };\n" +
+ "struct packet buffer[5];\n" +
+ "int main(int argc, char **argv) {\n" +
+ " buffer[2].";
+
+ int index = code.indexOf("[2].");
+
+ IASTCompletionNode node = parse( code, index + 4);
+ assertNotNull( node );
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(2, bindings.length);
+ assertEquals("a", ((IField)bindings[0]).getName());
+ assertEquals("b", ((IField)bindings[1]).getName());
+ }
+
+
+ public void testCompletionPreprocessorDirective() throws Exception {
+ IASTCompletionNode node = parse("#", 1);
+ assertNotNull( node );
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ //assertEquals("#", node.getPrefix());
+ }
+
+ public void testCompletionPreprocessorMacro() throws Exception {
+ String code =
+ "#define AMACRO 99 \n" +
+ "int main() { \n" +
+ " int AVAR; \n" +
+ " int x = A \n";
+
+ int index = code.indexOf("= A");
+
+ IASTCompletionNode node = parse( code, index + 3);
+ assertNotNull( node );
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+ assertEquals("A", node.getPrefix());
+ }
+
+
+ public void testCompletionInsidePreprocessorDirective() throws Exception {
+ String code =
+ "#define MAC1 99 \n" +
+ "#define MAC2 99 \n" +
+ "#ifdef MA";
+
+ int index = code.length();
+
+ IASTCompletionNode node = parse( code, index );
+ assertNotNull( node );
+
+ assertEquals("MA", node.getPrefix());
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMLocationInclusionTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMLocationInclusionTests.java
new file mode 100644
index 00000000000..9ce5a543597
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMLocationInclusionTests.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+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.ParserUtil;
+import org.eclipse.cdt.core.parser.tests.ast2.DOMLocationInclusionTests;
+import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
+import org.eclipse.core.resources.IFile;
+
+@SuppressWarnings("restriction")
+public class LRDOMLocationInclusionTests extends DOMLocationInclusionTests {
+
+ public static TestSuite suite() {
+ return new TestSuite(LRDOMLocationInclusionTests.class);
+ }
+
+ public LRDOMLocationInclusionTests() {
+ }
+
+ public LRDOMLocationInclusionTests(String name, Class<Object> className) {
+ super(name, className);
+ }
+
+ public LRDOMLocationInclusionTests(String name) {
+ super(name);
+ }
+
+ @Override
+ protected IASTTranslationUnit parse(IFile code, IScannerInfo s)throws Exception {
+ // TODO: total freakin hack! the test suite needs to be refactored
+ ILanguage lang = code.getName().endsWith("cc") ? getCPPLanguage() : getCLanguage(); //$NON-NLS-1$
+
+ CodeReader codeReader = new CodeReader(code.getLocation().toOSString());
+ IASTTranslationUnit tu = lang.getASTTranslationUnit(codeReader, s, SavedCodeReaderFactory.getInstance(), null, ILanguage.OPTION_ADD_COMMENTS, ParserUtil.getParserLogService());
+
+ return tu;
+ }
+
+ @Override
+ protected IASTTranslationUnit parse(IFile code) throws Exception {
+
+ return parse(code, new ExtendedScannerInfo());
+ }
+
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMLocationMacroTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMLocationMacroTests.java
new file mode 100644
index 00000000000..ad7e88b7b62
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMLocationMacroTests.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.DOMLocationMacroTests;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+@SuppressWarnings("restriction")
+public class LRDOMLocationMacroTests extends DOMLocationMacroTests {
+
+ public static TestSuite suite() {
+ return suite(LRDOMLocationMacroTests.class);
+ }
+
+ public LRDOMLocationMacroTests() {}
+ public LRDOMLocationMacroTests(String name) { super(name); }
+
+
+ @Override
+ @SuppressWarnings("unused")
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options().setCheckSyntaxProblems(expectNoProblems).setCheckPreprocessorProblems(expectNoProblems);
+ return ParseHelper.parse(code, language, options);
+ }
+
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+
+ /**
+ * Tests GCC specific stuff, not applicable at this point
+ */
+
+// @Override
+// public void testStdioBug() throws ParserException {
+// try {
+// super.testStdioBug();
+// fail();
+// }
+// catch(Throwable e) { }
+// }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMLocationTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMLocationTests.java
new file mode 100644
index 00000000000..13badf509ce
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMLocationTests.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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;
+import junit.framework.TestSuite;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.DOMLocationTests;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+@SuppressWarnings("restriction")
+public class LRDOMLocationTests extends DOMLocationTests {
+
+ public static TestSuite suite() {
+ return suite(LRDOMLocationTests.class);
+ }
+
+ public LRDOMLocationTests() { }
+ public LRDOMLocationTests(String name) { super(name); }
+
+ @Override
+ @SuppressWarnings("unused")
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options().setCheckSyntaxProblems(expectNoProblems).setCheckPreprocessorProblems(expectNoProblems);
+ return ParseHelper.parse(code, language, options);
+ }
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+
+
+ // this one fails because the C99 parser does error recovery differently
+ @Override
+ public void test162180_1() throws Exception {
+ try {
+ super.test162180_1();
+ fail();
+ }
+ catch(AssertionFailedError e) {}
+
+ }
+//
+// @Override
+// public void test162180_3() throws Exception {
+// try {
+// super.test162180_3();
+// fail();
+// }
+// catch(AssertionFailedError e) {}
+// }
+//
+// @Override
+// public void testBug86698_2() throws Exception { // I don't think C++ supports nested functions
+// try {
+// super.testBug86698_2();
+// fail();
+// }
+// catch(AssertionFailedError e) {}
+// }
+//
+//
+// @Override
+// public void testBug120607() throws Exception { // #assert and #unassert are gcc extensions
+// try {
+// super.testBug120607();
+// fail();
+// }
+// catch(AssertionFailedError e) {}
+// }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMPreprocessorInformationTest.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMPreprocessorInformationTest.java
new file mode 100644
index 00000000000..412f16d768f
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMPreprocessorInformationTest.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 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.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.DOMPreprocessorInformationTest;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+@SuppressWarnings("restriction")
+public class LRDOMPreprocessorInformationTest extends DOMPreprocessorInformationTest {
+
+ public static TestSuite suite() {
+ return suite(LRDOMPreprocessorInformationTest.class);
+ }
+
+ @Override
+ @SuppressWarnings("unused")
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options().setCheckSyntaxProblems(expectNoProblems).setCheckPreprocessorProblems(expectNoProblems);
+ return ParseHelper.parse(code, language, options);
+ }
+
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDigraphTrigraphTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDigraphTrigraphTests.java
new file mode 100644
index 00000000000..cbd38557c79
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDigraphTrigraphTests.java
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
+import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
+import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GCCLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+
+
+/**
+ * TODO these tests can be moved into the core
+ */
+@SuppressWarnings("nls")
+public class LRDigraphTrigraphTests extends TestCase {
+
+ public static TestSuite suite() {
+ return new TestSuite(LRDigraphTrigraphTests.class);
+ }
+
+
+ public LRDigraphTrigraphTests() { }
+ public LRDigraphTrigraphTests(String name) { super(name); }
+
+
+ protected IASTTranslationUnit parse(String code) {
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setCheckSyntaxProblems(true);
+ options.setCheckPreprocessorProblems(true);
+ return ParseHelper.parse(code, getCLanguage(), options);
+ }
+
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+
+ public void testTrigraphSequences() {
+ String code =
+ "??=define SIZE ??/ \n" + // trigraph used as backslash to ignore newline
+ "99 \n" +
+ "int main(void)??< \n" +
+ " int arr??(SIZE??); \n" +
+ " arr??(4??) = '0' - (??-0 ??' 1 ??! 2); \n" +
+ " printf(\"%c??/n\", arr??(4??)); \n" +
+ "??> \n";
+
+ IASTTranslationUnit tu = parse(code);
+ assertNotNull(tu);
+
+ IASTPreprocessorStatement[] defines = tu.getAllPreprocessorStatements();
+ assertEquals(1, defines.length);
+ IASTPreprocessorMacroDefinition macro = (IASTPreprocessorMacroDefinition)defines[0];
+ assertEquals("SIZE", macro.getName().toString());
+ //assertEquals("99", macro.getExpansion());
+
+ IASTFunctionDefinition main = (IASTFunctionDefinition)tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) main.getBody();
+ IASTStatement[] statements = body.getStatements();
+ assertEquals(3, statements.length);
+
+ // int arr??(SIZE??);
+ IASTSimpleDeclaration arr = (IASTSimpleDeclaration)((IASTDeclarationStatement)statements[0]).getDeclaration();
+ IASTArrayDeclarator arr_decl = (IASTArrayDeclarator)arr.getDeclarators()[0];
+ IASTArrayModifier modifier = arr_decl.getArrayModifiers()[0];
+ IASTLiteralExpression lit = (IASTLiteralExpression)modifier.getConstantExpression();
+ assertEquals(IASTLiteralExpression.lk_integer_constant, lit.getKind());
+
+ // arr??(4??) = '0' - (??-0 ??' 1 ??! 2);
+ IASTBinaryExpression expr = (IASTBinaryExpression)((IASTExpressionStatement)statements[1]).getExpression();
+ assertEquals(IASTBinaryExpression.op_assign, expr.getOperator());
+ IASTArraySubscriptExpression arr_op = (IASTArraySubscriptExpression)expr.getOperand1();
+ assertEquals("4", ((IASTLiteralExpression)arr_op.getSubscriptExpression()).toString());
+ IASTBinaryExpression cond = (IASTBinaryExpression)((IASTUnaryExpression)((IASTBinaryExpression)expr.getOperand2()).getOperand2()).getOperand();
+ assertEquals(IASTBinaryExpression.op_binaryOr, cond.getOperator());
+ IASTBinaryExpression cond2 = (IASTBinaryExpression)cond.getOperand1();
+ assertEquals(IASTBinaryExpression.op_binaryXor, cond2.getOperator());
+ IASTUnaryExpression not = (IASTUnaryExpression)cond2.getOperand1();
+ assertEquals(IASTUnaryExpression.op_tilde, not.getOperator());
+
+ // printf(\"%c??/n\", arr??(4??));
+ IASTFunctionCallExpression expr2 = (IASTFunctionCallExpression)((IASTExpressionStatement)statements[2]).getExpression();
+ IASTExpressionList params = (IASTExpressionList) expr2.getParameterExpression();
+ IASTArraySubscriptExpression arr_op2 = (IASTArraySubscriptExpression)params.getExpressions()[1];
+ assertEquals("4", ((IASTLiteralExpression)arr_op2.getSubscriptExpression()).toString());
+ }
+
+
+ public void testTrigraphEscapeSequences() {
+ // a ??/ trigraph should act just like a backslash in a string literal
+ String code =
+ "int main(void)??< \n" +
+ " char str[] = \"??/\"??/n\"; \n" +
+ " char c = '??/u0000'; \n" +
+ "??> \n";
+
+ parse(code); // will throw an exception if there are parse errors
+ }
+
+
+ public void testDigraphSequences() {
+ String code =
+ "%:define join(a, b) a %:%: b \n" +
+ "int main() <% \n" +
+ " int arr<:5:>; \n" +
+ "%> \n";
+
+ IASTTranslationUnit tu = parse(code); // will throw an exception if there are parse errors
+
+ IASTFunctionDefinition main = (IASTFunctionDefinition)tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) main.getBody();
+ IASTStatement[] statements = body.getStatements();
+ assertEquals(1, statements.length);
+
+ IASTSimpleDeclaration arr = (IASTSimpleDeclaration)((IASTDeclarationStatement)statements[0]).getDeclaration();
+ IASTArrayDeclarator arr_decl = (IASTArrayDeclarator)arr.getDeclarators()[0];
+ IASTArrayModifier modifier = arr_decl.getArrayModifiers()[0];
+ IASTLiteralExpression lit = (IASTLiteralExpression)modifier.getConstantExpression();
+ assertEquals("5", lit.toString());
+
+ }
+
+
+
+ public void testTrigraphAndDigraphSequecesInPreprocessorDirectives() {
+ String code =
+ "%:define join1(a, b) a %:%: b \n" +
+ "%:define str1(a) %: a \n" +
+ "??=define join2(a, b) a ??=??= b \n" +
+ "??=define str2(a) ??= a \n" +
+ "int main() <% \n" +
+ " int join1(x, y) = str1(its all good); \n" +
+ " int join2(a, b) = str2(its still good); \n" +
+ "%> \n";
+
+ IASTTranslationUnit tu = parse(code); // will throw an exception if there are parse errors
+
+ IASTFunctionDefinition main = (IASTFunctionDefinition)tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) main.getBody();
+ IASTStatement[] statements = body.getStatements();
+ assertEquals(2, statements.length);
+
+ IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration)((IASTDeclarationStatement)statements[0]).getDeclaration();
+ IASTDeclarator declarator1 = decl1.getDeclarators()[0];
+ assertEquals("xy", declarator1.getName().toString());
+ IASTLiteralExpression expr1 = (IASTLiteralExpression)((IASTInitializerExpression)declarator1.getInitializer()).getExpression();
+ assertEquals(IASTLiteralExpression.lk_string_literal, expr1.getKind());
+ assertEquals("\"its all good\"", expr1.toString());
+
+ IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration)((IASTDeclarationStatement)statements[1]).getDeclaration();
+ IASTDeclarator declarator2 = decl2.getDeclarators()[0];
+ assertEquals("ab", declarator2.getName().toString());
+ IASTLiteralExpression expr2 = (IASTLiteralExpression)((IASTInitializerExpression)declarator2.getInitializer()).getExpression();
+ assertEquals(IASTLiteralExpression.lk_string_literal, expr2.getKind());
+ assertEquals("\"its still good\"", expr2.toString());
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRGCCCompleteParseExtensionsTest.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRGCCCompleteParseExtensionsTest.java
new file mode 100644
index 00000000000..eeea2f59f5d
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRGCCCompleteParseExtensionsTest.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.GCCCompleteParseExtensionsTest;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+@SuppressWarnings("restriction")
+public class LRGCCCompleteParseExtensionsTest extends GCCCompleteParseExtensionsTest {
+
+ public static TestSuite suite() {
+ return suite(LRGCCCompleteParseExtensionsTest.class);
+ }
+
+ public LRGCCCompleteParseExtensionsTest() {}
+ public LRGCCCompleteParseExtensionsTest(String name) { super(name); }
+
+
+ @Override
+ @SuppressWarnings("unused")
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options().setCheckSyntaxProblems(expectNoProblems).setCheckPreprocessorProblems(expectNoProblems);
+ return ParseHelper.parse(code, language, options);
+ }
+
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRGCCTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRGCCTests.java
new file mode 100644
index 00000000000..712db6dcb94
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRGCCTests.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.GCCTests;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+@SuppressWarnings("restriction")
+public class LRGCCTests extends GCCTests {
+
+ public static TestSuite suite() {
+ return suite(LRGCCTests.class);
+ }
+
+ public LRGCCTests() {}
+ public LRGCCTests(String name) { super(name); }
+
+
+ @Override
+ @SuppressWarnings("unused")
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options().setCheckSyntaxProblems(expectNoProblems).setCheckPreprocessorProblems(expectNoProblems);
+ return ParseHelper.parse(code, language, options);
+ }
+
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRImageLocationTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRImageLocationTests.java
new file mode 100644
index 00000000000..21997f6b77d
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRImageLocationTests.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 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.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+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 skipTrivialInitializers) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setCheckSyntaxProblems(expectNoProblems);
+ options.setCheckPreprocessorProblems(expectNoProblems);
+ options.setSkipTrivialInitializers(skipTrivialInitializers);
+ return ParseHelper.parse(code, language, options);
+ }
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRKnRTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRKnRTests.java
new file mode 100644
index 00000000000..3a1c690315f
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRKnRTests.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.AST2KnRTests;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+/**
+ * @author Mike Kucera
+ */
+@SuppressWarnings("restriction")
+public class LRKnRTests extends AST2KnRTests {
+
+ public static TestSuite suite() {
+ return suite(LRKnRTests.class);
+ }
+
+ @Override
+ @SuppressWarnings("unused")
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ return ParseHelper.parse(code, language, expectNoProblems);
+ }
+
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+ // LPG handles syntax errors differently than the DOM parser
+ // these tests look for syntax errors in specific places and they fail
+
+ @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 _) { }
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRNodeSelectorTest.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRNodeSelectorTest.java
new file mode 100644
index 00000000000..4c8a8b8bdc2
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRNodeSelectorTest.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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 java.io.IOException;
+
+import junit.framework.TestSuite;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+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, boolean skipTrivialInitializer) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setCheckSyntaxProblems(expectNoProblems);
+ options.setCheckPreprocessorProblems(expectNoProblems);
+ options.setSkipTrivialInitializers(skipTrivialInitializer);
+ return ParseHelper.parse(code, language, options);
+ }
+
+ @Override
+ protected void createTranslationUnit() throws IOException {
+ fCode= getContents(1)[0].toString();
+ fTu = ParseHelper.parse(fCode, getCPPLanguage(), false);
+ fSelector= fTu.getNodeSelector(null);
+ }
+
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRParserTestSuite.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRParserTestSuite.java
new file mode 100644
index 00000000000..7c380a91c41
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRParserTestSuite.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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.Test;
+import junit.framework.TestSuite;
+
+public class LRParserTestSuite extends TestSuite {
+
+
+ public static Test suite() {
+ return new TestSuite() {{
+
+ addTest(LRCommentTests.suite());
+ addTest(LRCompleteParser2Tests.suite());
+ addTest(LRCompletionBasicTest.suite());
+ addTest(LRCompletionParseTest.suite());
+ addTest(LRCPPSpecTest.suite());
+ addTest(LRCPPTests.suite());
+ addTest(LRCSpecTests.suite()); // a couple of failures
+ addTest(LRDigraphTrigraphTests.suite());
+ addTest(LRDOMLocationInclusionTests.suite());
+ addTest(LRDOMLocationMacroTests.suite());
+ addTest(LRDOMLocationTests.suite());
+ addTest(LRDOMPreprocessorInformationTest.suite());
+ addTest(LRGCCTests.suite());
+ addTest(LRGCCCompleteParseExtensionsTest.suite());
+ addTest(LRImageLocationTests.suite());
+ addTest(LRKnRTests.suite()); // mostly fail due to ambiguities
+ addTest(LRNodeSelectorTest.suite());
+ addTestSuite(LRQuickParser2Tests.class);
+ addTest(LRSelectionParseTest.suite()); // this one still has a lot of failing tests though
+ addTest(LRSemanticsTests.suite());
+ addTest(LRTaskParserTest.suite());
+ addTest(LRTemplateTests.suite());
+ addTest(LRTests.suite()); // has some tests that do fail
+ addTest(LRUtilOldTests.suite());
+ addTest(LRUtilTests.suite());
+ //addTest(LRCPPImplicitNameTests.suite());
+ //addTest(LRInactiveCodeTests.suite());
+
+ }};
+ }
+}
+
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRQuickParser2Tests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRQuickParser2Tests.java
new file mode 100644
index 00000000000..d0b7dc7082b
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRQuickParser2Tests.java
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 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.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+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() : getCLanguage();
+ // don't check preprocessor problems for this test suite (causes tons of failures)
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setCheckSyntaxProblems(expectedToPass);
+ options.setCheckPreprocessorProblems(false);
+ ParseHelper.parse(code, language, options);
+ }
+
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+
+ @Override
+ public void testBug36532() {
+ // ParseHelper does not throw ParserException
+ // just ignore this test
+ }
+
+// @Override
+// public void testBug39695() throws Exception { // no support for __alignof__
+// try {
+// super.testBug39695();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+//
+// @Override
+// public void testBug39684() throws Exception { // typeof is gcc extension
+// try {
+// super.testBug39684();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+//
+// @Override
+// public void testBug39698A() throws Exception { // gcc extension
+// try {
+// super.testBug39698A();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+//
+// @Override
+// public void testBug39698B() throws Exception { // gcc extension
+// try {
+// super.testBug39698B();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+//
+// @Override
+// public void testBug39704B() throws Exception { // gcc extension
+// try {
+// super.testBug39704B();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+//
+// @Override
+// public void testBug39704C() throws Exception { // gcc extension
+// try {
+// super.testBug39704C();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+//
+// @Override
+// public void testBug39677() throws Exception { // gcc extension
+// try {
+// super.testBug39677();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+//
+//
+// @Override
+// public void testBug57652() throws Exception { // gcc extension
+// try {
+// super.testBug57652();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+//
+//
+// @Override
+// public void testBug39701A() throws Exception { // gcc extension
+// try {
+// super.testBug39701A();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+//
+// @Override
+// public void testBug39701B() throws Exception { // gcc extension
+// try {
+// super.testBug39701B();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+//
+// @Override
+// public void testBug39701C() throws Exception { // gcc extension
+// try {
+// super.testBug39701C();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+//
+//
+// @Override
+// public void testBug40007() throws Exception { // gcc extension
+// try {
+// super.testBug40007();
+// fail();
+// } catch(AssertionFailedError _) {
+// } catch(AssertionError _) {
+// }
+//
+// }
+//
+// @Override
+// public void testBug39703() throws Exception { // gcc extension
+// try {
+// super.testBug39703();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+//
+//
+// @Override
+// public void testBug39554() throws Exception { // gcc extension
+// try {
+// super.testBug39554();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+//
+//
+// @Override
+// public void testBug39686() throws Exception { // gcc extension
+// try {
+// super.testBug39686();
+// fail();
+// } catch(AssertionFailedError _) { }
+// }
+
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRSelectionParseTest.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRSelectionParseTest.java
new file mode 100644
index 00000000000..f6b3d5662d8
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRSelectionParseTest.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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.ICodeReaderFactory;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.CodeReader;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.ScannerInfo;
+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;
+
+@SuppressWarnings("restriction")
+public class LRSelectionParseTest extends AST2SelectionParseTest {
+
+ public static TestSuite suite() {
+ return new TestSuite(LRSelectionParseTest.class);
+ }
+
+ public LRSelectionParseTest() {}
+ public LRSelectionParseTest(String name) { super(name); }
+
+ @Override
+ protected IASTNode parse(String code, ParserLanguage lang, int offset, int length) throws ParserException {
+ return parse(code, lang, false, false, offset, length);
+ }
+
+ @Override
+ protected IASTNode parse(IFile file, ParserLanguage lang, int offset, int length) throws ParserException {
+ IASTTranslationUnit tu = parse(file, lang, false, false);
+ return tu.selectNodeForLocation(tu.getFilePath(), offset, length);
+ }
+
+ @Override
+ protected IASTNode parse(String code, ParserLanguage lang, int offset, int length, boolean expectedToPass) throws ParserException {
+ return parse(code, lang, false, expectedToPass, offset, length);
+ }
+
+ @Override
+ protected IASTNode parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems, int offset, int length) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setCheckPreprocessorProblems(expectNoProblems);
+ options.setCheckSyntaxProblems(expectNoProblems);
+ IASTTranslationUnit tu = ParseHelper.parse(code, language, options);
+ return tu.selectNodeForLocation(tu.getFilePath(), offset, length);
+ }
+
+ protected IASTTranslationUnit parse( IFile file, ParserLanguage lang, IScannerInfo scanInfo, boolean useGNUExtensions, boolean expectNoProblems ) {
+
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+
+ String fileName = file.getLocation().toOSString();
+ ICodeReaderFactory fileCreator = SavedCodeReaderFactory.getInstance();
+ CodeReader reader = fileCreator.createCodeReaderForTranslationUnit(fileName);
+
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setCheckPreprocessorProblems(expectNoProblems);
+ options.setCheckSyntaxProblems(expectNoProblems);
+ options.setCheckBindings(true);
+
+ return ParseHelper.parse(reader, language, scanInfo, fileCreator, options);
+ }
+
+ @Override
+ protected IASTTranslationUnit parse( IFile file, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems )
+ throws ParserException {
+ return parse(file, lang, new ScannerInfo(), useGNUExtensions, expectNoProblems);
+ }
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRSemanticsTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRSemanticsTests.java
new file mode 100644
index 00000000000..d88581caa06
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRSemanticsTests.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 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.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+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 skipTrivialInitializers) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setCheckSyntaxProblems(expectNoProblems);
+ options.setCheckPreprocessorProblems(expectNoProblems);
+ options.setSkipTrivialInitializers(skipTrivialInitializers);
+ return ParseHelper.parse(code, language, options);
+ }
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRTaskParserTest.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRTaskParserTest.java
new file mode 100644
index 00000000000..b3e67ec916c
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRTaskParserTest.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.TaskParserTest;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+@SuppressWarnings("restriction")
+public class LRTaskParserTest extends TaskParserTest {
+
+ public static TestSuite suite() {
+ return new TestSuite(LRTaskParserTest.class);
+ }
+
+ @Override
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ return parse(code, lang, useGNUExtensions, expectNoProblems, false);
+ }
+
+ @Override
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, @SuppressWarnings("unused") boolean useGNUExtensions, boolean expectNoProblems, boolean skipTrivialInitializers) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setCheckSyntaxProblems(expectNoProblems);
+ options.setCheckPreprocessorProblems(expectNoProblems);
+ options.setSkipTrivialInitializers(skipTrivialInitializers);
+ return ParseHelper.parse(code, language, options);
+ }
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRTemplateTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRTemplateTests.java
new file mode 100644
index 00000000000..ffeab5cc299
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRTemplateTests.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.AST2TemplateTests;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+@SuppressWarnings("restriction")
+public class LRTemplateTests extends AST2TemplateTests {
+
+
+ public static TestSuite suite() {
+ return suite(LRTemplateTests.class);
+ }
+
+
+ @Override
+ @SuppressWarnings("unused")
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems, boolean skipTrivialInitializers) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setCheckSyntaxProblems(expectNoProblems);
+ options.setCheckPreprocessorProblems(expectNoProblems);
+ options.setSkipTrivialInitializers(skipTrivialInitializers);
+ return ParseHelper.parse(code, language, options);
+ }
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRTests.java
new file mode 100644
index 00000000000..6cc16d54449
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRTests.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.AST2Tests;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+
+/**
+ *
+ * @author Mike Kucera
+ *
+ */
+@SuppressWarnings({ "nls", "restriction" })
+public class LRTests extends AST2Tests {
+
+ public static TestSuite suite() {
+ return suite(LRTests.class);
+ }
+
+ public LRTests(String name) {
+ super(name);
+ }
+
+
+ @Override
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ return parse(code, lang, useGNUExtensions, expectNoProblems, false);
+ }
+
+ @Override
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems, boolean skipTrivialInitializers) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setCheckSyntaxProblems(expectNoProblems);
+ options.setCheckPreprocessorProblems(expectNoProblems);
+ options.setSkipTrivialInitializers(skipTrivialInitializers);
+ return ParseHelper.parse(code, language, options);
+ }
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+
+ public void testMultipleHashHash() throws Exception {
+ String code = "#define TWICE(a) int a##tera; int a##ther; \n TWICE(pan)";
+ parseAndCheckBindings(code, ParserLanguage.C);
+ }
+
+
+ public void testBug191279() throws Exception {
+ StringBuffer sb = new StringBuffer();
+ sb.append(" /**/ \n");
+ sb.append("# define YO 99 /**/ \n");
+ sb.append("# undef YO /**/ ");
+ sb.append(" /* $ */ ");
+ String code = sb.toString();
+ parseAndCheckBindings(code, ParserLanguage.C);
+ }
+
+
+ public void testBug191324() throws Exception {
+ StringBuffer sb = new StringBuffer();
+ sb.append("int x$y = 99; \n");
+ sb.append("int $q = 100; \n"); // can use $ as first character in identifier
+ sb.append("#ifndef SS$_INVFILFOROP \n");
+ sb.append("int z; \n");
+ sb.append("#endif \n");
+ String code = sb.toString();
+ parseAndCheckBindings(code, ParserLanguage.C);
+ }
+
+
+ public void testBug192009_implicitInt() throws Exception {
+ String code = "main() { int x; }";
+ IASTTranslationUnit tu = parse(code, ParserLanguage.C, false, true);
+
+ IASTDeclaration[] declarations = tu.getDeclarations();
+ assertEquals(1, declarations.length);
+
+ IASTFunctionDefinition main = (IASTFunctionDefinition) declarations[0];
+ ICASTSimpleDeclSpecifier declSpec = (ICASTSimpleDeclSpecifier) main.getDeclSpecifier();
+ assertEquals(0, declSpec.getType());
+
+
+ assertEquals("main", main.getDeclarator().getName().toString());
+ }
+
+
+
+ /* I don't care about C98
+ */
+ @Override
+ public void testBug196468_emptyArrayInitializer() { }
+ public void _testBug196468_emptyArrayInitializer() throws Exception {
+ super.testBug196468_emptyArrayInitializer();
+ }
+
+
+ // CHANGED
+// /* LPG holds on to all the tokens as you parse, so I don't think
+// * it would be easy to fix this bug.
+// */
+// @Override
+// public void testScalabilityOfLargeTrivialInitializer_Bug253690() { }
+// public void _testScalabilityOfLargeTrivialInitializer_Bug253690() throws Exception {
+//
+// super.testScalabilityOfLargeTrivialInitializer_Bug253690();
+// }
+
+
+ /* All of the identifiers in the code resolve correctly.
+ * The problem is that some of the expressions parse wrong but
+ * thats not actually a big deal. Fixing this bug will be
+ * difficult so defer it to the future.
+ */
+ @Override
+ public void testBinaryVsCastAmbiguities_Bug237057() { }
+ public void _testBinaryVsCastAmbiguities_Bug237057() throws Exception {
+ super.testBinaryVsCastAmbiguities_Bug237057();
+ }
+
+
+ /* All of the identifiers in the code resolve correctly.
+ * The problem is that some of the expressions parse wrong but
+ * thats not actually a big deal. Fixing this bug will be
+ * difficult so defer it to the future.
+ */
+ @Override
+ public void testCastVsFunctionCallAmbiguities_Bug237057() { }
+ public void _testCastVsFunctionCallAmbiguities_Bug237057() throws Exception {
+ super.testCastVsFunctionCallAmbiguities_Bug237057();
+ }
+
+
+ /* The LR parser generates the AST for switch statements
+ * differently than the DOM parser.
+ */
+ @Override
+ public void testCaseRange_Bug211882() { }
+ public void _testCaseRange_Bug211882() throws Exception {
+ super.testCaseRange_Bug211882();
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRUtilOldTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRUtilOldTests.java
new file mode 100644
index 00000000000..85debdd48b0
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRUtilOldTests.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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;
+import junit.framework.TestSuite;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.AST2UtilOldTests;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+@SuppressWarnings("restriction")
+public class LRUtilOldTests extends AST2UtilOldTests {
+
+ public static TestSuite suite() {
+ return suite(LRUtilOldTests.class);
+ }
+
+
+ @Override
+ @SuppressWarnings("unused")
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ return ParseHelper.parse(code, language, expectNoProblems);
+ }
+
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+
+
+ @Override
+ public void testCastExpression() throws Exception { // A not typedefed
+ try {
+ super.testCastExpression();
+ fail();
+ } catch(AssertionFailedError _) {}
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRUtilTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRUtilTests.java
new file mode 100644
index 00000000000..98b03264545
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRUtilTests.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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.gnu.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.gnu.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.AST2UtilTests;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+@SuppressWarnings("restriction")
+public class LRUtilTests extends AST2UtilTests {
+
+ public static TestSuite suite() {
+ return suite(LRUtilTests.class);
+ }
+
+ @Override
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang ) throws ParserException {
+ return parse(code, lang, false, true );
+ }
+
+ @Override
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions ) throws ParserException {
+ return parse( code, lang, useGNUExtensions, true );
+ }
+
+ @Override
+ @SuppressWarnings("unused")
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
+ return ParseHelper.parse(code, language, expectNoProblems);
+ }
+
+
+ protected ILanguage getCLanguage() {
+ return GCCLanguage.getDefault();
+ }
+
+ protected ILanguage getCPPLanguage() {
+ return GPPLanguage.getDefault();
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/ParseHelper.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/ParseHelper.java
new file mode 100644
index 00000000000..8fec58190c9
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/ParseHelper.java
@@ -0,0 +1,215 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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 java.util.ArrayList;
+import java.util.List;
+
+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.model.ILanguage;
+import org.eclipse.cdt.core.parser.CodeReader;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.ParserUtil;
+import org.eclipse.cdt.core.parser.ScannerInfo;
+import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Utility methods for parsing test code using the C99 LPG parser.
+ *
+ * @author Mike Kucera
+ */
+@SuppressWarnings({"restriction", "nls"})
+public class ParseHelper {
+
+ static int testsRun = 0;
+
+
+
+ static protected class NameResolver extends ASTVisitor {
+ {
+ shouldVisitNames = true;
+ }
+
+ public List<IASTName> nameList = new ArrayList<IASTName>();
+ public List<String> problemBindings = new ArrayList<String>();
+ public int numNullBindings = 0;
+
+
+ @Override
+ public int visit(IASTName name) {
+ nameList.add(name);
+ IBinding binding = name.resolveBinding();
+ if (binding instanceof IProblemBinding)
+ problemBindings.add(name.toString());
+ if (binding == null)
+ numNullBindings++;
+ return PROCESS_CONTINUE;
+ }
+
+ public IASTName getName(int idx) {
+ if(idx < 0 || idx >= nameList.size())
+ return null;
+ return nameList.get(idx);
+ }
+
+ public int size() {
+ return nameList.size();
+ }
+ }
+
+
+
+ public static class Options {
+
+ boolean checkSyntaxProblems = true;
+ boolean checkPreprocessorProblems = true;
+ boolean checkBindings = false;
+
+ int expectedProblemBindings;
+ String[] problems;
+ boolean skipTrivialInitializers;
+
+ public Options setCheckSyntaxProblems(boolean checkSyntaxProblems) {
+ this.checkSyntaxProblems = checkSyntaxProblems;
+ return this;
+ }
+ public Options setCheckBindings(boolean checkBindings) {
+ this.checkBindings = checkBindings;
+ return this;
+ }
+ public Options setCheckPreprocessorProblems(boolean checkPreprocessorProblems) {
+ this.checkPreprocessorProblems = checkPreprocessorProblems;
+ return this;
+ }
+ public Options setExpectedProblemBindings(int expectedProblemBindings) {
+ this.expectedProblemBindings = expectedProblemBindings;
+ return this;
+ }
+ public Options setProblems(String[] problems) {
+ this.problems = problems;
+ setExpectedProblemBindings(problems.length);
+ setCheckBindings(true);
+ return this;
+ }
+ public Options setSkipTrivialInitializers(boolean skipTrivialInitializers) {
+ this.skipTrivialInitializers = skipTrivialInitializers;
+ return this;
+ }
+
+ }
+
+
+ public static IASTTranslationUnit parse(String code, ILanguage lang, boolean expectNoProblems) {
+ Options options = new Options().setCheckSyntaxProblems(expectNoProblems).setCheckPreprocessorProblems(expectNoProblems);
+ return parse(code.toCharArray(), lang, options);
+ }
+
+ public static IASTTranslationUnit parse(String code, ILanguage lang, Options options) {
+ return parse(code.toCharArray(), lang, options);
+ }
+
+
+ public static IASTTranslationUnit parse(char[] code, ILanguage lang, Options options) {
+ CodeReader codeReader = new CodeReader(code);
+ return parse(codeReader, lang, new ScannerInfo(), null, options);
+ }
+
+
+ /**
+ * TODO thats WAY too many parameters, need to use a parameter object, need to refactor the
+ * DOM parser test suite so that its a lot cleaner.
+ */
+ public static IASTTranslationUnit parse(CodeReader codeReader, ILanguage language, IScannerInfo scanInfo,
+ ICodeReaderFactory fileCreator, Options options) {
+ testsRun++;
+
+ IASTTranslationUnit tu;
+ try {
+ int languageOptions = 0;
+// if(options.skipTrivialInitializers)
+// languageOptions |= ILanguage.OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS;
+
+ tu = language.getASTTranslationUnit(codeReader, scanInfo, fileCreator, null, languageOptions, ParserUtil.getParserLogService());
+ } catch (CoreException e) {
+ throw new AssertionFailedError(e.toString());
+ }
+
+ // should parse correctly first before we look at the bindings
+ if(options.checkSyntaxProblems) {
+
+ // this should work for C++ also, CVisitor.getProblems() and CPPVisitor.getProblems() are exactly the same code!
+ if (CVisitor.getProblems(tu).length != 0) {
+ throw new AssertionFailedError(" CVisitor has AST Problems " );
+ }
+ }
+
+ if(options.checkPreprocessorProblems) {
+ if (tu.getPreprocessorProblems().length != 0) {
+ throw new AssertionFailedError(language.getName() + " TranslationUnit has Preprocessor Problems " );
+ }
+ }
+
+ // resolve all bindings
+ if (options.checkBindings) {
+ NameResolver res = new NameResolver();
+ tu.accept( res );
+ if(res.problemBindings.size() != options.expectedProblemBindings)
+ throw new AssertionFailedError("Expected " + options.expectedProblemBindings + " problem(s), encountered " + res.problemBindings.size());
+
+ if(options.problems != null) {
+ for(int i = 0; i < options.problems.length; i++) {
+ String expected = options.problems[i];
+ String actual = res.problemBindings.get(i);
+ if(!expected.equals(actual))
+ throw new AssertionFailedError(String.format("Problem binding not equal, expected: %s, got: %s", expected, actual));
+ }
+ }
+ }
+
+ return tu;
+ }
+
+
+ public static IASTTranslationUnit commentParse(String code, ILanguage language) {
+ CodeReader codeReader = new CodeReader(code.toCharArray());
+ IASTTranslationUnit tu;
+ try {
+ tu = language.getASTTranslationUnit(codeReader, new ScannerInfo(), null, null, ILanguage.OPTION_ADD_COMMENTS, ParserUtil.getParserLogService());
+ } catch (CoreException e) {
+ throw new AssertionFailedError(e.toString());
+ }
+ return tu;
+ }
+
+ public static IASTCompletionNode getCompletionNode(String code, ILanguage lang) {
+ return getCompletionNode(code, lang, code.length());
+ }
+
+
+ public static IASTCompletionNode getCompletionNode(String code, ILanguage language, int offset) {
+ CodeReader reader = new CodeReader(code.toCharArray());
+ try {
+ return language.getCompletionNode(reader, new ScannerInfo(), null, null, ParserUtil.getParserLogService(), offset);
+ } catch (CoreException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}

Back to the top