Add test for JavaTX constraints generation

This commit is contained in:
Till Schnell 2021-04-04 15:39:57 +02:00
parent cbe2d7b0f5
commit 0551d25fbf
2 changed files with 45 additions and 4 deletions

View File

@ -0,0 +1,38 @@
package inferWildcards;
import java.io.File;
import javax.tools.JavaCompiler;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
import org.junit.Before;
import org.junit.Test;
import de.dhbwstuttgart.core.JavaTXCompiler;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.Pair;
public class TestInferWildcardsJavaTx
{
private JavaCompiler compiler;
private StandardJavaFileManager fileManager;
@Before
public void setup () {
compiler = ToolProvider.getSystemJavaCompiler();
fileManager = compiler.getStandardFileManager(null, null, null);
}
@Test
public void test () throws Exception {
String resourcePath = System.getProperty("user.dir") + "/src/test/resources/inferWildcards";
File[] files1 = { new File(resourcePath + "/TestClassWildcards.java") };
JavaTXCompiler javaTXCompiler = new JavaTXCompiler(files1);
ConstraintSet<Pair> constraints = javaTXCompiler.getConstraints();
System.out.println(constraints);
}
}

View File

@ -1,14 +1,17 @@
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.lang.String;
import java.lang.Object;
class TestClassWildcards class TestClassWildcards
{ {
private List<String> field1; private List<String> field1;
private int counter; //private int counter;
public TestClassWildcards () { public TestClassWildcards () {
field1 = new ArrayList<>(); field1 = new ArrayList<>();
counter = 0; //counter = 0;
} }
/** /**
@ -18,8 +21,8 @@ class TestClassWildcards
*/ */
public List<String> test (List<String> param1) { public List<String> test (List<String> param1) {
List<String> localVar = field1; List<String> localVar = field1;
field1 = param; field1 = param1;
counter++; //counter++;
return localVar; return localVar;
} }