diff --git a/src/test/java/typeinference/UnifyTest.java b/src/test/java/typeinference/UnifyTest.java index 3a65aaccf..fe0624c2b 100644 --- a/src/test/java/typeinference/UnifyTest.java +++ b/src/test/java/typeinference/UnifyTest.java @@ -38,95 +38,6 @@ import java.util.Set; public class UnifyTest { public static final String rootDirectory = System.getProperty("user.dir")+"/resources/javFiles/"; - - @Test - public void unifyTest(){ - UnifyType type1 = new PlaceholderType("a"); - UnifyType type2 = new ReferenceType("List", new TypeParams(new PlaceholderType("b"))); - UnifyPair pair1 = new UnifyPair(type1, type2, PairOperator.SMALLERDOT); - - type1 = new ReferenceType("List", new TypeParams(new PlaceholderType("c"))); - type2 = new PlaceholderType("a"); - UnifyPair pair2 = new UnifyPair(type1, type2, PairOperator.SMALLERDOT); - - type1 = new ReferenceType("String"); - type2 = new PlaceholderType("b"); - UnifyPair pair3 = new UnifyPair(type1, type2, PairOperator.SMALLERDOT); - - type1 = new ReferenceType("Integer"); - type2 = new PlaceholderType("c"); - UnifyPair pair4 = new UnifyPair(type1, type2, PairOperator.SMALLERDOT); - - Set undConstraints = new HashSet<>(); - undConstraints.add(pair1); - undConstraints.add(pair2); - undConstraints.add(pair3); - undConstraints.add(pair4); - - List>> oderConstraints = new ArrayList<>(); - - Set constraints = new HashSet<>(); - type1 = new ReferenceType("Object"); - type2 = new ReferenceType("String"); - constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); - type1 = new ReferenceType("Number"); - type2 = new ReferenceType("Integer"); - constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); - type1 = new ReferenceType("Object"); - type2 = new ReferenceType("Number"); - constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); - /* type1 = new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("X"))); - type2 = new ReferenceType("List", new TypeParams(new PlaceholderType("X"))); - constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); - type1 = new ReferenceType("Object"); - type2 = new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("X"))); - constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));*/ - type1 = new ReferenceType("AbstractList"); - type2 = new ReferenceType("List"); - constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); - type1 = new ReferenceType("Object"); - type2 = new ReferenceType("AbstractList"); - constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); - - IFiniteClosure finiteClosure = new FiniteClosure(constraints, new NullWriter()); - - TypeUnify unifyAlgo = new TypeUnify(); - ConstraintSet< Pair> cons = new ConstraintSet<>(); - UnifyResultModel urm = new UnifyResultModel(cons, finiteClosure); - UnifyTaskModel tasks = new UnifyTaskModel(); - Set> solution = unifyAlgo.unify(undConstraints, oderConstraints, finiteClosure, new NullWriter(), false, urm, tasks); - System.out.println(solution.size()); - } - - @Test - public void smallUnifyTest(){ - UnifyType type1 = new PlaceholderType("a"); - UnifyType type2 = new ReferenceType("List", new TypeParams(new ReferenceType("Integer"))); - UnifyPair pair1 = new UnifyPair(type1, type2, PairOperator.SMALLERDOT); - - Set undConstraints = new HashSet<>(); - undConstraints.add(pair1); - - List>> oderConstraints = new ArrayList<>(); - - Set constraints = new HashSet<>(); - type1 = new ReferenceType("Object"); - type2 = new ReferenceType("List"); - constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); - type1 = new ReferenceType("Object"); - type2 = new ReferenceType("Integer"); - constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); - - IFiniteClosure finiteClosure = new FiniteClosure(constraints, new NullWriter()); - - TypeUnify unifyAlgo = new TypeUnify(); - ConstraintSet< Pair> cons = new ConstraintSet<>(); - UnifyResultModel urm = new UnifyResultModel(cons, finiteClosure); - UnifyTaskModel tasks = new UnifyTaskModel(); - Set> solution = unifyAlgo.unify(undConstraints, oderConstraints, finiteClosure, new NullWriter(), false, urm, tasks); - System.out.println(solution.size()); - System.out.println(solution); - } /* @Test public void finiteClosure() throws IOException, ClassNotFoundException {