forked from JavaTX/JavaCompilerCore
MethodTypeInsertTest angefügt
This commit is contained in:
parent
4786345f7b
commit
c5eb3a5711
@ -42,6 +42,7 @@ import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import sun.reflect.generics.reflectiveObjects.TypeVariableImpl;
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.FunN;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.UndConstraint;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
@ -713,9 +714,7 @@ public class SourceFile
|
||||
//Der Unifikationsalgorithmus kann wiederum auch mehrere Lösungen errechnen, diese werden im folgenden durchlaufen:
|
||||
for(Vector<Pair> resultSet : result){
|
||||
//Add Result set as a new ReconstructionResult to ret:
|
||||
TypeinferenceResultSet reconstructionResult = new TypeinferenceResultSet(klasse);
|
||||
reconstructionResult.setConstraints(constraints);
|
||||
reconstructionResult.setUnifiedConstraints(resultSet);
|
||||
TypeinferenceResultSet reconstructionResult = new TypeinferenceResultSet(klasse, constraints, new ResultSet(resultSet));
|
||||
ret.add(reconstructionResult);
|
||||
|
||||
//ResultSet res = new ResultSet(resultSet);
|
||||
|
@ -53,12 +53,13 @@ public class TypeinferenceResultSet
|
||||
private mycompiler.myclass.Class ownerOfResultSet;//Jedes Resultset gilt immer nur für eine Klasse. Diese wird in dieser Variable gespeichert.
|
||||
|
||||
// ino.method.CTypeReconstructionResult.27256.definition
|
||||
public TypeinferenceResultSet(mycompiler.myclass.Class inferedClass)
|
||||
public TypeinferenceResultSet(mycompiler.myclass.Class inferedClass, Vector<Pair> constraints, ResultSet unifiedConstraints)
|
||||
// ino.end
|
||||
// ino.method.CTypeReconstructionResult.27256.body
|
||||
{
|
||||
this.ownerOfResultSet = inferedClass;
|
||||
|
||||
this.constraints = constraints;
|
||||
this.unifiedConstraints = unifiedConstraints;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@ -74,10 +75,6 @@ public class TypeinferenceResultSet
|
||||
}
|
||||
|
||||
|
||||
public void setConstraints(Vector<Pair> constraints) {
|
||||
this.constraints = constraints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Andreas Stadelmeier, a10023
|
||||
* Nach dem Durchführen des Interferenzalgorithmus von Lambda 8 entsteht für jede Lösung ein Set con Constraints.
|
||||
@ -88,9 +85,6 @@ public class TypeinferenceResultSet
|
||||
return unifiedConstraints;
|
||||
}
|
||||
|
||||
public void setUnifiedConstraints(Vector<Pair> unifiedConstraints) {
|
||||
this.unifiedConstraints = new ResultSet(unifiedConstraints);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ermittelt den in diesem ResultSet für den TypePlaceholder tph zugewiesenen Wert.
|
||||
|
6
test/plugindevelopment/MethodTypeInsertTest.jav
Normal file
6
test/plugindevelopment/MethodTypeInsertTest.jav
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
class VariableTypeInsertTest{
|
||||
methode(){
|
||||
return "String";
|
||||
}
|
||||
}
|
16
test/plugindevelopment/MethodTypeInsertTest.java
Normal file
16
test/plugindevelopment/MethodTypeInsertTest.java
Normal file
@ -0,0 +1,16 @@
|
||||
package plugindevelopment;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class MethodTypeInsertTest {
|
||||
|
||||
|
||||
private static final String TEST_FILE = "MethodTypeInsertTest.jav";
|
||||
private static final String SOLUTION_FILE = "MethodTypeInsertTestSolution.jav";
|
||||
|
||||
@Test
|
||||
public void run(){
|
||||
TypeInsertTester.test(this.TEST_FILE, this.SOLUTION_FILE);
|
||||
}
|
||||
|
||||
}
|
6
test/plugindevelopment/MethodTypeInsertTestSolution.jav
Normal file
6
test/plugindevelopment/MethodTypeInsertTestSolution.jav
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
class VariableTypeInsertTest{
|
||||
String methode(){
|
||||
return "String";
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ import mycompiler.myparser.JavaParser.yyException;
|
||||
import mycompiler.mytypereconstruction.TypeinferenceResultSet;
|
||||
|
||||
|
||||
public class TypeInsertTester extends TestCase {
|
||||
public class TypeInsertTester{
|
||||
|
||||
private static final String rootDirectory = System.getProperty("user.dir")+"/test/plugindevelopment/";
|
||||
|
||||
@ -29,21 +29,21 @@ public class TypeInsertTester extends TestCase {
|
||||
try {
|
||||
compiler.parse(new File(rootDirectory + sourceFileToInfere));
|
||||
Vector<TypeinferenceResultSet> results = compiler.typeReconstruction();
|
||||
assertTrue("Es darf nicht mehr als eine Lösungsmöglichkeit geben", results.size()==1);
|
||||
TestCase.assertTrue("Es darf nicht mehr als eine Lösungsmöglichkeit geben", results.size()==1);
|
||||
for(TypeinferenceResultSet result : results){
|
||||
Vector<TypeInsertSet> points = result.getTypeInsertionPoints();
|
||||
assertTrue("Es muss genau ein TypeInsertSet vorhanden sein", points.size()==1);
|
||||
TestCase.assertTrue("Es muss mindestens ein TypeInsertSet vorhanden sein", points.size()>0);
|
||||
for(TypeInsertSet point : points){
|
||||
inferedSource = point.insertAllTypes(getFileContent(rootDirectory + sourceFileToInfere));
|
||||
String solutionSource = getFileContent(rootDirectory + solutionFile);
|
||||
System.out.println("\nInferierter Source:\n"+inferedSource);
|
||||
assertTrue("Nicht das erwartete Ergebnis", inferedSource.equals(solutionSource));
|
||||
TestCase.assertTrue("Nicht das erwartete Ergebnis", inferedSource.equals(solutionSource));
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException | yyException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
TestCase.fail();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user