forked from JavaTX/JavaCompilerCore
reduce 2 Test
This commit is contained in:
parent
176ec7b707
commit
7ada9cbd47
@ -16,6 +16,7 @@ import de.dhbwstuttgart.typinference.unify.model.FiniteClosure;
|
||||
import de.dhbwstuttgart.typinference.unify.model.MPair;
|
||||
import de.dhbwstuttgart.typinference.unify.model.MPair.PairOperator;
|
||||
import de.dhbwstuttgart.typinference.unify.model.SimpleType;
|
||||
import de.dhbwstuttgart.typinference.unify.model.SuperType;
|
||||
|
||||
|
||||
public class RuleSetTest {
|
||||
@ -186,7 +187,48 @@ public class RuleSetTest {
|
||||
|
||||
@Test
|
||||
public void testReduce2() {
|
||||
TypeFactory tf = new TypeFactory();
|
||||
FiniteClosureBuilder fcb = new FiniteClosureBuilder();
|
||||
IRuleSet rules = new RuleSet(fcb.getFiniteClosure());
|
||||
|
||||
/*
|
||||
* Positive Tests
|
||||
*/
|
||||
System.out.println("----- Reduce2 ------");
|
||||
|
||||
// C<T1, SType1, ? extends SType1>
|
||||
SimpleType c1 = tf.getSimpleType("C", tf.getPlaceholderType("T1"), tf.getSimpleType("SType1"), tf.getExtendsType(tf.getSimpleType("SType1")));
|
||||
// C<T2, SType2, ? extends SType2>
|
||||
SimpleType c2 = tf.getSimpleType("C", tf.getPlaceholderType("T2"), tf.getSimpleType("SType2"), tf.getExtendsType(tf.getSimpleType("SType2")));
|
||||
|
||||
MPair pair1 = new MPair(c1, c2, PairOperator.EQUALSDOT);
|
||||
MPair pair2 = new MPair(tf.getExtendsType(c1), tf.getExtendsType(c2), PairOperator.EQUALSDOT);
|
||||
MPair pair3 = new MPair(tf.getSuperType(c1), tf.getSuperType(c2), PairOperator.EQUALSDOT);
|
||||
|
||||
Optional<Set<MPair>> opt1 = rules.reduce2(pair1);
|
||||
System.out.println(opt1);
|
||||
|
||||
Optional<Set<MPair>> opt2 = rules.reduce2(pair2);
|
||||
System.out.println(opt2);
|
||||
|
||||
Optional<Set<MPair>> opt3 = rules.reduce2(pair3);
|
||||
System.out.println(opt3);
|
||||
|
||||
|
||||
/*
|
||||
* Negative Tests
|
||||
*/
|
||||
|
||||
SimpleType d1 = tf.getSimpleType("D", tf.getPlaceholderType("T2"), tf.getSimpleType("SType2"), tf.getExtendsType(tf.getSimpleType("SType2")));
|
||||
pair1 = new MPair(d1, c1, PairOperator.EQUALSDOT); // Case 1: D =. C
|
||||
pair2 = new MPair(tf.getExtendsType(c1), c2, PairOperator.EQUALSDOT); // Case 2: ? extends C =. C
|
||||
pair3 = new MPair(tf.getExtendsType(c1), tf.getSuperType(c2), PairOperator.EQUALSDOT); // Case 3: ? extends C =. ? super C
|
||||
MPair pair4 = new MPair(c1, c2, PairOperator.SMALLERDOT); // Case 4: C <. C
|
||||
|
||||
Assert.assertFalse(rules.reduceEq(pair1).isPresent());
|
||||
Assert.assertFalse(rules.reduceEq(pair2).isPresent());
|
||||
Assert.assertFalse(rules.reduceEq(pair3).isPresent());
|
||||
Assert.assertFalse(rules.reduceEq(pair4).isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -239,7 +281,7 @@ public class RuleSetTest {
|
||||
|
||||
// C<T1, SType1, ? extends SType1>
|
||||
SimpleType c1 = tf.getSimpleType("C", tf.getPlaceholderType("T1"), tf.getSimpleType("SType1"), tf.getExtendsType(tf.getSimpleType("SType1")));
|
||||
// D<T2, SType2, ? extends SType2>
|
||||
// C<T2, SType2, ? extends SType2>
|
||||
SimpleType c2 = tf.getSimpleType("C", tf.getPlaceholderType("T2"), tf.getSimpleType("SType2"), tf.getExtendsType(tf.getSimpleType("SType2")));
|
||||
|
||||
MPair pair = new MPair(c1, c2, PairOperator.SMALLERDOTWC);
|
||||
|
Loading…
Reference in New Issue
Block a user