MethodTypeInsertTest angefügt. TypeInsertTester verbessert
This commit is contained in:
parent
c5eb3a5711
commit
eef38bff42
@ -679,7 +679,8 @@ public class SourceFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Erst die Unifizierung erstellen:
|
//Erst die Unifizierung erstellen:
|
||||||
Vector<Vector<Pair>> unifyResult = Unify.unify(constraints, finiteClosure);
|
Vector<Pair> constraintsClone = (Vector<Pair>)constraints.clone();
|
||||||
|
Vector<Vector<Pair>> unifyResult = Unify.unify(constraintsClone, finiteClosure);
|
||||||
//Dann den Ergebnissen anfügen
|
//Dann den Ergebnissen anfügen
|
||||||
result.addAll(unifyResult);
|
result.addAll(unifyResult);
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ import typinferenz.assumptions.TypeAssumptions;
|
|||||||
* @author janulrich
|
* @author janulrich
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Method extends Field implements ITypeReplacementListener, IItemWithOffset, TypeInsertable
|
public class Method extends Field implements IItemWithOffset, TypeInsertable
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.class.Method.23482.body
|
// ino.class.Method.23482.body
|
||||||
{
|
{
|
||||||
|
@ -231,7 +231,7 @@ public class MethodCall extends Expr
|
|||||||
}
|
}
|
||||||
Vector<CParaTypeAssumption> paraAssumptions=assumption.getParaAssumptions();
|
Vector<CParaTypeAssumption> paraAssumptions=assumption.getParaAssumptions();
|
||||||
Type returnType=assumption.getAssumedType();
|
Type returnType=assumption.getAssumedType();
|
||||||
Method meth=new Method();
|
Method meth=new Method(0);
|
||||||
Vector<FormalParameter> parameterVector=new Vector<FormalParameter>();
|
Vector<FormalParameter> parameterVector=new Vector<FormalParameter>();
|
||||||
ParameterList pl=new ParameterList();
|
ParameterList pl=new ParameterList();
|
||||||
for(int i=0;i<paraAssumptions.size();i++){
|
for(int i=0;i<paraAssumptions.size();i++){
|
||||||
|
@ -10,7 +10,7 @@ import java.util.Vector;
|
|||||||
*/
|
*/
|
||||||
public class TypeInsertSet {
|
public class TypeInsertSet {
|
||||||
|
|
||||||
Vector<TypeInsertPoint> points = new Vector<TypeInsertPoint>();
|
public Vector<TypeInsertPoint> points = new Vector<TypeInsertPoint>();
|
||||||
|
|
||||||
public TypeInsertSet(TypeInsertPoint p){
|
public TypeInsertSet(TypeInsertPoint p){
|
||||||
points.add(p);
|
points.add(p);
|
||||||
|
@ -10,17 +10,35 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.apache.log4j.ConsoleAppender;
|
||||||
|
import org.apache.log4j.FileAppender;
|
||||||
|
import org.apache.log4j.Level;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.apache.log4j.PatternLayout;
|
||||||
|
import org.apache.log4j.SimpleLayout;
|
||||||
|
|
||||||
import typinferenz.TypeInsertPoint;
|
import typinferenz.TypeInsertPoint;
|
||||||
import typinferenz.TypeInsertSet;
|
import typinferenz.TypeInsertSet;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import mycompiler.MyCompiler;
|
import mycompiler.MyCompiler;
|
||||||
import mycompiler.MyCompilerAPI;
|
import mycompiler.MyCompilerAPI;
|
||||||
import mycompiler.myparser.JavaParser.yyException;
|
import mycompiler.myparser.JavaParser.yyException;
|
||||||
|
import mycompiler.mytest.LambdaTest;
|
||||||
import mycompiler.mytypereconstruction.TypeinferenceResultSet;
|
import mycompiler.mytypereconstruction.TypeinferenceResultSet;
|
||||||
|
|
||||||
|
|
||||||
public class TypeInsertTester{
|
public class TypeInsertTester{
|
||||||
|
|
||||||
|
private static Logger inferencelog = Logger.getLogger("Typeinference");
|
||||||
|
static{
|
||||||
|
{
|
||||||
|
// Ausgabeoptionen fuer die Logger
|
||||||
|
ConsoleAppender logAppender = new ConsoleAppender(new SimpleLayout());
|
||||||
|
logAppender.setTarget("System.out");
|
||||||
|
logAppender.activateOptions();
|
||||||
|
inferencelog.addAppender(logAppender); //Bei den Tests wird der Log auch in System.out geschrieben.
|
||||||
|
}
|
||||||
|
}
|
||||||
private static final String rootDirectory = System.getProperty("user.dir")+"/test/plugindevelopment/";
|
private static final String rootDirectory = System.getProperty("user.dir")+"/test/plugindevelopment/";
|
||||||
|
|
||||||
public static void test(String sourceFileToInfere, String solutionFile){
|
public static void test(String sourceFileToInfere, String solutionFile){
|
||||||
@ -34,10 +52,12 @@ public class TypeInsertTester{
|
|||||||
Vector<TypeInsertSet> points = result.getTypeInsertionPoints();
|
Vector<TypeInsertSet> points = result.getTypeInsertionPoints();
|
||||||
TestCase.assertTrue("Es muss mindestens ein TypeInsertSet vorhanden sein", points.size()>0);
|
TestCase.assertTrue("Es muss mindestens ein TypeInsertSet vorhanden sein", points.size()>0);
|
||||||
for(TypeInsertSet point : points){
|
for(TypeInsertSet point : points){
|
||||||
|
if(point.points.size()>0){
|
||||||
inferedSource = point.insertAllTypes(getFileContent(rootDirectory + sourceFileToInfere));
|
inferedSource = point.insertAllTypes(getFileContent(rootDirectory + sourceFileToInfere));
|
||||||
String solutionSource = getFileContent(rootDirectory + solutionFile);
|
String solutionSource = getFileContent(rootDirectory + solutionFile);
|
||||||
System.out.println("\nInferierter Source:\n"+inferedSource);
|
System.out.println("\nInferierter Source:\n"+inferedSource);
|
||||||
TestCase.assertTrue("Nicht das erwartete Ergebnis", inferedSource.equals(solutionSource));
|
TestCase.assertTrue("Nicht das erwartete Ergebnis", inferedSource.equals(solutionSource));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,4 +73,5 @@ public class TypeInsertTester{
|
|||||||
byte[] encoded = Files.readAllBytes(Paths.get(path));
|
byte[] encoded = Files.readAllBytes(Paths.get(path));
|
||||||
return StandardCharsets.UTF_8.decode(ByteBuffer.wrap(encoded)).toString();
|
return StandardCharsets.UTF_8.decode(ByteBuffer.wrap(encoded)).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user