Tests anfügen
This commit is contained in:
parent
3cd7dba316
commit
4b9eda962e
@ -618,6 +618,15 @@ public class UnifyTest extends TypeUnify {
|
||||
public void unifyTestVoid() {
|
||||
/*
|
||||
* Constraints Set mit "void" Typen
|
||||
* T1 < Integer
|
||||
* Integer < Integer
|
||||
* T1 < T2
|
||||
* T3 < Bool
|
||||
* void < T4
|
||||
* OL < Object
|
||||
* void < void
|
||||
* ol < T5
|
||||
* T5 < ol
|
||||
*/
|
||||
TypeFactory tf = new TypeFactory();
|
||||
FiniteClosureBuilder fcb = new FiniteClosureBuilder();
|
||||
@ -626,7 +635,7 @@ public class UnifyTest extends TypeUnify {
|
||||
UnifyType tphT2 = tf.getPlaceholderType("T2");
|
||||
UnifyType tphT3 = tf.getPlaceholderType("T3");
|
||||
UnifyType tphT4 = tf.getPlaceholderType("T4");
|
||||
UnifyType tphT5 = tf.getPlaceholderType("T4");
|
||||
UnifyType tphT5 = tf.getPlaceholderType("T5");
|
||||
|
||||
UnifyType integer = tf.getSimpleType("java.lang.Integer");
|
||||
UnifyType voidType = tf.getSimpleType("void");
|
||||
@ -638,7 +647,7 @@ public class UnifyTest extends TypeUnify {
|
||||
fcb.add(integer, object);
|
||||
fcb.add(main, object);
|
||||
fcb.add(bool, object);
|
||||
fcb.add(voidType, object);
|
||||
fcb.add(voidType, voidType);
|
||||
fcb.add(ol, object);
|
||||
|
||||
IFiniteClosure fc = fcb.getFiniteClosure();
|
||||
@ -657,10 +666,71 @@ public class UnifyTest extends TypeUnify {
|
||||
eq.add(new UnifyPair(tphT5, ol, PairOperator.SMALLERDOT));
|
||||
|
||||
Set<Set<UnifyPair>> expected = new HashSet<>();
|
||||
Set<UnifyPair> solution = new HashSet<UnifyPair>();
|
||||
solution.add(new UnifyPair(tphT3, bool, PairOperator.EQUALSDOT));
|
||||
solution.add(new UnifyPair(tphT5, ol, PairOperator.EQUALSDOT));
|
||||
solution.add(new UnifyPair(tphT2, integer, PairOperator.EQUALSDOT));
|
||||
solution.add(new UnifyPair(tphT1, integer, PairOperator.EQUALSDOT));
|
||||
solution.add(new UnifyPair(tphT4, voidType, PairOperator.EQUALSDOT));
|
||||
expected.add(solution);
|
||||
|
||||
|
||||
Set<Set<UnifyPair>> actual = unify(eq, fc);
|
||||
|
||||
System.out.println("Test Void:");
|
||||
System.out.println(actual);
|
||||
|
||||
Assert.assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unifyTestOverloading(){
|
||||
/*
|
||||
* Constraints Set mit "void" Typen
|
||||
* OL < T1
|
||||
* T1 < T1
|
||||
* T1 < T2
|
||||
* T1 < OL
|
||||
*/
|
||||
TypeFactory tf = new TypeFactory();
|
||||
FiniteClosureBuilder fcb = new FiniteClosureBuilder();
|
||||
|
||||
UnifyType tphT1 = tf.getPlaceholderType("T1");
|
||||
UnifyType tphT2 = tf.getPlaceholderType("T2");
|
||||
|
||||
UnifyType integer = tf.getSimpleType("java.lang.Integer");
|
||||
UnifyType voidType = tf.getSimpleType("void");
|
||||
UnifyType bool = tf.getSimpleType("java.lang.Boolean");
|
||||
UnifyType object = tf.getSimpleType("Object");
|
||||
UnifyType main = tf.getSimpleType("Main");
|
||||
UnifyType ol = tf.getSimpleType("OL");
|
||||
|
||||
fcb.add(integer, object);
|
||||
fcb.add(main, object);
|
||||
fcb.add(bool, object);
|
||||
fcb.add(voidType, voidType);
|
||||
fcb.add(ol, object);
|
||||
|
||||
IFiniteClosure fc = fcb.getFiniteClosure();
|
||||
|
||||
Set<UnifyPair> eq = new HashSet<UnifyPair>();
|
||||
eq.add(new UnifyPair(ol, tphT1, PairOperator.SMALLERDOT));
|
||||
eq.add(new UnifyPair(tphT1, tphT1, PairOperator.SMALLERDOT));
|
||||
eq.add(new UnifyPair(tphT1, tphT2, PairOperator.SMALLERDOT));
|
||||
eq.add(new UnifyPair(tphT1, ol, PairOperator.SMALLERDOT));
|
||||
|
||||
Set<UnifyPair> expectedSolution = new HashSet<UnifyPair>();
|
||||
expectedSolution.add(new UnifyPair(tphT1, ol, PairOperator.EQUALSDOT));
|
||||
|
||||
|
||||
Set<Set<UnifyPair>> actual = unify(eq, fc);
|
||||
|
||||
System.out.println("Test Overloading:");
|
||||
System.out.println(actual);
|
||||
|
||||
for(Set<UnifyPair> actualSolution : actual){
|
||||
Assert.assertTrue(actualSolution.containsAll(expectedSolution));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user