mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
JUnit-tests: ported Scanner2Tests to DOMScannerTests.
This commit is contained in:
parent
3dd82904da
commit
f71f0d74ca
5 changed files with 2536 additions and 46 deletions
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
|
@ -103,17 +104,8 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
}
|
||||
|
||||
protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems , boolean parseComments) throws ParserException {
|
||||
CodeReader codeReader = new CodeReader(code
|
||||
.toCharArray());
|
||||
ScannerInfo scannerInfo = new ScannerInfo();
|
||||
IScannerExtensionConfiguration configuration = null;
|
||||
if( lang == ParserLanguage.C )
|
||||
configuration = new GCCScannerExtensionConfiguration();
|
||||
else
|
||||
configuration = new GPPScannerExtensionConfiguration();
|
||||
IScanner scanner = new DOMScanner( codeReader, scannerInfo, ParserMode.COMPLETE_PARSE, lang, NULL_LOG, configuration, FileCodeReaderFactory.getInstance() );
|
||||
scanner.setScanComments(parseComments);
|
||||
|
||||
IScanner scanner = createScanner(new CodeReader(code.toCharArray()), lang, ParserMode.COMPLETE_PARSE,
|
||||
new ScannerInfo(), parseComments);
|
||||
ISourceCodeParser parser2 = null;
|
||||
if( lang == ParserLanguage.CPP )
|
||||
{
|
||||
|
@ -158,6 +150,18 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
return tu;
|
||||
}
|
||||
|
||||
public static IScanner createScanner(CodeReader codeReader, ParserLanguage lang, ParserMode mode,
|
||||
ScannerInfo scannerInfo, boolean parseComments) {
|
||||
IScannerExtensionConfiguration configuration = null;
|
||||
if( lang == ParserLanguage.C )
|
||||
configuration = new GCCScannerExtensionConfiguration();
|
||||
else
|
||||
configuration = new GPPScannerExtensionConfiguration();
|
||||
IScanner scanner = new DOMScanner( codeReader, scannerInfo, mode, lang, NULL_LOG, configuration, FileCodeReaderFactory.getInstance() );
|
||||
scanner.setScanComments(parseComments);
|
||||
return scanner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
*/
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Emanuel Graf (IFS)
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Emanuel Graf (IFS)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||
|
||||
|
@ -26,7 +26,8 @@ public class DOMParserTestSuite extends TestCase {
|
|||
|
||||
public static Test suite() {
|
||||
TestSuite suite= new TestSuite(ParserTestSuite.class.getName());
|
||||
suite.addTest( AST2Tests.suite() );
|
||||
suite.addTest(DOMScannerTests.suite());
|
||||
suite.addTest(AST2Tests.suite());
|
||||
suite.addTestSuite( GCCTests.class );
|
||||
suite.addTestSuite( AST2CPPTests.class );
|
||||
suite.addTest( AST2TemplateTests.suite() );
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -122,7 +122,10 @@ public class BaseTestCase extends TestCase {
|
|||
}
|
||||
}
|
||||
};
|
||||
CCorePlugin.getDefault().getLog().addLogListener(logListener);
|
||||
final CCorePlugin corePlugin = CCorePlugin.getDefault();
|
||||
if (corePlugin != null) { // if we don't run a JUnit Plugin Test
|
||||
corePlugin.getLog().addLogListener(logListener);
|
||||
}
|
||||
|
||||
Throwable testThrowable= null;
|
||||
try {
|
||||
|
@ -151,7 +154,9 @@ public class BaseTestCase extends TestCase {
|
|||
throw afe;
|
||||
}
|
||||
} finally {
|
||||
CCorePlugin.getDefault().getLog().removeLogListener(logListener);
|
||||
if (corePlugin != null) {
|
||||
corePlugin.getLog().removeLogListener(logListener);
|
||||
}
|
||||
}
|
||||
|
||||
if(testThrowable!=null)
|
||||
|
|
|
@ -1832,21 +1832,20 @@ abstract class BaseScanner implements IScanner {
|
|||
start = bufferPos[bufferStackPos] + 1;
|
||||
length = 0;
|
||||
boolean escaped = false;
|
||||
while (++bufferPos[bufferStackPos] < limit) {
|
||||
++length;
|
||||
for (length=0; ++bufferPos[bufferStackPos] < limit; length++) {
|
||||
c = buffer[bufferPos[bufferStackPos]];
|
||||
if (c == '"') {
|
||||
if (!escaped)
|
||||
if (!escaped) {
|
||||
filename = new String(buffer, start, length);
|
||||
break;
|
||||
}
|
||||
} else if (c == '\\') {
|
||||
escaped = !escaped;
|
||||
continue;
|
||||
}
|
||||
escaped = false;
|
||||
}
|
||||
--length;
|
||||
|
||||
filename = new String(buffer, start, length);
|
||||
nameOffset = start;
|
||||
nameEndOffset = start + length;
|
||||
endOffset = start + length + 1;
|
||||
|
@ -1855,16 +1854,16 @@ abstract class BaseScanner implements IScanner {
|
|||
nameLine = getLineNumber(bufferPos[bufferStackPos]);
|
||||
local = false;
|
||||
start = bufferPos[bufferStackPos] + 1;
|
||||
length = 0;
|
||||
|
||||
while (++bufferPos[bufferStackPos] < limit
|
||||
&& buffer[bufferPos[bufferStackPos]] != '>')
|
||||
++length;
|
||||
for (length=0; ++bufferPos[bufferStackPos] < limit; length++) {
|
||||
if (buffer[bufferPos[bufferStackPos]] == '>') {
|
||||
filename= new String(buffer, start, length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
endOffset = start + length + 1;
|
||||
nameOffset = start;
|
||||
nameEndOffset = start + length;
|
||||
|
||||
filename = new String(buffer, start, length);
|
||||
break;
|
||||
default:
|
||||
// handle macro expansions
|
||||
|
@ -2260,8 +2259,13 @@ abstract class BaseScanner implements IScanner {
|
|||
int currarg = -1;
|
||||
while (bufferPos[bufferStackPos] < limit) {
|
||||
skipOverWhiteSpace();
|
||||
if (++bufferPos[bufferStackPos] >= limit)
|
||||
if (++bufferPos[bufferStackPos] >= limit) {
|
||||
if (reportProblems) {
|
||||
handleProblem(IProblem.PREPROCESSOR_INVALID_MACRO_DEFN,
|
||||
idstart, name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
c = buffer[bufferPos[bufferStackPos]];
|
||||
int argstart = bufferPos[bufferStackPos];
|
||||
if (c == ')') {
|
||||
|
|
Loading…
Add table
Reference in a new issue