|
|
|
@ -11,13 +11,14 @@ import org.junit.Test;
|
|
|
|
|
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
|
|
|
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
|
|
|
|
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
|
|
|
|
import de.dhbwstuttgart.typeinference.unify.model.FunNType;
|
|
|
|
|
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
|
|
|
|
import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
|
|
|
|
import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
|
|
|
|
|
import de.dhbwstuttgart.typeinference.unify.model.TypeParams;
|
|
|
|
|
import junit.framework.Assert;
|
|
|
|
|
|
|
|
|
|
public class UnifyTest extends TypeUnify{
|
|
|
|
|
public class UnifyTest {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Testing the unification for cases with (n)one pair and without generics.
|
|
|
|
@ -51,7 +52,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
Set<UnifyPair> eq = new HashSet<UnifyPair>();
|
|
|
|
|
Set<Set<UnifyPair>> expected = new HashSet<>();
|
|
|
|
|
expected.add(new HashSet<>());
|
|
|
|
|
Set<Set<UnifyPair>> actual = unify(eq, fc);
|
|
|
|
|
Set<Set<UnifyPair>> actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
Assert.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@ -69,7 +70,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
addAsSet(expected, new UnifyPair(tphA, integer, PairOperator.EQUALSDOT));
|
|
|
|
|
addAsSet(expected, new UnifyPair(tphA, doubl, PairOperator.EQUALSDOT));
|
|
|
|
|
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
@ -87,7 +88,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
addAsSet(expected, new UnifyPair(tphA, number, PairOperator.EQUALSDOT));
|
|
|
|
|
addAsSet(expected, new UnifyPair(tphA, object, PairOperator.EQUALSDOT));
|
|
|
|
|
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
@ -104,7 +105,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
expected = new HashSet<>();
|
|
|
|
|
addAsSet(expected, new UnifyPair(tphA, number, PairOperator.EQUALSDOT));
|
|
|
|
|
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
@ -128,7 +129,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
addAsSet(expected, new UnifyPair(tphA, supNumber, PairOperator.EQUALSDOT));
|
|
|
|
|
addAsSet(expected, new UnifyPair(tphA, supObject, PairOperator.EQUALSDOT));
|
|
|
|
|
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
System.out.println("? super Integer");
|
|
|
|
|
System.out.println(actual);
|
|
|
|
|
actual = filterGeneratedTPHsMultiple(actual);
|
|
|
|
@ -156,7 +157,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
addAsSet(expected, new UnifyPair(tphA, supDouble, PairOperator.EQUALSDOT));
|
|
|
|
|
addAsSet(expected, new UnifyPair(tphA, supNumber, PairOperator.EQUALSDOT));
|
|
|
|
|
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
actual = filterGeneratedTPHsMultiple(actual);
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(expected, actual);
|
|
|
|
@ -174,7 +175,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
addAsSet(expected, new UnifyPair(tphA, extNumber, PairOperator.EQUALSDOT));
|
|
|
|
|
addAsSet(expected, new UnifyPair(tphA, extObject, PairOperator.EQUALSDOT));
|
|
|
|
|
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
actual = filterGeneratedTPHsMultiple(actual);
|
|
|
|
|
Assert.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
@ -199,7 +200,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
addAsSet(expected, new UnifyPair(tphA, integer, PairOperator.EQUALSDOT));
|
|
|
|
|
addAsSet(expected, new UnifyPair(tphA, number, PairOperator.EQUALSDOT));
|
|
|
|
|
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
actual = filterGeneratedTPHsMultiple(actual);
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(expected, actual);
|
|
|
|
@ -216,7 +217,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
expected = new HashSet<>();
|
|
|
|
|
expected.add(new HashSet<>());
|
|
|
|
|
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
@ -231,7 +232,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
|
|
|
|
|
expected = new HashSet<>();
|
|
|
|
|
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
@ -248,7 +249,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
expected = new HashSet<>();
|
|
|
|
|
addAsSet(expected, new UnifyPair(tphA, tphB, PairOperator.SMALLERDOT));
|
|
|
|
|
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
@ -264,7 +265,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
expected = new HashSet<>();
|
|
|
|
|
addAsSet(expected, new UnifyPair(tphA, tphB, PairOperator.SMALLERDOTWC));
|
|
|
|
|
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
@ -286,7 +287,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
|
|
|
|
|
IFiniteClosure voidFC = fcb.getFiniteClosure();
|
|
|
|
|
|
|
|
|
|
actual = unify(eq, voidFC);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(expected, actual);
|
|
|
|
|
}
|
|
|
|
@ -331,7 +332,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
eq.add(new UnifyPair(tf.getSimpleType("List", tphB), tf.getSimpleType("List", extNum), PairOperator.SMALLERDOT));
|
|
|
|
|
|
|
|
|
|
Set<Set<UnifyPair>> expected = new HashSet<>();
|
|
|
|
|
Set<Set<UnifyPair>> actual = unify(eq, fc);
|
|
|
|
|
Set<Set<UnifyPair>> actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
//System.out.println(actual);
|
|
|
|
|
//Assert.assertEquals(actual, expected);
|
|
|
|
@ -350,7 +351,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
eq.add(new UnifyPair(tf.getSimpleType("Vector", extA), tf.getSimpleType("Vector", extNum), PairOperator.SMALLERDOT));
|
|
|
|
|
|
|
|
|
|
expected = new HashSet<>();
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
//System.out.println(actual);
|
|
|
|
|
//Assert.assertEquals(actual, expected);
|
|
|
|
@ -366,7 +367,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
eq.add(new UnifyPair(tf.getSimpleType("Vector", extNum), tf.getSimpleType("Vector", extA), PairOperator.SMALLERDOT));
|
|
|
|
|
|
|
|
|
|
expected = new HashSet<>();
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
System.out.println(actual);
|
|
|
|
|
//Assert.assertEquals(actual, expected);
|
|
|
|
@ -387,7 +388,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
eq.add(new UnifyPair(extNum, tphB, PairOperator.SMALLERDOTWC));
|
|
|
|
|
|
|
|
|
|
expected = new HashSet<>();
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
//System.out.println(actual);
|
|
|
|
|
//Assert.assertEquals(actual, expected);
|
|
|
|
@ -449,7 +450,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
eq.add(new UnifyPair(tf.getSimpleType("List", integer), tf.getSimpleType("List", tphB), PairOperator.SMALLERDOT));
|
|
|
|
|
|
|
|
|
|
Set<Set<UnifyPair>> expected = new HashSet<>();
|
|
|
|
|
Set<Set<UnifyPair>> actual = unify(eq, fc);
|
|
|
|
|
Set<Set<UnifyPair>> actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
System.out.println(actual);
|
|
|
|
|
//Assert.assertEquals(actual, expected);
|
|
|
|
@ -469,7 +470,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
|
|
|
|
|
expected = new HashSet<>();
|
|
|
|
|
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
System.out.println("Case 2");
|
|
|
|
|
System.out.println(actual);
|
|
|
|
@ -489,7 +490,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
|
|
|
|
|
expected = new HashSet<>();
|
|
|
|
|
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("Case 3");
|
|
|
|
@ -514,7 +515,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
|
|
|
|
|
expected = new HashSet<>();
|
|
|
|
|
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
System.out.println(actual);
|
|
|
|
|
//Assert.assertEquals(expected, actual);
|
|
|
|
@ -533,7 +534,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
|
|
|
|
|
expected = new HashSet<>();
|
|
|
|
|
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
System.out.println(actual);
|
|
|
|
|
//Assert.assertEquals(expected, actual);
|
|
|
|
@ -552,7 +553,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
|
|
|
|
|
expected = new HashSet<>();
|
|
|
|
|
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
System.out.println("Case 7");
|
|
|
|
|
System.out.println(actual);
|
|
|
|
@ -573,7 +574,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
|
|
|
|
|
expected = new HashSet<>();
|
|
|
|
|
|
|
|
|
|
actual = unify(eq, fc);
|
|
|
|
|
actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
System.out.println("Case 8:");
|
|
|
|
|
System.out.println(actual);
|
|
|
|
@ -608,7 +609,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
eq.add(new UnifyPair(tf.getSimpleType("Matrix"), tf.getSimpleType("Vector", tf.getPlaceholderType("a")), PairOperator.SMALLERDOT));
|
|
|
|
|
|
|
|
|
|
Set<Set<UnifyPair>> expected = new HashSet<>();
|
|
|
|
|
Set<Set<UnifyPair>> actual = unify(eq, fc);
|
|
|
|
|
Set<Set<UnifyPair>> actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
System.out.println("Test Matrix:");
|
|
|
|
|
System.out.println(actual);
|
|
|
|
@ -675,7 +676,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
expected.add(solution);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Set<Set<UnifyPair>> actual = unify(eq, fc);
|
|
|
|
|
Set<Set<UnifyPair>> actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
System.out.println("Test Void:");
|
|
|
|
|
System.out.println(actual);
|
|
|
|
@ -683,6 +684,172 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
Assert.assertEquals(expected, actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Test
|
|
|
|
|
// public void unifyTestMatrixSimple() {
|
|
|
|
|
//// [(C <. C),
|
|
|
|
|
//// (D <. D),
|
|
|
|
|
//// (java.lang.Boolean <. PC),
|
|
|
|
|
//// (java.lang.Integer <. E1),
|
|
|
|
|
//// (java.util.Vector<java.lang.Integer> <. java.util.Vector<E1>),
|
|
|
|
|
//// (java.lang.Integer <. PD),
|
|
|
|
|
//// (java.util.Vector<java.lang.Integer> <. java.util.Vector<E3>),
|
|
|
|
|
//// (PE <. java.lang.Boolean),
|
|
|
|
|
//// (C <. java.lang.Integer),
|
|
|
|
|
//// (PD <. java.lang.Integer),
|
|
|
|
|
//// (PE <. java.lang.Boolean),
|
|
|
|
|
//// (E2 <. PF),
|
|
|
|
|
//// (C <. java.lang.Integer),
|
|
|
|
|
//// (java.util.Vector<java.lang.Integer> <. java.util.Vector<E2>),
|
|
|
|
|
//// (PG <. java.lang.Double),
|
|
|
|
|
//// (java.lang.Integer <. java.lang.Double),
|
|
|
|
|
//// (PF <. java.lang.Double),
|
|
|
|
|
//// (PG <. D),
|
|
|
|
|
//// (D <. PH),
|
|
|
|
|
//// (void <. B),
|
|
|
|
|
//// (void <. PI),
|
|
|
|
|
//// (Matrix <. java.util.Vector<E4>),
|
|
|
|
|
//// (void <. void)]
|
|
|
|
|
//
|
|
|
|
|
// TypeFactory tf = new TypeFactory();
|
|
|
|
|
// FiniteClosureBuilder fcb = new FiniteClosureBuilder();
|
|
|
|
|
//
|
|
|
|
|
// UnifyType tphC = tf.getPlaceholderType("C");
|
|
|
|
|
// UnifyType tphD = tf.getPlaceholderType("D");
|
|
|
|
|
// UnifyType tphPC = tf.getPlaceholderType("PC");
|
|
|
|
|
// UnifyType tphE1 = tf.getPlaceholderType("E1");
|
|
|
|
|
// UnifyType tphPD = tf.getPlaceholderType("PD");
|
|
|
|
|
// UnifyType tphE3 = tf.getPlaceholderType("E3");
|
|
|
|
|
// UnifyType tphPE = tf.getPlaceholderType("PE");
|
|
|
|
|
// UnifyType tphE2 = tf.getPlaceholderType("E2");
|
|
|
|
|
// UnifyType tphPG = tf.getPlaceholderType("PG");
|
|
|
|
|
// UnifyType tphPF = tf.getPlaceholderType("PF");
|
|
|
|
|
// UnifyType tphPH = tf.getPlaceholderType("PH");
|
|
|
|
|
// UnifyType tphPI = tf.getPlaceholderType("PI");
|
|
|
|
|
// UnifyType tphE4 = tf.getPlaceholderType("E4");
|
|
|
|
|
// UnifyType tphB = tf.getPlaceholderType("B");
|
|
|
|
|
//
|
|
|
|
|
// UnifyType integer = tf.getSimpleType("java.lang.Integer");
|
|
|
|
|
// UnifyType voidType = tf.getSimpleType("void");
|
|
|
|
|
// UnifyType bool = tf.getSimpleType("java.lang.Boolean");
|
|
|
|
|
// UnifyType object = tf.getSimpleType("java.lang.Object");
|
|
|
|
|
// UnifyType doubl = tf.getSimpleType("java.lang.Double");
|
|
|
|
|
// UnifyType number = tf.getSimpleType("java.lang.Number");
|
|
|
|
|
//
|
|
|
|
|
// fcb.add(integer, number);
|
|
|
|
|
// fcb.add(bool, object);
|
|
|
|
|
// fcb.add(doubl, number);
|
|
|
|
|
// fcb.add(number, object);
|
|
|
|
|
// fcb.add(voidType, voidType);
|
|
|
|
|
//
|
|
|
|
|
// IFiniteClosure fc = fcb.getFiniteClosure();
|
|
|
|
|
//
|
|
|
|
|
// Set<UnifyPair> eq = new HashSet<UnifyPair>();
|
|
|
|
|
// eq.add(new UnifyPair(tphC, tphC, PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(tphD, tphD, PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(bool, tphPC, PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(integer, tphE1, PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(tf.getSimpleType("Vector", integer), tf.getSimpleType("Vector", tphE1), PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(integer, tphPD, PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(tf.getSimpleType("Vector", integer), tf.getSimpleType("Vector", tphE3), PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(tphPE, bool, PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(tphC, integer, PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(tphPD, integer, PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(tphPE, bool, PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(tphE2, tphPF, PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(tphC, integer, PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(tf.getSimpleType("Vector", integer), tf.getSimpleType("Vector", tphE2), PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(tphPG, doubl, PairOperator.SMALLERDOT));
|
|
|
|
|
// //eq.add(new UnifyPair(integer, doubl, PairOperator.SMALLERDOT)); KEIN WUNDER INFERIERT DAS NICHT
|
|
|
|
|
// eq.add(new UnifyPair(tphPF, doubl, PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(tphPG, tphD, PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(tphD, tphPH, PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(voidType, tphB, PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(voidType, tphPI, PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(tf.getSimpleType("Matrix"), tphPI, PairOperator.SMALLERDOT));
|
|
|
|
|
// eq.add(new UnifyPair(voidType, tphPI, PairOperator.SMALLERDOT));
|
|
|
|
|
//
|
|
|
|
|
// Set<Set<UnifyPair>> expected = new HashSet<>();
|
|
|
|
|
//
|
|
|
|
|
// Set<Set<UnifyPair>> actual = unify(eq, fc);
|
|
|
|
|
//
|
|
|
|
|
// System.out.println("Test Void:");
|
|
|
|
|
// System.out.println(actual);
|
|
|
|
|
//
|
|
|
|
|
// //Assert.assertEquals(expected, actual);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void unifyTestLambda6() {
|
|
|
|
|
// [(D <. D),
|
|
|
|
|
// (R455538610 <. ND),
|
|
|
|
|
// (Matrix <. T1455538610),
|
|
|
|
|
// (C <. T2455538610),
|
|
|
|
|
// (B <. Fun2<R455538610,T1455538610,T2455538610>),
|
|
|
|
|
// (ND <. NE),
|
|
|
|
|
// (Fun1<? extends NE,? super B> <. NC),
|
|
|
|
|
// (NC <. NF),
|
|
|
|
|
// (Fun1<? extends NF,? super C> <. NB),
|
|
|
|
|
// (NB <. D),
|
|
|
|
|
// (void <. NG),
|
|
|
|
|
// (Matrix <. java.lang.Object),
|
|
|
|
|
// (void <. void)]
|
|
|
|
|
|
|
|
|
|
TypeFactory tf = new TypeFactory();
|
|
|
|
|
FiniteClosureBuilder fcb = new FiniteClosureBuilder();
|
|
|
|
|
|
|
|
|
|
UnifyType tphD = tf.getPlaceholderType("D");
|
|
|
|
|
UnifyType tphND = tf.getPlaceholderType("ND");
|
|
|
|
|
UnifyType tphR4 = tf.getPlaceholderType("R4");
|
|
|
|
|
UnifyType tphT1 = tf.getPlaceholderType("T1");
|
|
|
|
|
UnifyType tphT2 = tf.getPlaceholderType("T2");
|
|
|
|
|
UnifyType tphC = tf.getPlaceholderType("C");
|
|
|
|
|
UnifyType tphNE = tf.getPlaceholderType("NE");
|
|
|
|
|
UnifyType tphNC = tf.getPlaceholderType("NC");
|
|
|
|
|
UnifyType tphB = tf.getPlaceholderType("B");
|
|
|
|
|
UnifyType tphNF = tf.getPlaceholderType("NF");
|
|
|
|
|
UnifyType tphNB = tf.getPlaceholderType("NB");
|
|
|
|
|
UnifyType tphNG = tf.getPlaceholderType("NG");
|
|
|
|
|
|
|
|
|
|
UnifyType voidType = tf.getSimpleType("void");
|
|
|
|
|
UnifyType object = tf.getSimpleType("java.lang.Object");
|
|
|
|
|
UnifyType matrix = tf.getSimpleType("java.lang.Matrix");
|
|
|
|
|
|
|
|
|
|
UnifyType r = tf.getPlaceholderType("R");
|
|
|
|
|
UnifyType t1 = tf.getPlaceholderType("T1");
|
|
|
|
|
UnifyType t2 = tf.getPlaceholderType("T2");
|
|
|
|
|
UnifyType fun1 = FunNType.getFunNType(new TypeParams(r, t1));
|
|
|
|
|
UnifyType fun2 = FunNType.getFunNType(new TypeParams(r, t1, t2));
|
|
|
|
|
|
|
|
|
|
fcb.add(matrix, object);
|
|
|
|
|
fcb.add(voidType, voidType);
|
|
|
|
|
|
|
|
|
|
IFiniteClosure fc = fcb.getFiniteClosure();
|
|
|
|
|
|
|
|
|
|
Set<UnifyPair> eq = new HashSet<UnifyPair>();
|
|
|
|
|
eq.add(new UnifyPair(tphD, tphD, PairOperator.SMALLERDOT));
|
|
|
|
|
eq.add(new UnifyPair(tphR4, tphND, PairOperator.SMALLERDOT));
|
|
|
|
|
eq.add(new UnifyPair(matrix, tphT1, PairOperator.SMALLERDOT));
|
|
|
|
|
eq.add(new UnifyPair(tphC, tphT2, PairOperator.SMALLERDOT));
|
|
|
|
|
eq.add(new UnifyPair(tphB, FunNType.getFunNType(new TypeParams(tphR4, tphT1, tphT2)), PairOperator.SMALLERDOT));
|
|
|
|
|
eq.add(new UnifyPair(tphND, tphNE, PairOperator.SMALLERDOT));
|
|
|
|
|
eq.add(new UnifyPair(FunNType.getFunNType(new TypeParams(tphNE, tphB)), tphNC, PairOperator.SMALLERDOT));
|
|
|
|
|
eq.add(new UnifyPair(tphNC, tphNF, PairOperator.SMALLERDOT));
|
|
|
|
|
eq.add(new UnifyPair(FunNType.getFunNType(new TypeParams(tphNF, tphC)), tphNB, PairOperator.SMALLERDOT));
|
|
|
|
|
eq.add(new UnifyPair(tphNB, tphD, PairOperator.SMALLERDOT));
|
|
|
|
|
eq.add(new UnifyPair(voidType, tphNG, PairOperator.SMALLERDOT));
|
|
|
|
|
eq.add(new UnifyPair(matrix, object, PairOperator.SMALLERDOT));
|
|
|
|
|
eq.add(new UnifyPair(voidType, voidType, PairOperator.SMALLERDOT));
|
|
|
|
|
|
|
|
|
|
Set<Set<UnifyPair>> expected = new HashSet<>();
|
|
|
|
|
|
|
|
|
|
Set<Set<UnifyPair>> actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
System.out.println("Test Lambda6:");
|
|
|
|
|
System.out.println(actual);
|
|
|
|
|
|
|
|
|
|
//Assert.assertEquals(expected, actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void unifyTestOverloading(){
|
|
|
|
|
/*
|
|
|
|
@ -723,7 +890,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
expectedSolution.add(new UnifyPair(tphT1, ol, PairOperator.EQUALSDOT));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Set<Set<UnifyPair>> actual = unify(eq, fc);
|
|
|
|
|
Set<Set<UnifyPair>> actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
System.out.println("Test Overloading:");
|
|
|
|
|
System.out.println(actual);
|
|
|
|
@ -774,7 +941,7 @@ public class UnifyTest extends TypeUnify{
|
|
|
|
|
solution.add(new UnifyPair(tphT2, integer, PairOperator.EQUALSDOT));
|
|
|
|
|
expected.add(solution);
|
|
|
|
|
|
|
|
|
|
Set<Set<UnifyPair>> actual = unify(eq, fc);
|
|
|
|
|
Set<Set<UnifyPair>> actual = new TypeUnify().unifySequential(eq, fc);
|
|
|
|
|
|
|
|
|
|
System.out.println("Test Subclass:");
|
|
|
|
|
System.out.println(actual);
|
|
|
|
|