diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 8a4a97c12a9..5fbb69091ce 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -176,8 +176,7 @@ public class AST2CPPTests extends AST2TestBase { } protected BindingAssertionHelper getAssertionHelper() throws ParserException, IOException { - String code= getAboveComment(); - return new BindingAssertionHelper(code, true); + return getAssertionHelper(CPP); } private void assertProblemBinding(int id, IBinding b) { @@ -7843,15 +7842,6 @@ public class AST2CPPTests extends AST2TestBase { checkDeclDef(declNames, defNames, cls.getMembers()); } - // #define MACRO "macro" - // void f(const char* s); - // void test() { - // f("aaa"MACRO); - // } - public void testStringConcatenationWithMacro() throws Exception { - parseAndCheckBindings(); - } - // class X { // struct S* m1; // struct T; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java index 080384e04d4..5041b33b29f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java @@ -15,6 +15,7 @@ *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; +import static org.eclipse.cdt.core.parser.ParserLanguage.C; import static org.eclipse.cdt.core.parser.ParserLanguage.CPP; import java.io.IOException; @@ -110,6 +111,7 @@ import junit.framework.AssertionFailedError; */ public class AST2TestBase extends BaseTestCase { public final static String TEST_CODE = ""; + protected static final ParserLanguage[] C_AND_CPP = new ParserLanguage[] { C, CPP }; protected static final IParserLogService NULL_LOG = new NullLogService(); protected static boolean sValidateCopy; @@ -838,6 +840,11 @@ public class AST2TestBase extends BaseTestCase { return tu; } + protected BindingAssertionHelper getAssertionHelper(ParserLanguage lang) throws ParserException, IOException { + String code= getAboveComment(); + return new BindingAssertionHelper(code, lang); + } + final protected void assertNoProblemBindings(NameCollector col) { for (IASTName n : col.nameList) { assertFalse("ProblemBinding for " + n.getRawSignature(), n.resolveBinding() instanceof IProblemBinding); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index 74f7c14f572..6118c7794cc 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -715,6 +715,23 @@ public class AST2Tests extends AST2TestBase { } } + // #define _MACRO "macro" + // #define MACRO _MACRO + // void f(const char* s); + // void test() { + // f("aaa"MACRO); + // } + public void testStringConcatenationWithMacro() throws Exception { + for (ParserLanguage lang : C_AND_CPP) { + BindingAssertionHelper bh = getAssertionHelper(lang); + IASTName name = bh.findName("f(\"", 1); + assertNotNull(name); + IASTFunctionCallExpression call = (IASTFunctionCallExpression) name.getParent().getParent(); + IASTLiteralExpression arg = (IASTLiteralExpression) call.getArguments()[0]; + assertEquals("\"aaamacro\"", arg.toString()); + } + } + public void testStructureDef() throws Exception { StringBuffer buffer = new StringBuffer(); buffer.append("struct A; \r\n"); //$NON-NLS-1$