Test via assert of amount of generated constraints

This commit is contained in:
Till Schnell 2021-04-13 09:14:17 +02:00
parent f698c967c0
commit e5f03369cc
5 changed files with 45 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hamcrest.CoreMatchers;
import org.junit.Before;
@ -17,6 +18,7 @@ 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.Constraint;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.result.ResultSet;
@ -69,6 +71,13 @@ public class TestInferWildcardsFields
ConstraintSet<Pair> generateConstraints = ConstraintsGenerationUtils.generateConstraints(tphMap);
System.out.println(generateConstraints);
int size = 0;
for (Set<Constraint<Pair>> l : generateConstraints.getOderConstraints())
for (Constraint<Pair> c : l)
size += c.size();
assertThat("Number of Generated Constraints", tphMap.size() * 3, CoreMatchers.is(size));
}
@Test

View File

@ -6,6 +6,7 @@ import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hamcrest.CoreMatchers;
import org.junit.Before;
@ -17,6 +18,7 @@ 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.Constraint;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.result.ResultSet;
@ -69,6 +71,13 @@ public class TestInferWildcardsMap
ConstraintSet<Pair> generateConstraints = ConstraintsGenerationUtils.generateConstraints(tphMap);
System.out.println(generateConstraints);
int size = 0;
for (Set<Constraint<Pair>> l : generateConstraints.getOderConstraints())
for (Constraint<Pair> c : l)
size += c.size();
assertThat("Number of Generated Constraints", tphMap.size() * 3, CoreMatchers.is(size));
}
@Test

View File

@ -6,6 +6,7 @@ import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hamcrest.CoreMatchers;
import org.junit.Before;
@ -17,6 +18,7 @@ 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.Constraint;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.result.ResultSet;
@ -69,6 +71,13 @@ public class TestInferWildcardsMapNested
ConstraintSet<Pair> generateConstraints = ConstraintsGenerationUtils.generateConstraints(tphMap);
System.out.println(generateConstraints);
int size = 0;
for (Set<Constraint<Pair>> l : generateConstraints.getOderConstraints())
for (Constraint<Pair> c : l)
size += c.size();
assertThat("Number of Generated Constraints", tphMap.size() * 3, CoreMatchers.is(size));
}
@Test

View File

@ -6,6 +6,7 @@ import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hamcrest.CoreMatchers;
import org.junit.Before;
@ -17,6 +18,7 @@ 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.Constraint;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.result.ResultSet;
@ -69,6 +71,13 @@ public class TestInferWildcardsNested
ConstraintSet<Pair> generateConstraints = ConstraintsGenerationUtils.generateConstraints(tphMap);
System.out.println(generateConstraints);
int size = 0;
for (Set<Constraint<Pair>> l : generateConstraints.getOderConstraints())
for (Constraint<Pair> c : l)
size += c.size();
assertThat("Number of Generated Constraints", tphMap.size() * 3, CoreMatchers.is(size));
}
@Test

View File

@ -6,6 +6,7 @@ import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hamcrest.CoreMatchers;
import org.junit.Before;
@ -17,6 +18,7 @@ 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.Constraint;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.result.ResultSet;
@ -69,6 +71,13 @@ public class TestInferWildcardsSingle
ConstraintSet<Pair> generateConstraints = ConstraintsGenerationUtils.generateConstraints(tphMap);
System.out.println(generateConstraints);
int size = 0;
for (Set<Constraint<Pair>> l : generateConstraints.getOderConstraints())
for (Constraint<Pair> c : l)
size += c.size();
assertThat("Number of Generated Constraints", tphMap.size() * 3, CoreMatchers.is(size));
}
@Test