54 lines
1.8 KiB
Java
54 lines
1.8 KiB
Java
package unify;
|
|
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
|
|
import org.junit.Test;
|
|
|
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
|
import de.dhbwstuttgart.typeinference.unifynew.Unify;
|
|
import de.dhbwstuttgart.typinference.unify.model.MPair;
|
|
import de.dhbwstuttgart.typinference.unify.model.MPair.PairOperator;
|
|
|
|
public class UnifyTest extends Unify {
|
|
|
|
@Test
|
|
public void unifyTest() {
|
|
TypeFactory tf = new TypeFactory();
|
|
FiniteClosureBuilder fcb = new FiniteClosureBuilder();
|
|
Set<MPair> eq = new HashSet<MPair>();
|
|
|
|
fcb.add(tf.getSimpleType("Number"), tf.getSimpleType("Object"));
|
|
fcb.add(tf.getSimpleType("Integer"), tf.getSimpleType("Number"));
|
|
fcb.add(tf.getSimpleType("Double"), tf.getSimpleType("Number"));
|
|
|
|
IFiniteClosure fc = fcb.getCollectionExample();
|
|
|
|
// Vector<Integer> <. Vector<A>
|
|
// Vector<Integer <. Vector<C>
|
|
// A <. Number
|
|
// Double <. B
|
|
// B <. Object
|
|
eq.add(new MPair(tf.getSimpleType("Vector", tf.getSimpleType("Integer")), tf.getSimpleType("Vector", "A"), PairOperator.SMALLERDOT));
|
|
eq.add(new MPair(tf.getSimpleType("Vector", tf.getSimpleType("Integer")), tf.getSimpleType("Vector", "C"), PairOperator.SMALLERDOT));
|
|
eq.add(new MPair(tf.getPlaceholderType("A"), tf.getSimpleType("Number"), PairOperator.SMALLERDOT));
|
|
//eq.add(new MPair(tf.getPlaceholderType("A"), tf.getPlaceholderType("C"), PairOperator.SMALLERDOT));
|
|
eq.add(new MPair(tf.getSimpleType("Double"), tf.getPlaceholderType("B"), PairOperator.SMALLERDOT));
|
|
eq.add(new MPair(tf.getPlaceholderType("B"), tf.getSimpleType("Object"), PairOperator.EQUALSDOT));
|
|
|
|
this.unify(eq, fc);
|
|
|
|
}
|
|
|
|
@Test
|
|
public void applyTypeUnificationRulesTest() {
|
|
|
|
}
|
|
|
|
@Test
|
|
public void calculatePairSetsTest() {
|
|
|
|
}
|
|
|
|
}
|