MethodTypeInsertTest angefügt. TypeInsertTester verbessert

This commit is contained in:
JanUlrich 2014-03-09 14:12:48 +01:00
parent c5eb3a5711
commit eef38bff42
5 changed files with 26 additions and 4 deletions

View File

@ -679,7 +679,8 @@ public class SourceFile
}
//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
result.addAll(unifyResult);

View File

@ -51,7 +51,7 @@ import typinferenz.assumptions.TypeAssumptions;
* @author janulrich
*
*/
public class Method extends Field implements ITypeReplacementListener, IItemWithOffset, TypeInsertable
public class Method extends Field implements IItemWithOffset, TypeInsertable
// ino.end
// ino.class.Method.23482.body
{

View File

@ -231,7 +231,7 @@ public class MethodCall extends Expr
}
Vector<CParaTypeAssumption> paraAssumptions=assumption.getParaAssumptions();
Type returnType=assumption.getAssumedType();
Method meth=new Method();
Method meth=new Method(0);
Vector<FormalParameter> parameterVector=new Vector<FormalParameter>();
ParameterList pl=new ParameterList();
for(int i=0;i<paraAssumptions.size();i++){

View File

@ -10,7 +10,7 @@ import java.util.Vector;
*/
public class TypeInsertSet {
Vector<TypeInsertPoint> points = new Vector<TypeInsertPoint>();
public Vector<TypeInsertPoint> points = new Vector<TypeInsertPoint>();
public TypeInsertSet(TypeInsertPoint p){
points.add(p);

View File

@ -10,17 +10,35 @@ import java.nio.file.Files;
import java.nio.file.Paths;
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.TypeInsertSet;
import junit.framework.TestCase;
import mycompiler.MyCompiler;
import mycompiler.MyCompilerAPI;
import mycompiler.myparser.JavaParser.yyException;
import mycompiler.mytest.LambdaTest;
import mycompiler.mytypereconstruction.TypeinferenceResultSet;
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/";
public static void test(String sourceFileToInfere, String solutionFile){
@ -34,10 +52,12 @@ public class TypeInsertTester{
Vector<TypeInsertSet> points = result.getTypeInsertionPoints();
TestCase.assertTrue("Es muss mindestens ein TypeInsertSet vorhanden sein", points.size()>0);
for(TypeInsertSet point : points){
if(point.points.size()>0){
inferedSource = point.insertAllTypes(getFileContent(rootDirectory + sourceFileToInfere));
String solutionSource = getFileContent(rootDirectory + solutionFile);
System.out.println("\nInferierter Source:\n"+inferedSource);
TestCase.assertTrue("Nicht das erwartete Ergebnis", inferedSource.equals(solutionSource));
}
}
}
@ -53,4 +73,5 @@ public class TypeInsertTester{
byte[] encoded = Files.readAllBytes(Paths.get(path));
return StandardCharsets.UTF_8.decode(ByteBuffer.wrap(encoded)).toString();
}
}