forked from JavaTX/JavaCompilerCore
implemented succesfully running test
This commit is contained in:
parent
a6ca31d509
commit
0f18cedf90
@ -93,6 +93,23 @@ public class UnifyTest {
|
|||||||
System.out.println(solution.size());
|
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
|
@Test
|
||||||
public void smallUnifyTest(){
|
public void smallUnifyTest(){
|
||||||
UnifyType type1 = new PlaceholderType("a");
|
UnifyType type1 = new PlaceholderType("a");
|
||||||
@ -100,17 +117,36 @@ public class UnifyTest {
|
|||||||
UnifyPair pair1 = new UnifyPair(type1, type2, PairOperator.SMALLERDOT);
|
UnifyPair pair1 = new UnifyPair(type1, type2, PairOperator.SMALLERDOT);
|
||||||
|
|
||||||
Set<UnifyPair> undConstraints = new HashSet<>();
|
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<>();
|
List<Set<Constraint<UnifyPair>>> oderConstraints = new ArrayList<>();
|
||||||
|
|
||||||
Set<UnifyPair> constraints = new HashSet<>();
|
Set<UnifyPair> constraints = new HashSet<>();
|
||||||
type1 = new ReferenceType("Object");
|
type1 = new ReferenceType("Object");
|
||||||
type2 = new ReferenceType("List");
|
type2 = new ReferenceType("List", new TypeParams(new PlaceholderType("X")));
|
||||||
constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
constraints.add(new UnifyPair(type2, type1, PairOperator.SMALLER));
|
||||||
type1 = new ReferenceType("Object");
|
type1 = new ReferenceType("Object");
|
||||||
type2 = new ReferenceType("Integer");
|
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());
|
IFiniteClosure finiteClosure = new FiniteClosure(constraints, new NullWriter());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user