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:
parent
12982b88e7
commit
46ab6162f7
2 changed files with 33 additions and 44 deletions
|
@ -6284,7 +6284,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
// }
|
||||
// struct B {};
|
||||
// };
|
||||
public void _testClassMemberScope_259460() throws Exception {
|
||||
public void _testScopeOfClassMember_259460() throws Exception {
|
||||
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,6 @@ public class AST2SpecBaseTest extends AST2BaseTest {
|
|||
return parse(code, lang, false, true, true, problems.length, problems);
|
||||
}
|
||||
|
||||
|
||||
private IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems,
|
||||
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
|
||||
|
@ -98,25 +97,21 @@ public class AST2SpecBaseTest extends AST2BaseTest {
|
|||
// return parse(codeReader, lang, useGNUExtensions, expectNoProblems);
|
||||
// }
|
||||
|
||||
private IASTTranslationUnit parse(CodeReader codeReader, ParserLanguage lang, boolean useGNUExtensions,
|
||||
boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings, String[] problems) throws ParserException {
|
||||
private IASTTranslationUnit parse(CodeReader codeReader, ParserLanguage lang,
|
||||
boolean useGNUExtensions, boolean expectNoProblems, boolean checkBindings,
|
||||
int expectedProblemBindings, String[] problems) throws ParserException {
|
||||
ScannerInfo scannerInfo = new ScannerInfo();
|
||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||
|
||||
ISourceCodeParser parser2 = null;
|
||||
if( lang == ParserLanguage.CPP )
|
||||
{
|
||||
if (lang == ParserLanguage.CPP) {
|
||||
ICPPParserExtensionConfiguration config = null;
|
||||
if (useGNUExtensions)
|
||||
config = new GPPParserExtensionConfiguration();
|
||||
else
|
||||
config = new ANSICPPParserExtensionConfiguration();
|
||||
parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE,
|
||||
NULL_LOG,
|
||||
config );
|
||||
}
|
||||
else
|
||||
{
|
||||
parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
|
||||
} else {
|
||||
ICParserExtensionConfiguration config = null;
|
||||
|
||||
if (useGNUExtensions)
|
||||
|
@ -138,7 +133,8 @@ public class AST2SpecBaseTest extends AST2BaseTest {
|
|||
NameResolver res = new NameResolver();
|
||||
tu.accept(res);
|
||||
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) {
|
||||
for (int i = 0; i < problems.length; i++) {
|
||||
assertEquals(problems[i], res.problemBindings.get(i));
|
||||
|
@ -149,17 +145,14 @@ public class AST2SpecBaseTest extends AST2BaseTest {
|
|||
if (parser2.encounteredError() && expectNoProblems)
|
||||
throw new ParserException("FAILURE");
|
||||
|
||||
if( lang == ParserLanguage.C && expectNoProblems )
|
||||
{
|
||||
if (lang == ParserLanguage.C && expectNoProblems) {
|
||||
if (CVisitor.getProblems(tu).length != 0) {
|
||||
throw new ParserException("CVisitor has AST Problems");
|
||||
}
|
||||
if (tu.getPreprocessorProblems().length != 0) {
|
||||
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) {
|
||||
throw new ParserException("CPPVisitor has AST Problems");
|
||||
}
|
||||
|
@ -171,8 +164,6 @@ public class AST2SpecBaseTest extends AST2BaseTest {
|
|||
return tu;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static protected class NameResolver extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
|
@ -182,7 +173,6 @@ public class AST2SpecBaseTest extends AST2BaseTest {
|
|||
public List<String> problemBindings = new ArrayList<String>();
|
||||
public int numNullBindings = 0;
|
||||
|
||||
|
||||
@Override
|
||||
public int visit(IASTName name) {
|
||||
nameList.add(name);
|
||||
|
@ -204,5 +194,4 @@ public class AST2SpecBaseTest extends AST2BaseTest {
|
|||
return nameList.size();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue