forked from JavaTX/JavaCompilerCore
reduceUpLow test
This commit is contained in:
parent
b3514a8375
commit
e695429262
@ -16,7 +16,6 @@ import de.dhbwstuttgart.typinference.unify.model.FiniteClosure;
|
|||||||
import de.dhbwstuttgart.typinference.unify.model.MPair;
|
import de.dhbwstuttgart.typinference.unify.model.MPair;
|
||||||
import de.dhbwstuttgart.typinference.unify.model.MPair.PairOperator;
|
import de.dhbwstuttgart.typinference.unify.model.MPair.PairOperator;
|
||||||
import de.dhbwstuttgart.typinference.unify.model.SimpleType;
|
import de.dhbwstuttgart.typinference.unify.model.SimpleType;
|
||||||
import de.dhbwstuttgart.typinference.unify.model.SuperType;
|
|
||||||
|
|
||||||
|
|
||||||
public class RuleSetTest {
|
public class RuleSetTest {
|
||||||
@ -97,7 +96,38 @@ public class RuleSetTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReduceUpLow() {
|
public void testReduceUpLow() {
|
||||||
|
IRuleSet rules = new RuleSet(new FiniteClosureBuilder().getFiniteClosure());
|
||||||
|
TypeFactory tf = new TypeFactory();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Positive Tests
|
||||||
|
*/
|
||||||
|
MPair reduce1 = new MPair(tf.getExtendsType(tf.getSimpleType("type")), tf.getSuperType(tf.getSimpleType("type")), PairOperator.SMALLERDOT);
|
||||||
|
MPair reduce2 = new MPair(tf.getExtendsType(tf.getSimpleType("type")), tf.getSuperType(tf.getPlaceholderType("T")), PairOperator.SMALLERDOT);
|
||||||
|
|
||||||
|
MPair expected1 = new MPair(tf.getSimpleType("type"), tf.getSimpleType("type"), PairOperator.SMALLERDOT);
|
||||||
|
MPair expected2 = new MPair(tf.getSimpleType("type"), tf.getPlaceholderType("T"), PairOperator.SMALLERDOT);
|
||||||
|
|
||||||
|
Optional<MPair> opt1 = rules.reduceUpLow(reduce1);
|
||||||
|
Optional<MPair> opt2 = rules.reduceUpLow(reduce2);
|
||||||
|
|
||||||
|
Assert.assertTrue(opt1.isPresent());
|
||||||
|
Assert.assertTrue(opt2.isPresent());
|
||||||
|
Assert.assertEquals(opt1.get(), expected1);
|
||||||
|
Assert.assertEquals(opt2.get(), expected2);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Negative Tests
|
||||||
|
*/
|
||||||
|
MPair noreduce1 = new MPair(tf.getExtendsType(tf.getSimpleType("type")), tf.getExtendsType(tf.getSimpleType("type")), PairOperator.SMALLERDOT);
|
||||||
|
MPair noreduce2 = new MPair(tf.getSuperType(tf.getPlaceholderType("T")), tf.getExtendsType(tf.getSimpleType("type")), PairOperator.SMALLERDOT);
|
||||||
|
MPair noreduce3 = new MPair(tf.getSuperType(tf.getPlaceholderType("T")), tf.getSimpleType("type"), PairOperator.SMALLERDOT);
|
||||||
|
MPair noreduce4 = new MPair(tf.getExtendsType(tf.getPlaceholderType("T")), tf.getSimpleType("type"), PairOperator.EQUALSDOT);
|
||||||
|
|
||||||
|
Assert.assertFalse(rules.reduceUpLow(noreduce1).isPresent());
|
||||||
|
Assert.assertFalse(rules.reduceUpLow(noreduce2).isPresent());
|
||||||
|
Assert.assertFalse(rules.reduceUpLow(noreduce3).isPresent());
|
||||||
|
Assert.assertFalse(rules.reduceUpLow(noreduce4).isPresent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user