1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Test case for bug 259460.

This commit is contained in:
Sergey Prigogin 2008-12-22 01:39:25 +00:00
parent 12982b88e7
commit 46ab6162f7
2 changed files with 33 additions and 44 deletions

View file

@ -6284,7 +6284,7 @@ public class AST2CPPTests extends AST2BaseTest {
// } // }
// struct B {}; // struct B {};
// }; // };
public void _testClassMemberScope_259460() throws Exception { public void _testScopeOfClassMember_259460() throws Exception {
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP); parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP);
} }
} }

View file

@ -75,7 +75,6 @@ public class AST2SpecBaseTest extends AST2BaseTest {
return parse(code, lang, false, true, true, problems.length, problems); return parse(code, lang, false, true, true, problems.length, problems);
} }
private IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems, private IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems,
boolean checkBindings, int expectedProblemBindings, String[] problems) throws ParserException { boolean checkBindings, int expectedProblemBindings, String[] problems) throws ParserException {
// TODO beef this up with tests... i.e. run once with \n, and then run again with \r\n replacing \n ... etc // TODO beef this up with tests... i.e. run once with \n, and then run again with \r\n replacing \n ... etc
@ -98,25 +97,21 @@ public class AST2SpecBaseTest extends AST2BaseTest {
// return parse(codeReader, lang, useGNUExtensions, expectNoProblems); // return parse(codeReader, lang, useGNUExtensions, expectNoProblems);
// } // }
private IASTTranslationUnit parse(CodeReader codeReader, ParserLanguage lang, boolean useGNUExtensions, private IASTTranslationUnit parse(CodeReader codeReader, ParserLanguage lang,
boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings, String[] problems) throws ParserException { boolean useGNUExtensions, boolean expectNoProblems, boolean checkBindings,
int expectedProblemBindings, String[] problems) throws ParserException {
ScannerInfo scannerInfo = new ScannerInfo(); ScannerInfo scannerInfo = new ScannerInfo();
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
ISourceCodeParser parser2 = null; ISourceCodeParser parser2 = null;
if( lang == ParserLanguage.CPP ) if (lang == ParserLanguage.CPP) {
{
ICPPParserExtensionConfiguration config = null; ICPPParserExtensionConfiguration config = null;
if (useGNUExtensions) if (useGNUExtensions)
config = new GPPParserExtensionConfiguration(); config = new GPPParserExtensionConfiguration();
else else
config = new ANSICPPParserExtensionConfiguration(); config = new ANSICPPParserExtensionConfiguration();
parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
NULL_LOG, } else {
config );
}
else
{
ICParserExtensionConfiguration config = null; ICParserExtensionConfiguration config = null;
if (useGNUExtensions) if (useGNUExtensions)
@ -138,7 +133,8 @@ public class AST2SpecBaseTest extends AST2BaseTest {
NameResolver res = new NameResolver(); NameResolver res = new NameResolver();
tu.accept(res); tu.accept(res);
if (res.problemBindings.size() != expectedProblemBindings) if (res.problemBindings.size() != expectedProblemBindings)
throw new ParserException("Expected " + expectedProblemBindings + " problems, encountered " + res.problemBindings.size() ); throw new ParserException("Expected " + expectedProblemBindings +
" problems, encountered " + res.problemBindings.size());
if (problems != null) { if (problems != null) {
for (int i = 0; i < problems.length; i++) { for (int i = 0; i < problems.length; i++) {
assertEquals(problems[i], res.problemBindings.get(i)); assertEquals(problems[i], res.problemBindings.get(i));
@ -149,17 +145,14 @@ public class AST2SpecBaseTest extends AST2BaseTest {
if (parser2.encounteredError() && expectNoProblems) if (parser2.encounteredError() && expectNoProblems)
throw new ParserException("FAILURE"); throw new ParserException("FAILURE");
if( lang == ParserLanguage.C && expectNoProblems ) if (lang == ParserLanguage.C && expectNoProblems) {
{
if (CVisitor.getProblems(tu).length != 0) { if (CVisitor.getProblems(tu).length != 0) {
throw new ParserException("CVisitor has AST Problems"); throw new ParserException("CVisitor has AST Problems");
} }
if (tu.getPreprocessorProblems().length != 0) { if (tu.getPreprocessorProblems().length != 0) {
throw new ParserException("C TranslationUnit has Preprocessor Problems"); throw new ParserException("C TranslationUnit has Preprocessor Problems");
} }
} } else if (lang == ParserLanguage.CPP && expectNoProblems) {
else if ( lang == ParserLanguage.CPP && expectNoProblems )
{
if (CPPVisitor.getProblems(tu).length != 0) { if (CPPVisitor.getProblems(tu).length != 0) {
throw new ParserException("CPPVisitor has AST Problems"); throw new ParserException("CPPVisitor has AST Problems");
} }
@ -171,8 +164,6 @@ public class AST2SpecBaseTest extends AST2BaseTest {
return tu; return tu;
} }
static protected class NameResolver extends ASTVisitor { static protected class NameResolver extends ASTVisitor {
{ {
shouldVisitNames = true; shouldVisitNames = true;
@ -182,7 +173,6 @@ public class AST2SpecBaseTest extends AST2BaseTest {
public List<String> problemBindings = new ArrayList<String>(); public List<String> problemBindings = new ArrayList<String>();
public int numNullBindings = 0; public int numNullBindings = 0;
@Override @Override
public int visit(IASTName name) { public int visit(IASTName name) {
nameList.add(name); nameList.add(name);
@ -204,5 +194,4 @@ public class AST2SpecBaseTest extends AST2BaseTest {
return nameList.size(); return nameList.size();
} }
} }
} }