forked from JavaTX/JavaCompilerCore
Add test for JavaTX constraints generation
This commit is contained in:
parent
cbe2d7b0f5
commit
0551d25fbf
38
src/test/java/inferWildcards/TestInferWildcardsJavaTx.java
Normal file
38
src/test/java/inferWildcards/TestInferWildcardsJavaTx.java
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user