forked from JavaTX/JavaCompilerCore
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:
|
||||
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);
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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++){
|
||||
|
@ -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);
|
||||
|
@ -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,12 +52,14 @@ 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException | yyException e) {
|
||||
e.printStackTrace();
|
||||
@ -53,4 +73,5 @@ public class TypeInsertTester{
|
||||
byte[] encoded = Files.readAllBytes(Paths.get(path));
|
||||
return StandardCharsets.UTF_8.decode(ByteBuffer.wrap(encoded)).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user