Add Test for map
This commit is contained in:
parent
6458a06293
commit
50c05064c7
91
src/test/java/inferWildcards/TestInferWildcardsMap.java
Normal file
91
src/test/java/inferWildcards/TestInferWildcardsMap.java
Normal file
@ -0,0 +1,91 @@
|
||||
package inferWildcards;
|
||||
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.inferWildcards.ConstraintsGenerationUtils;
|
||||
import de.dhbwstuttgart.inferWildcards.JavaTXCompilerWildcards;
|
||||
import de.dhbwstuttgart.inferWildcards.TypePlaceholderReplaceUtils;
|
||||
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 TestInferWildcardsMap
|
||||
{
|
||||
|
||||
private String resourcePath;
|
||||
|
||||
@Before
|
||||
public void setup () {
|
||||
resourcePath = System.getProperty("user.dir")
|
||||
+ "/src/test/resources/inferWildcards/TestClassWildcardsMap.java";
|
||||
}
|
||||
|
||||
private JavaTXCompiler getStandardCompiler () throws ClassNotFoundException, IOException {
|
||||
File[] files1 = { new File(resourcePath) };
|
||||
return new JavaTXCompiler(files1);
|
||||
}
|
||||
|
||||
private JavaTXCompilerWildcards getWildcardsCompiler () throws ClassNotFoundException, IOException {
|
||||
File[] files1 = { new File(resourcePath) };
|
||||
return new JavaTXCompilerWildcards(files1);
|
||||
}
|
||||
|
||||
private static Map<? extends TypePlaceholder, ? extends RefType> generateTph (JavaTXCompiler javaTXCompiler) {
|
||||
System.out.println("\nReplacements:");
|
||||
|
||||
return TypePlaceholderReplaceUtils.generateTypePlaceholder(javaTXCompiler);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenerateTph () throws ClassNotFoundException, IOException {
|
||||
System.out.println("\n--------- Test Generate TPH --------------\n");
|
||||
|
||||
JavaTXCompiler javaTXCompiler = getStandardCompiler();
|
||||
Map<? extends TypePlaceholder, ? extends RefType> generateTph = generateTph(javaTXCompiler);
|
||||
|
||||
System.out.println(generateTph);
|
||||
|
||||
assertThat("Number of TPH is 6", 6, CoreMatchers.is(generateTph.size()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGeneratedConstraints () throws ClassNotFoundException, IOException {
|
||||
System.out.println("\n--------- Test Generate Constraints --------------\n");
|
||||
|
||||
JavaTXCompilerWildcards javaTXCompilerWildcards = getWildcardsCompiler();
|
||||
Map<? extends TypePlaceholder, ? extends RefType> tphMap = javaTXCompilerWildcards.getTphMap();
|
||||
ConstraintSet<Pair> generateConstraints = ConstraintsGenerationUtils.generateConstraints(tphMap);
|
||||
|
||||
System.out.println(generateConstraints);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCombinedConstraints () throws ClassNotFoundException, IOException {
|
||||
System.out.println("\n--------- Test Combined Constraints --------------\n");
|
||||
|
||||
JavaTXCompilerWildcards javaTXCompilerWildcards = getWildcardsCompiler();
|
||||
ConstraintSet<Pair> constraints = javaTXCompilerWildcards.getConstraints();
|
||||
|
||||
System.out.println(constraints);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTypeInference () throws ClassNotFoundException, IOException {
|
||||
JavaTXCompilerWildcards wildcardsCompiler = getWildcardsCompiler();
|
||||
List<ResultSet> typeInference = wildcardsCompiler.typeInference();
|
||||
|
||||
System.out.println(typeInference);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user