diff --git a/src/mycompiler/SourceFile.java b/src/mycompiler/SourceFile.java index bd87e32d8..8f148b8d6 100755 --- a/src/mycompiler/SourceFile.java +++ b/src/mycompiler/SourceFile.java @@ -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 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); diff --git a/src/mycompiler/mytypereconstruction/TypeinferenceResultSet.java b/src/mycompiler/mytypereconstruction/TypeinferenceResultSet.java index 5a6cb72c7..933e89853 100755 --- a/src/mycompiler/mytypereconstruction/TypeinferenceResultSet.java +++ b/src/mycompiler/mytypereconstruction/TypeinferenceResultSet.java @@ -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 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 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 unifiedConstraints) { - this.unifiedConstraints = new ResultSet(unifiedConstraints); - } /** * Ermittelt den in diesem ResultSet für den TypePlaceholder tph zugewiesenen Wert. diff --git a/test/plugindevelopment/MethodTypeInsertTest.jav b/test/plugindevelopment/MethodTypeInsertTest.jav new file mode 100644 index 000000000..03b20bc8f --- /dev/null +++ b/test/plugindevelopment/MethodTypeInsertTest.jav @@ -0,0 +1,6 @@ + +class VariableTypeInsertTest{ + methode(){ + return "String"; + } +} diff --git a/test/plugindevelopment/MethodTypeInsertTest.java b/test/plugindevelopment/MethodTypeInsertTest.java new file mode 100644 index 000000000..cf9c5aef0 --- /dev/null +++ b/test/plugindevelopment/MethodTypeInsertTest.java @@ -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); + } + +} diff --git a/test/plugindevelopment/MethodTypeInsertTestSolution.jav b/test/plugindevelopment/MethodTypeInsertTestSolution.jav new file mode 100644 index 000000000..4246f9536 --- /dev/null +++ b/test/plugindevelopment/MethodTypeInsertTestSolution.jav @@ -0,0 +1,6 @@ + +class VariableTypeInsertTest{ + String methode(){ + return "String"; + } +} diff --git a/test/plugindevelopment/TypeInsertTester.java b/test/plugindevelopment/TypeInsertTester.java index 644c970d7..f49a3292a 100644 --- a/test/plugindevelopment/TypeInsertTester.java +++ b/test/plugindevelopment/TypeInsertTester.java @@ -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 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 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(); } }