From c627f9de607686ff46b7f1c1b9fbc7abb821a0a1 Mon Sep 17 00:00:00 2001 From: Till Schnell Date: Sat, 10 Apr 2021 10:40:58 +0200 Subject: [PATCH] Split the single testcase to two --- .../TestInferWildcardsJavaTx.java | 25 +++++++++++++++-- .../TestClassWildcardsFields.java | 27 +++++++++++++++++++ .../TestClassWildcardsSingle.java | 20 +------------- 3 files changed, 51 insertions(+), 21 deletions(-) create mode 100644 src/test/resources/inferWildcards/TestClassWildcardsFields.java diff --git a/src/test/java/inferWildcards/TestInferWildcardsJavaTx.java b/src/test/java/inferWildcards/TestInferWildcardsJavaTx.java index d46265ed..240cd756 100644 --- a/src/test/java/inferWildcards/TestInferWildcardsJavaTx.java +++ b/src/test/java/inferWildcards/TestInferWildcardsJavaTx.java @@ -2,6 +2,7 @@ package inferWildcards; import java.io.File; import java.io.IOException; +import java.util.List; import java.util.Map; import org.junit.Before; @@ -14,6 +15,7 @@ import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.constraints.Pair; +import de.dhbwstuttgart.typeinference.result.ResultSet; public class TestInferWildcardsJavaTx { @@ -55,6 +57,25 @@ public class TestInferWildcardsJavaTx return constraints; } + @Test + public void testFields () throws Exception { + System.out.println("\n--------- Test Single --------------\n"); + JavaTXCompiler javaTXCompiler = getCompiler("TestClassWildcardsFields.java"); + + // Manipulate AST + Map tphMap = generateTph(javaTXCompiler); + + // Generate Constraints + ConstraintSet generatedConstraints = getGeneratedConstraints(tphMap); + // System.out.println(generatedConstraints); + + // Constraints + combineConstraints(javaTXCompiler, generatedConstraints); + + List typeInference = javaTXCompiler.typeInference(); + System.out.println(typeInference); + } + @Test public void testSingle () throws Exception { System.out.println("\n--------- Test Single --------------\n"); @@ -70,8 +91,8 @@ public class TestInferWildcardsJavaTx // Constraints combineConstraints(javaTXCompiler, generatedConstraints); - // List typeInference = javaTXCompiler.typeInference(); - // System.out.println(typeInference); + List typeInference = javaTXCompiler.typeInference(); + System.out.println(typeInference); } diff --git a/src/test/resources/inferWildcards/TestClassWildcardsFields.java b/src/test/resources/inferWildcards/TestClassWildcardsFields.java new file mode 100644 index 00000000..f244b4c1 --- /dev/null +++ b/src/test/resources/inferWildcards/TestClassWildcardsFields.java @@ -0,0 +1,27 @@ +import java.util.ArrayList; +import java.util.List; +import java.lang.String; + +class TestClassWildcardsFields +{ + + private List field1; + //private int counter; + + public TestClassWildcards () { + //field1 = new ArrayList<>(); + //counter = 0; + } + + /** + * Working method for Java + * @param param1 + * @return + */ + public List test (List param1) { + List localVar = field1; + field1 = param1; + //counter++; + return localVar; + } +} \ No newline at end of file diff --git a/src/test/resources/inferWildcards/TestClassWildcardsSingle.java b/src/test/resources/inferWildcards/TestClassWildcardsSingle.java index 68d02d8e..b9af5a46 100644 --- a/src/test/resources/inferWildcards/TestClassWildcardsSingle.java +++ b/src/test/resources/inferWildcards/TestClassWildcardsSingle.java @@ -1,4 +1,3 @@ -import java.util.ArrayList; import java.util.List; import java.lang.String; import java.lang.Object; @@ -6,24 +5,7 @@ import java.lang.Object; class TestClassWildcardsSingle { - private List field1; - //private int counter; - public TestClassWildcards () { - field1 = new ArrayList<>(); - //counter = 0; - } - - /** - * Working method for Java - * @param param1 - * @return - */ - public List test (List param1) { - List localVar = field1; - field1 = param1; - //counter++; - return localVar; } /** @@ -31,7 +13,7 @@ class TestClassWildcardsSingle * @param input * @return */ - public List test2 (List input) { + public List test (List input) { List listOfObjects = input; Object test = listOfObjects.get(0); String string = "Test";