Split the single testcase to two

This commit is contained in:
Till Schnell 2021-04-10 10:40:58 +02:00
parent ff92807b83
commit c627f9de60
3 changed files with 51 additions and 21 deletions

View File

@ -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<TypePlaceholder, RefType> tphMap = generateTph(javaTXCompiler);
// Generate Constraints
ConstraintSet<Pair> generatedConstraints = getGeneratedConstraints(tphMap);
// System.out.println(generatedConstraints);
// Constraints
combineConstraints(javaTXCompiler, generatedConstraints);
List<ResultSet> 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<ResultSet> typeInference = javaTXCompiler.typeInference();
// System.out.println(typeInference);
List<ResultSet> typeInference = javaTXCompiler.typeInference();
System.out.println(typeInference);
}

View File

@ -0,0 +1,27 @@
import java.util.ArrayList;
import java.util.List;
import java.lang.String;
class TestClassWildcardsFields
{
private List<String> field1;
//private int counter;
public TestClassWildcards () {
//field1 = new ArrayList<>();
//counter = 0;
}
/**
* Working method for Java
* @param param1
* @return
*/
public List<String> test (List<String> param1) {
List<String> localVar = field1;
field1 = param1;
//counter++;
return localVar;
}
}

View File

@ -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<String> field1;
//private int counter;
public TestClassWildcards () {
field1 = new ArrayList<>();
//counter = 0;
}
/**
* Working method for Java
* @param param1
* @return
*/
public List<String> test (List<String> param1) {
List<String> localVar = field1;
field1 = param1;
//counter++;
return localVar;
}
/**
@ -31,7 +13,7 @@ class TestClassWildcardsSingle
* @param input
* @return
*/
public List<Object> test2 (List<String> input) {
public List<Object> test (List<String> input) {
List<Object> listOfObjects = input;
Object test = listOfObjects.get(0);
String string = "Test";