forked from JavaTX/JavaCompilerCore
44 lines
1.3 KiB
Java
44 lines
1.3 KiB
Java
package strucType;
|
|
|
|
import java.util.HashSet;
|
|
import java.util.Optional;
|
|
import java.util.Set;
|
|
|
|
import org.junit.Test;
|
|
|
|
import de.dhbwstuttgart.strucTypes.RuleSetStrucType;
|
|
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
|
|
import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
|
import de.dhbwstuttgart.typeinference.unify.model.ReferenceType;
|
|
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
|
import junit.framework.Assert;
|
|
|
|
public class TestRuleSetStrucType {
|
|
|
|
@Test
|
|
public void testRefl() {
|
|
|
|
Set<UnifyPair> pairs = new HashSet<>();
|
|
|
|
ReferenceType t = new ReferenceType("t");
|
|
PlaceholderType T1 = new PlaceholderType("T1");
|
|
PlaceholderType T2 = new PlaceholderType("T2");
|
|
PlaceholderType T3 = new PlaceholderType("T3");
|
|
|
|
UnifyPair p1 = UnifyTypeFactory.generateSmallerDotPair(t, T1);
|
|
UnifyPair p2 = UnifyTypeFactory.generateSmallerDotPair(T1, T3);
|
|
UnifyPair p3 = UnifyTypeFactory.generateSmallerDotPair(T1, T2);
|
|
UnifyPair p4 = UnifyTypeFactory.generateSmallerDotPair(T2, t);
|
|
|
|
pairs.add(p1);
|
|
pairs.add(p2);
|
|
pairs.add(p3);
|
|
pairs.add(p4);
|
|
|
|
RuleSetStrucType rules = new RuleSetStrucType();
|
|
Optional<Set<UnifyPair>> opt = rules.refl(pairs);
|
|
// System.out.println(opt.get());
|
|
Assert.assertTrue("Refl: " + opt.get(),opt.isPresent());
|
|
}
|
|
}
|