implemented succesfully running test

This commit is contained in:
NoName11234 2024-02-04 13:28:01 +01:00
parent a6ca31d509
commit 0f18cedf90

View File

@ -93,6 +93,23 @@ public class UnifyTest {
System.out.println(solution.size());
}
private UnifyPair genPair(String name){
UnifyType type1 = new PlaceholderType(name);
UnifyType type2 = new ReferenceType("List", new TypeParams(new ReferenceType("Integer")));
UnifyPair pair1 = new UnifyPair(type2, type1, PairOperator.SMALLERDOT);
return pair1;
}
private UnifyPair genPair2(String name){
PlaceholderType type1 = new PlaceholderType(name);
type1.setVariance(1);
UnifyType type2 = new ReferenceType("List", new TypeParams(new ReferenceType("String")));
UnifyPair pair1 = new UnifyPair(type2, type1, PairOperator.SMALLERDOT);
return pair1;
}
@Test
public void smallUnifyTest(){
UnifyType type1 = new PlaceholderType("a");
@ -100,17 +117,36 @@ public class UnifyTest {
UnifyPair pair1 = new UnifyPair(type1, type2, PairOperator.SMALLERDOT);
Set<UnifyPair> undConstraints = new HashSet<>();
undConstraints.add(pair1);
undConstraints.add(genPair("a"));
undConstraints.add(genPair2("a"));
undConstraints.add(genPair("b"));
undConstraints.add(genPair2("b"));
undConstraints.add(genPair("c"));
undConstraints.add(genPair2("c"));
undConstraints.add(genPair("d"));
undConstraints.add(genPair2("d"));
undConstraints.add(genPair("e"));
undConstraints.add(genPair2("e"));
undConstraints.add(genPair("e1"));
undConstraints.add(genPair2("e1"));
undConstraints.add(genPair("e2"));
undConstraints.add(genPair2("e2"));
undConstraints.add(genPair("e3"));
undConstraints.add(genPair2("e3"));
List<Set<Constraint<UnifyPair>>> oderConstraints = new ArrayList<>();
Set<UnifyPair> constraints = new HashSet<>();
type1 = new ReferenceType("Object");
type2 = new ReferenceType("List");
constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
type2 = new ReferenceType("List", new TypeParams(new PlaceholderType("X")));
constraints.add(new UnifyPair(type2, type1, PairOperator.SMALLER));
type1 = new ReferenceType("Object");
type2 = new ReferenceType("Integer");
constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
constraints.add(new UnifyPair(type2, type1, PairOperator.SMALLER));
type1 = new ReferenceType("Object");
type2 = new ReferenceType("String");
constraints.add(new UnifyPair(type2, type1, PairOperator.SMALLER));
IFiniteClosure finiteClosure = new FiniteClosure(constraints, new NullWriter());