diff --git a/test/unify/UnifyTest.java b/test/unify/UnifyTest.java index 400b0c5a..3f1aeafe 100644 --- a/test/unify/UnifyTest.java +++ b/test/unify/UnifyTest.java @@ -1,23 +1,58 @@ package unify; -import org.apache.commons.bcel6.generic.ReferenceType; import org.junit.Test; -import de.dhbwstuttgart.bytecode.TypePlaceholderType; +import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Pair; +import de.dhbwstuttgart.typeinference.unify.FC_TTO; +import de.dhbwstuttgart.typeinference.unify.Unify; public class UnifyTest { @Test public void unifyTestSimpleTypes() { + + /* + * Input + */ Type tph1 = TypePlaceholder.backdoorCreate("b"); Type tph2 = TypePlaceholder.backdoorCreate("a"); - //Type refT = new RefType() - //Pair x = new Pair(); + RefType rt1 = new RefType("java.lang.Boolean", null, 0); + RefType rt2 = new RefType("java.lang.Integer", null, 0); + + Menge assumptions = new Menge(); + + // b <. Boolean <. a <. Integer + assumptions.add(new Pair(tph1, rt1)); + assumptions.add(new Pair(rt1, tph2)); + assumptions.add(new Pair(tph2, rt2)); + + /* + * FC TTO + */ + Menge fc = new Menge(); + + // String <. Boolean <. Integer + fc.add(new Pair(new RefType("java.lang.String", null, 0), new RefType("java.lang.Boolean", null, 0))); + fc.add(new Pair(new RefType("java.lang.Boolean", null, 0), new RefType("java.lang.Integer", null, 0))); + + Menge tto = (Menge) fc.clone(); + + Menge classes = new Menge(); + + classes.add(new Class("java.lang.Boolean", 0)); + classes.add(new Class("java.lang.String", 0)); + classes.add(new Class("java.lang.Integer", 0)); + + // Was ist tto und classes? + FC_TTO fctto = new FC_TTO(fc, tto, null); + + System.out.println(Unify.unify(assumptions, fctto)); } @Test