mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Andrew Niefer.
This patch creates a new failing test class : FullParseFailedTests. This is for writing failed tests on the parser doing COMPLETE_PARSE. The first failed test is for bug 40842 "Parser: NPE while parsing class declaration in full parse mode"
This commit is contained in:
parent
30f7903424
commit
d84488d695
4 changed files with 70 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2003-07-28 Andrew Niefer
|
||||||
|
This patch creates a new failing test class : FullParseFailedTests. This
|
||||||
|
is for writing failed tests on the parser doing COMPLETE_PARSE.
|
||||||
|
|
||||||
2003-07-28 Victor Mozgin
|
2003-07-28 Victor Mozgin
|
||||||
Moved testBug39537() from ASTFailedTests.java to QuickParseASTTests.java.
|
Moved testBug39537() from ASTFailedTests.java to QuickParseASTTests.java.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2003 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Corp. - Rational Software - initial implementation
|
||||||
|
******************************************************************************/
|
||||||
|
/*
|
||||||
|
* Created on Jul 28, 2003
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.core.parser.failedTests;
|
||||||
|
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.io.Writer;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.tests.BaseASTTest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author aniefer
|
||||||
|
*
|
||||||
|
* To change the template for this generated type comment go to
|
||||||
|
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||||
|
*/
|
||||||
|
public class FullParseFailedTests extends BaseASTTest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param a
|
||||||
|
*/
|
||||||
|
public FullParseFailedTests(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBug40842() throws Exception{
|
||||||
|
Writer code = new StringWriter();
|
||||||
|
|
||||||
|
//note that if the parse fails at EOF, parse.failParse never sets
|
||||||
|
//parsePassed = false because it will throw EOF on LA(1), so get
|
||||||
|
//around this by adding more code after the error.
|
||||||
|
code.write("class A {} a;\n int x;");
|
||||||
|
assertCodeFailsFullParse(code.toString());
|
||||||
|
}
|
||||||
|
}
|
|
@ -57,6 +57,11 @@ public class BaseASTTest extends TestCase
|
||||||
return parse( code, true, true );
|
return parse( code, true, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IASTCompilationUnit fullParse( String code ) throws ParserException
|
||||||
|
{
|
||||||
|
return parse( code, false, true );
|
||||||
|
}
|
||||||
|
|
||||||
protected IASTDeclaration assertSoleDeclaration( String code ) throws ParserException
|
protected IASTDeclaration assertSoleDeclaration( String code ) throws ParserException
|
||||||
{
|
{
|
||||||
Iterator declarationIter = null;
|
Iterator declarationIter = null;
|
||||||
|
@ -96,6 +101,20 @@ public class BaseASTTest extends TestCase
|
||||||
fail("The expected error did not occur.");
|
fail("The expected error did not occur.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void assertCodeFailsFullParse(String code) {
|
||||||
|
boolean testPassed = false;
|
||||||
|
try {
|
||||||
|
IASTCompilationUnit tu = fullParse(code);
|
||||||
|
testPassed = true;
|
||||||
|
fail( "We should not reach this point");
|
||||||
|
} catch (Throwable e) {
|
||||||
|
if (!(e instanceof ParserException))
|
||||||
|
fail("Unexpected Error: " + e.getMessage());
|
||||||
|
}
|
||||||
|
if (testPassed)
|
||||||
|
fail("The expected error did not occur.");
|
||||||
|
}
|
||||||
|
|
||||||
protected void assertSimpleReturnType(IASTFunction function, IASTSimpleTypeSpecifier.Type type)
|
protected void assertSimpleReturnType(IASTFunction function, IASTSimpleTypeSpecifier.Type type)
|
||||||
{
|
{
|
||||||
assertEquals( ((IASTSimpleTypeSpecifier)function.getReturnType().getTypeSpecifier()).getType(), type );
|
assertEquals( ((IASTSimpleTypeSpecifier)function.getReturnType().getTypeSpecifier()).getType(), type );
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.model.tests.BinaryTests;
|
||||||
import org.eclipse.cdt.core.model.tests.ElementDeltaTests;
|
import org.eclipse.cdt.core.model.tests.ElementDeltaTests;
|
||||||
import org.eclipse.cdt.core.model.tests.WorkingCopyTests;
|
import org.eclipse.cdt.core.model.tests.WorkingCopyTests;
|
||||||
import org.eclipse.cdt.core.parser.failedTests.ASTFailedTests;
|
import org.eclipse.cdt.core.parser.failedTests.ASTFailedTests;
|
||||||
|
import org.eclipse.cdt.core.parser.failedTests.FullParseFailedTests;
|
||||||
import org.eclipse.cdt.core.parser.failedTests.LokiFailures;
|
import org.eclipse.cdt.core.parser.failedTests.LokiFailures;
|
||||||
import org.eclipse.cdt.core.parser.failedTests.STLFailedTests;
|
import org.eclipse.cdt.core.parser.failedTests.STLFailedTests;
|
||||||
import org.eclipse.cdt.core.parser.tests.ParserTestSuite;
|
import org.eclipse.cdt.core.parser.tests.ParserTestSuite;
|
||||||
|
@ -97,6 +98,7 @@ public class AutomatedIntegrationSuite extends TestSuite
|
||||||
suite.addTestSuite(LokiFailures.class);
|
suite.addTestSuite(LokiFailures.class);
|
||||||
suite.addTestSuite(STLFailedTests.class);
|
suite.addTestSuite(STLFailedTests.class);
|
||||||
suite.addTestSuite(CModelElementsFailedTests.class);
|
suite.addTestSuite(CModelElementsFailedTests.class);
|
||||||
|
suite.addTestSuite(FullParseFailedTests.class);
|
||||||
|
|
||||||
// Last test to trigger report generation
|
// Last test to trigger report generation
|
||||||
suite.addTest(suite.new GenerateReport("generateReport"));
|
suite.addTest(suite.new GenerateReport("generateReport"));
|
||||||
|
|
Loading…
Add table
Reference in a new issue