diff options
Diffstat (limited to 'lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests')
28 files changed, 0 insertions, 2898 deletions
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCPPSpecFailingTest.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCPPSpecFailingTest.java deleted file mode 100644 index 2ca06bdf816..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCPPSpecFailingTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.AST2CPPSpecFailingTest; -import org.eclipse.cdt.internal.core.parser.ParserException; - -@SuppressWarnings("restriction") -public class LRCPPSpecFailingTest extends AST2CPPSpecFailingTest { - - public static TestSuite suite() { - return suite(LRCPPSpecFailingTest.class); - } - - public LRCPPSpecFailingTest() { } - public LRCPPSpecFailingTest(String name) { super(name); } - - - @Override - protected void parseCandCPP( String code, boolean checkBindings, int expectedProblemBindings ) throws ParserException { - parse(code, ParserLanguage.C, checkBindings, expectedProblemBindings); - parse(code, ParserLanguage.CPP, checkBindings, expectedProblemBindings); - } - - @Override - protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean checkBindings, int expectedProblemBindings ) throws ParserException { - ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage(); - return ParseHelper.parse(code, language, true, checkBindings, expectedProblemBindings ); - } - - @Override - protected IASTTranslationUnit parse(String code, ParserLanguage lang, String[] problems) throws ParserException { - ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage(); - return ParseHelper.parse(code, language, problems); - } - - - protected BaseExtensibleLanguage getCLanguage() { - return C99Language.getDefault(); - } - - protected BaseExtensibleLanguage getCPPLanguage() { - return ISOCPPLanguage.getDefault(); - } - -} 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 deleted file mode 100644 index bc2477fecd8..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCPPSpecTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.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 parse( String code, ParserLanguage lang, boolean checkBindings, int expectedProblemBindings ) throws ParserException { - ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage(); - return ParseHelper.parse(code, language, true, checkBindings, expectedProblemBindings ); - } - - @Override - protected IASTTranslationUnit parse(String code, ParserLanguage lang, String[] problems) throws ParserException { - ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage(); - return ParseHelper.parse(code, language, problems); - } - - protected BaseExtensibleLanguage getCLanguage() { - return C99Language.getDefault(); - } - - protected BaseExtensibleLanguage getCPPLanguage() { - return ISOCPPLanguage.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 deleted file mode 100644 index 450a0737f7b..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCPPTests.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.AssertionFailedError; -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.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, @SuppressWarnings("unused") boolean parseComments) throws ParserException { - ILanguage language = lang.isCPP() ? getCPPLanguage() : getC99Language(); - return ParseHelper.parse(code, language, expectNoProblems); - } - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.getDefault(); - } - - - @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 testBug99262B() throws Exception { // gcc - try { - super.testBug99262B(); - fail(); - } catch(AssertionFailedError _) { - } - } - - @Override - public void testLiteralsViaOverloads_225534() throws Exception { // gcc, I think - try { - super.testLiteralsViaOverloads_225534(); - fail(); - } catch(AssertionFailedError _) { - } - } - - -} diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCSpecFailingTest.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCSpecFailingTest.java deleted file mode 100644 index aa47ce74f1f..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCSpecFailingTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.AssertionFailedError; -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.AST2CSpecFailingTest; -import org.eclipse.cdt.internal.core.parser.ParserException; - -@SuppressWarnings("restriction") -public class LRCSpecFailingTest extends AST2CSpecFailingTest { - - public static TestSuite suite() { - return suite(LRCSpecFailingTest.class); - } - - public LRCSpecFailingTest() { } - public LRCSpecFailingTest(String name) { super(name); } - - - @Override - protected void parseCandCPP( String code, boolean checkBindings, int expectedProblemBindings ) throws ParserException { - parse(code, ParserLanguage.C, checkBindings, expectedProblemBindings); - parse(code, ParserLanguage.CPP, checkBindings, expectedProblemBindings); - } - - @Override - protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean checkBindings, int expectedProblemBindings ) throws ParserException { - ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage(); - return ParseHelper.parse(code, language, true, checkBindings, expectedProblemBindings ); - } - - @Override - protected IASTTranslationUnit parse(String code, ParserLanguage lang, String[] problems) throws ParserException { - ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage(); - return ParseHelper.parse(code, language, problems); - } - - protected BaseExtensibleLanguage getCLanguage() { - return C99Language.getDefault(); - } - - protected BaseExtensibleLanguage getCPPLanguage() { - return ISOCPPLanguage.getDefault(); - } - - @Override - public void test6_7_7s6() throws Exception { // this test actually passes, yay! - try { - super.test6_7_7s6(); - } catch (AssertionFailedError e) { - } - } -} 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 deleted file mode 100644 index 6c3833ff6f5..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCSpecTests.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.AssertionFailedError; -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.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(); - return ParseHelper.parse(code, language, true, checkBindings, expectedProblemBindings ); - } - - @Override - protected IASTTranslationUnit parse(String code, ParserLanguage lang, String[] problems) throws ParserException { - ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage(); - return ParseHelper.parse(code, language, problems); - } - - protected ILanguage getCLanguage() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.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 _) { } - } - - -} 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 deleted file mode 100644 index 087c2a91961..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCommentTests.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTComment; -import org.eclipse.cdt.core.dom.ast.IASTFileLocation; -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.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 - @SuppressWarnings("unused") - protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException { - ILanguage language = lang.isCPP() ? getCPPLanguage() : getC99Language(); - return ParseHelper.parse(code, language, expectNoProblems); - } - - - @Override - @SuppressWarnings("unused") - protected IASTTranslationUnit parse(String code, ParserLanguage lang, - boolean useGNUExtensions, boolean expectNoProblems, - boolean parseComments) throws ParserException { - - ILanguage language = lang.isCPP() ? getCPPLanguage() : getC99Language(); - return ParseHelper.commentParse(code, language); - } - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.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 deleted file mode 100644 index 58cb19126e4..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCompleteParser2Tests.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.AssertionFailedError; -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.CompleteParser2Tests; - -public class LRCompleteParser2Tests extends CompleteParser2Tests { - - public static TestSuite suite() { - return suite(LRCompleteParser2Tests.class); - } - - @Override - @SuppressWarnings("unused") - protected IASTTranslationUnit parse(String code, boolean expectedToPass, - ParserLanguage lang, boolean gcc) throws Exception { - ILanguage language = lang.isCPP() ? getCPPLanguage() : getC99Language(); - return ParseHelper.parse(code, language, expectedToPass); - } - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.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 deleted file mode 100644 index 9d51fd58623..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCompletionBasicTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.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.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.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() : getC99Language(); - return ParseHelper.getCompletionNode(code, language); - } - - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.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 deleted file mode 100644 index bbca81ada20..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRCompletionParseTest.java +++ /dev/null @@ -1,415 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import 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.c99.C99Language; -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, getC99Language(), 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 getC99Language() { - return C99Language.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 deleted file mode 100644 index 976311aad32..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMLocationInclusionTests.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.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() : getC99Language(); //$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 getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.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 deleted file mode 100644 index 8fcc5d505f9..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMLocationMacroTests.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.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() : getC99Language(); - return ParseHelper.parse(code, language, expectNoProblems); - } - - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.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 deleted file mode 100644 index 11af2e14cef..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMLocationTests.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.AssertionFailedError; -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.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() : getC99Language(); - return ParseHelper.parse(code, language, expectNoProblems); - } - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.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 deleted file mode 100644 index b6b7cce7716..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDOMPreprocessorInformationTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.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() : getC99Language(); - return ParseHelper.parse(code, language, expectNoProblems); - } - - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.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 deleted file mode 100644 index fafc19cd4d7..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRDigraphTrigraphTests.java +++ /dev/null @@ -1,183 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.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.c99.C99Language; -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(LRCSpecTests.class); - } - - - public LRDigraphTrigraphTests() { } - public LRDigraphTrigraphTests(String name) { super(name); } - - - protected IASTTranslationUnit parse(String code) { - return ParseHelper.parse(code, getCLanguage(), true); - } - - - protected ILanguage getCLanguage() { - return C99Language.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/LRGCCTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRGCCTests.java deleted file mode 100644 index 0b6603470de..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRGCCTests.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.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() : getC99Language(); - return ParseHelper.parse(code, language, expectNoProblems); - } - - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.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 deleted file mode 100644 index 2bca1e7c61a..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRImageLocationTests.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others All rights reserved. This - * program and the accompanying materials are made available under the terms of - * the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation - ******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.ImageLocationTests; -import org.eclipse.cdt.internal.core.parser.ParserException; - -@SuppressWarnings("restriction") -public class LRImageLocationTests extends ImageLocationTests { - - public static TestSuite suite() { - return suite(LRImageLocationTests.class); - } - - public LRImageLocationTests() { } - public LRImageLocationTests(String name) { super(name); } - - - @Override - @SuppressWarnings("unused") - protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, - boolean expectNoProblems, boolean parseComments) throws ParserException { - ILanguage language = lang.isCPP() ? getCPPLanguage() : getC99Language(); - return ParseHelper.parse(code, language, expectNoProblems); - } - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.getDefault(); - } - -} 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 deleted file mode 100644 index 2dc57ce6679..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRKnRTests.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.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() : getC99Language(); - return ParseHelper.parse(code, language, expectNoProblems); - } - - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.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 deleted file mode 100644 index 9e47a0dc9f7..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRNodeSelectorTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import java.io.IOException; - -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.ASTNodeSelectorTest; -import org.eclipse.cdt.internal.core.parser.ParserException; - -@SuppressWarnings("restriction") -public class LRNodeSelectorTest extends ASTNodeSelectorTest { - - public static TestSuite suite() { - return suite(LRNodeSelectorTest.class); - } - - public LRNodeSelectorTest() {} - public LRNodeSelectorTest(String name) { super(name); } - - - @Override - protected IASTTranslationUnit parse( String code, ParserLanguage lang, @SuppressWarnings("unused") boolean useGNUExtensions, boolean expectNoProblems, @SuppressWarnings("unused") boolean parseComments) throws ParserException { - ILanguage language = lang.isCPP() ? getCPPLanguage() : getC99Language(); - return ParseHelper.parse(code, language, expectNoProblems); - } - - @Override - protected void createTranslationUnit() throws IOException { - fCode= getContents(1)[0].toString(); - fTu = ParseHelper.parse(fCode, getCPPLanguage(), false); - fSelector= fTu.getNodeSelector(null); - } - - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.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 deleted file mode 100644 index 19b4c5efb86..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRParserTestSuite.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - - - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class LRParserTestSuite extends TestSuite { - - // TODO: the following test are not being reused - // - // DOMGCCSelectionParseExtensionsTest - // DOMSelectionParseTest - // GCCCompleteParseExtensionsTest - // QuickParser2Tests - // - // and perhaps others - - public static Test suite() { - return new TestSuite() {{ - - addTestSuite(LRCommentTests.class); - addTestSuite(LRCompleteParser2Tests.class); - addTestSuite(LRCompletionBasicTest.class); - addTestSuite(LRCompletionParseTest.class); - addTestSuite(LRCPPSpecFailingTest.class); - addTestSuite(LRCPPSpecTest.class); - addTestSuite(LRCPPTests.class); - addTestSuite(LRCSpecFailingTest.class); - addTestSuite(LRCSpecTests.class); // a couple of failures - addTestSuite(LRDigraphTrigraphTests.class); - addTestSuite(LRDOMLocationInclusionTests.class); - addTestSuite(LRDOMLocationMacroTests.class); - addTestSuite(LRDOMLocationTests.class); - addTestSuite(LRDOMPreprocessorInformationTest.class); - addTestSuite(LRGCCTests.class); - addTestSuite(LRImageLocationTests.class); - addTestSuite(LRKnRTests.class); // mostly fail due to ambiguities - addTestSuite(LRNodeSelectorTest.class); - addTestSuite(LRQuickParser2Tests.class); - addTestSuite(LRSelectionParseTest.class); // this one still has a lot of failing tests though - addTestSuite(LRSemanticsTests.class); - addTestSuite(LRTaskParserTest.class); - addTestSuite(LRTemplateTests.class); - addTestSuite(LRTests.class); // has some tests that do fail - addTestSuite(LRUtilOldTests.class); - addTestSuite(LRUtilTests.class); - - }}; - } -} - 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 deleted file mode 100644 index 7ddb87c712f..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRQuickParser2Tests.java +++ /dev/null @@ -1,182 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others All rights reserved. This - * program and the accompanying materials are made available under the terms of - * the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation - ******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.AssertionFailedError; - -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.CodeReader; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.ScannerInfo; -import org.eclipse.cdt.core.parser.tests.ast2.QuickParser2Tests; -import org.eclipse.cdt.core.parser.tests.scanner.FileCodeReaderFactory; - -public class LRQuickParser2Tests extends QuickParser2Tests { - - public LRQuickParser2Tests() {} - public LRQuickParser2Tests(String name) { super(name); } - - - @Override - protected void parse(String code, boolean expectedToPass, - ParserLanguage lang, @SuppressWarnings("unused") boolean gcc) throws Exception { - ILanguage language = lang.isCPP() ? getCPPLanguage() : getC99Language(); - CodeReader reader = new CodeReader(code.toCharArray()); - // don't check preprocessor problems for this test suite (causes tons of failures) - ParseHelper.parse(reader, language, new ScannerInfo(), FileCodeReaderFactory.getInstance(), expectedToPass, false, 0, null, false); - } - - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.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 deleted file mode 100644 index 40dc773e455..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRSelectionParseTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ICodeReaderFactory; -import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.CodeReader; -import org.eclipse.cdt.core.parser.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() : getC99Language(); - - IASTTranslationUnit tu = ParseHelper.parse(code, language, useGNUExtensions, expectNoProblems, 0); - 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() : getC99Language(); - - String fileName = file.getLocation().toOSString(); - ICodeReaderFactory fileCreator = SavedCodeReaderFactory.getInstance(); - CodeReader reader = fileCreator.createCodeReaderForTranslationUnit(fileName); - return ParseHelper.parse(reader, language, scanInfo, fileCreator, expectNoProblems, true, 0, null, true); - } - - @Override - protected IASTTranslationUnit parse( IFile file, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) - throws ParserException { - return parse(file, lang, new ScannerInfo(), useGNUExtensions, expectNoProblems); - } - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.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 deleted file mode 100644 index c5ffa32c1cd..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRSemanticsTests.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others All rights reserved. This - * program and the accompanying materials are made available under the terms of - * the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation - ******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.SemanticsTests; -import org.eclipse.cdt.internal.core.parser.ParserException; - -@SuppressWarnings("restriction") -public class LRSemanticsTests extends SemanticsTests { - - public static TestSuite suite() { - return suite(LRSemanticsTests.class); - } - - public LRSemanticsTests() { } - public LRSemanticsTests(String name) { super(name); } - - - @SuppressWarnings("unused") - @Override - protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, - boolean expectNoProblems, boolean parseComments) throws ParserException { - ILanguage language = lang.isCPP() ? getCPPLanguage() : getC99Language(); - return ParseHelper.parse(code, language, expectNoProblems); - } - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.getDefault(); - } -} 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 deleted file mode 100644 index 1882fc7a1ed..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRTaskParserTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.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 - @SuppressWarnings("unused") - protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException { - ILanguage language = lang.isCPP() ? getCPPLanguage() : getC99Language(); - - return ParseHelper.parse(code, language, expectNoProblems); - } - - @Override - protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems, @SuppressWarnings("unused") boolean parseComments) throws ParserException { - return parse(code,lang, useGNUExtensions, expectNoProblems ); - } - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.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 deleted file mode 100644 index 4ccf6596ea0..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRTemplateTests.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.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 parseComments) throws ParserException { - ILanguage language = lang.isCPP() ? getCPPLanguage() : getC99Language(); - return ParseHelper.parse(code, language, expectNoProblems); - } - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.getDefault(); - } - -} 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 deleted file mode 100644 index 85609357d57..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRTests.java +++ /dev/null @@ -1,283 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.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.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.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, @SuppressWarnings("unused") boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException { - ILanguage language = lang.isCPP() ? getCPPLanguage() : getC99Language(); - return ParseHelper.parse(code, language, expectNoProblems); - } - - @Override - protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems, @SuppressWarnings("unused") boolean parseComments) throws ParserException { - return parse(code,lang, useGNUExtensions, expectNoProblems ); - } - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.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()); - } - - - - @Override - public void testBug93980() { // some wierd gcc extension I think - try { - super.testBug93980(); - fail(); - } catch(Throwable _) { } - } - - - @Override - public void testBug95866() { // gcc extension - try { - super.testBug95866(); - fail(); - } catch(Throwable _) { } - } - - - @Override - public void testBug80171() throws Exception { // implicit int not supported - try { - super.testBug80171(); - fail(); - } catch(Throwable _) { } - } - - - @Override - public void testBug196468_emptyArrayInitializer() { // empty array initializer is a gcc extension - try { - super.testBug196468_emptyArrayInitializer(); - fail(); - } catch(Throwable _) { } - } - - - @Override - public void testBug75340() { // not legal c99 - try { - super.testBug75340(); - fail(); - } catch(Throwable _) { } - } - - - @Override - public void test92791() { // I think the test is wrong, the second code snippet contains a redeclaration - try { - super.test92791(); - fail(); - } catch(Throwable _) { } - } - - - - @Override - public void testBug192165() { // gcc extension: typeof - try { - super.testBug192165(); - fail(); - } catch(Throwable _) { } - } - - - - @Override - public void testBug191450_attributesInBetweenPointers() { // gcc extension: attributes - try { - super.testBug191450_attributesInBetweenPointers(); - fail(); - } catch(Throwable _) { } - } - - @Override - public void testOmittedPositiveExpression_Bug212905() throws Exception { - try { - super.testOmittedPositiveExpression_Bug212905(); - fail(); - } catch(Throwable _) { } - } - - @Override - public void testRedefinedGCCKeywords_Bug226112() throws Exception { - try { - super.testRedefinedGCCKeywords_Bug226112(); - fail(); - } catch(Throwable _) { } - } - - @Override - public void testASMLabels_Bug226121() throws Exception { - try { - super.testASMLabels_Bug226121(); - fail(); - } catch(Throwable _) { } - } - - @Override - public void testCompoundStatementExpression_Bug226274() throws Exception { - try { - super.testCompoundStatementExpression_Bug226274(); - fail(); - } catch(Throwable _) { } - } - - - - // GCC extensions - @Override - public void testTypeofUnaryExpression_Bug226492() throws Exception { - try { - super.testTypeofUnaryExpression_Bug226492(); - fail(); - } catch(Throwable _) { } - } - - @Override - public void testTypeofExpression_Bug226492() throws Exception { - try { - super.testTypeofExpression_Bug226492(); - fail(); - } catch(Throwable _) { } - } - - @Override - public void testTypeofExpressionWithAttribute_Bug226492() throws Exception { - try { - super.testTypeofExpressionWithAttribute_Bug226492(); - fail(); - } catch(Throwable _) { } - } - - @Override - public void testCaseRange_Bug211882() throws Exception { - try { - super.testCaseRange_Bug211882(); - fail(); - } catch(Throwable _) { } - } - - @Override - public void testAttributeInElaboratedTypeSpecifier_Bug227085() throws Exception { - try { - super.testAttributeInElaboratedTypeSpecifier_Bug227085(); - fail(); - } catch(Throwable _) { } - } - - @Override - public void testRestrictReference_Bug227110() throws Exception { - try { - super.testRestrictReference_Bug227110(); - fail(); - } catch(Throwable _) { } - } - - @Override - public void testRedefinePtrdiff_Bug230895() throws Exception { - try { - super.testRedefinePtrdiff_Bug230895(); - fail(); - } catch(Throwable _) { } - } - - - @Override - public void testReturnTypeOfBuiltin_Bug234309() throws Exception { - try { - super.testReturnTypeOfBuiltin_Bug234309(); - fail(); - } catch(Throwable _) { } - } - -} 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 deleted file mode 100644 index 04ed8d6bc2c..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRUtilOldTests.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.AssertionFailedError; -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.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() : getC99Language(); - return ParseHelper.parse(code, language, expectNoProblems); - } - - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.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 deleted file mode 100644 index aeafe6ef149..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/LRUtilTests.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.lrparser.c99.C99Language; -import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.tests.ast2.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() : getC99Language(); - return ParseHelper.parse(code, language, expectNoProblems); - } - - - protected ILanguage getC99Language() { - return C99Language.getDefault(); - } - - protected ILanguage getCPPLanguage() { - return ISOCPPLanguage.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 deleted file mode 100644 index 8ce2fbcad4c..00000000000 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/ParseHelper.java +++ /dev/null @@ -1,187 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.lrparser.tests; - -import 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 IASTTranslationUnit parse(char[] code, ILanguage lang, boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings) { - CodeReader codeReader = new CodeReader(code); - return parse(codeReader, lang, new ScannerInfo(), null, expectNoProblems, checkBindings, expectedProblemBindings, null, expectNoProblems); - } - - public static IASTTranslationUnit parse(String code, ILanguage lang, boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings) { - return parse(code.toCharArray(), lang, expectNoProblems, checkBindings, expectedProblemBindings); - } - - public static IASTTranslationUnit parse(String code, ILanguage lang, boolean expectNoProblems) { - return parse(code, lang, expectNoProblems, false, 0); - } - - public static IASTTranslationUnit parse(String code, ILanguage lang, String[] problems) { - CodeReader codeReader = new CodeReader(code.toCharArray()); - return parse(codeReader, lang, new ScannerInfo(), null, true, true, problems.length, problems, true); - } - - - /** - * 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. - * - * @param codeReader - * @param language - * @param scanInfo - * @param fileCreator - * @param checkSyntaxProblems - * @param checkBindings - * @param expectedProblemBindings - * @param problems - * @param checkPreprocessorProblems - * @return - */ - public static IASTTranslationUnit parse(CodeReader codeReader, ILanguage language, IScannerInfo scanInfo, - ICodeReaderFactory fileCreator, boolean checkSyntaxProblems, - boolean checkBindings, int expectedProblemBindings, String[] problems, - boolean checkPreprocessorProblems) { - testsRun++; - - IASTTranslationUnit tu; - try { - tu = language.getASTTranslationUnit(codeReader, scanInfo, fileCreator, null, ParserUtil.getParserLogService()); - } catch (CoreException e) { - throw new AssertionFailedError(e.toString()); - } - - // should parse correctly first before we look at the bindings - if(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(checkPreprocessorProblems) { - if (tu.getPreprocessorProblems().length != 0) { - throw new AssertionFailedError(language.getName() + " TranslationUnit has Preprocessor Problems " ); - } - } - - // resolve all bindings - if (checkBindings) { - NameResolver res = new NameResolver(); - tu.accept( res ); - if(res.problemBindings.size() != expectedProblemBindings) - throw new AssertionFailedError("Expected " + expectedProblemBindings + " problem(s), encountered " + res.problemBindings.size()); - - if(problems != null) { - for(int i = 0; i < problems.length; i++) { - String expected = 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); - } - } - -} |