JavaTXCompilerInJavaTX/test/unify/Test.java
2017-10-18 14:30:31 +02:00

33 lines
1.5 KiB
Java

package unify;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
import de.dhbwstuttgart.typeinference.unify.model.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Created by janulrich on 13.10.17.
*/
public class Test {
@org.junit.Test
public void test() throws ClassNotFoundException {
List<ClassOrInterface> availableClasses = new ArrayList<>();
availableClasses.add(ASTFactory.createClass(Class.forName("java.util.List")));
availableClasses.add(ASTFactory.createClass(Class.forName("java.util.AbstractList")));
FiniteClosure fc = UnifyTypeFactory.generateFC(availableClasses);
TypeUnify typeUnify = new TypeUnify();
Set<UnifyPair> constraints = new HashSet<>();
System.out.println(fc);
constraints.add(new UnifyPair(new PlaceholderType("tpha"), new ReferenceType("java.util.AbstractList", new TypeParams(new PlaceholderType("b"))), PairOperator.SMALLERDOT));
//constraints.add(new UnifyPair(new PlaceholderType("tpha"), new ReferenceType("java.util.AbstractList", new TypeParams(
// new ReferenceType("java.util.AbstractList",new TypeParams(new ReferenceType("java.lang.Object", new TypeParams()))))), PairOperator.SMALLERDOT));
System.out.println(typeUnify.unify(constraints, fc));
}
}