mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Factor out an AST2CPPTestBase base class for C++ AST2 tests
Change-Id: I923fa1559a0cca584ff3a601d59ac71c0e491c49
This commit is contained in:
parent
7f8440b6b2
commit
9aa8aca96b
4 changed files with 41 additions and 39 deletions
|
@ -0,0 +1,37 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2017 Nathan Ridge.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||||
|
|
||||||
|
import static org.eclipse.cdt.core.parser.ParserLanguage.CPP;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
|
||||||
|
public class AST2CPPTestBase extends AST2TestBase {
|
||||||
|
public AST2CPPTestBase() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public AST2CPPTestBase(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception {
|
||||||
|
return parseAndCheckBindings(code, CPP);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IASTTranslationUnit parseAndCheckBindings() throws Exception {
|
||||||
|
String code= getAboveComment();
|
||||||
|
return parseAndCheckBindings(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BindingAssertionHelper getAssertionHelper() throws ParserException, IOException {
|
||||||
|
return getAssertionHelper(CPP);
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,7 +25,6 @@ import static org.eclipse.cdt.core.parser.tests.VisibilityAsserts.assertVisibili
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -159,7 +158,7 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
public class AST2CPPTests extends AST2TestBase {
|
public class AST2CPPTests extends AST2CPPTestBase {
|
||||||
|
|
||||||
public AST2CPPTests() {
|
public AST2CPPTests() {
|
||||||
}
|
}
|
||||||
|
@ -172,19 +171,6 @@ public class AST2CPPTests extends AST2TestBase {
|
||||||
return suite(AST2CPPTests.class);
|
return suite(AST2CPPTests.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception {
|
|
||||||
return parseAndCheckBindings(code, CPP);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IASTTranslationUnit parseAndCheckBindings() throws Exception {
|
|
||||||
String code= getAboveComment();
|
|
||||||
return parseAndCheckBindings(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected BindingAssertionHelper getAssertionHelper() throws ParserException, IOException {
|
|
||||||
return getAssertionHelper(CPP);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertProblemBinding(int id, IBinding b) {
|
private void assertProblemBinding(int id, IBinding b) {
|
||||||
assertTrue(b instanceof IProblemBinding);
|
assertTrue(b instanceof IProblemBinding);
|
||||||
assertEquals(id, ((IProblemBinding) b).getID());
|
assertEquals(id, ((IProblemBinding) b).getID());
|
||||||
|
|
|
@ -24,8 +24,6 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUti
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateType;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateType;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.IName;
|
import org.eclipse.cdt.core.dom.IName;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||||
|
@ -103,11 +101,10 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
public class AST2TemplateTests extends AST2TestBase {
|
public class AST2TemplateTests extends AST2CPPTestBase {
|
||||||
|
|
||||||
public AST2TemplateTests() {
|
public AST2TemplateTests() {
|
||||||
}
|
}
|
||||||
|
@ -120,19 +117,6 @@ public class AST2TemplateTests extends AST2TestBase {
|
||||||
return suite(AST2TemplateTests.class);
|
return suite(AST2TemplateTests.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTTranslationUnit parseAndCheckBindings() throws Exception {
|
|
||||||
return parseAndCheckBindings(getAboveComment());
|
|
||||||
}
|
|
||||||
|
|
||||||
private IASTTranslationUnit parseAndCheckBindings(final String code) throws Exception {
|
|
||||||
return parseAndCheckBindings(code, CPP);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected BindingAssertionHelper getAssertionHelper() throws ParserException, IOException {
|
|
||||||
String code= getAboveComment();
|
|
||||||
return new AST2AssertionHelper(code, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private NameCollector getNameCollector(IASTTranslationUnit ast) {
|
private NameCollector getNameCollector(IASTTranslationUnit ast) {
|
||||||
NameCollector collector = new NameCollector();
|
NameCollector collector = new NameCollector();
|
||||||
ast.accept(collector);
|
ast.accept(collector);
|
||||||
|
|
|
@ -10,19 +10,14 @@ package org.eclipse.cdt.core.parser.tests.ast2.cxx14;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemType;
|
import org.eclipse.cdt.core.dom.ast.IProblemType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.tests.ast2.AST2CPPTestBase;
|
||||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2TestBase;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClosureType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClosureType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||||
|
|
||||||
public class ReturnTypeDeductionTests extends AST2TestBase {
|
public class ReturnTypeDeductionTests extends AST2CPPTestBase {
|
||||||
private BindingAssertionHelper getAssertionHelper() throws Exception {
|
|
||||||
return getAssertionHelper(ParserLanguage.CPP);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertReturnType(String functionName, IType returnType) throws Exception {
|
private void assertReturnType(String functionName, IType returnType) throws Exception {
|
||||||
BindingAssertionHelper bh = getAssertionHelper();
|
BindingAssertionHelper bh = getAssertionHelper();
|
||||||
ICPPFunction f = bh.assertNonProblem(functionName);
|
ICPPFunction f = bh.assertNonProblem(functionName);
|
||||||
|
|
Loading…
Add table
Reference in a new issue