package asp.unifywithoutwildcards;

import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.sat.asp.writer.ASPFactory;
import de.dhbwstuttgart.sat.asp.writer.ASPStatement;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typeinference.constraints.Constraint;
import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
import org.junit.Test;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class ASPFactoryTest extends ASPFactory {
    @Test
    public void undConstraintTest(){
        TypePlaceholder tph = TypePlaceholder.fresh(new NullToken());
        Constraint<Pair> toTest = new Constraint();
        for(int i = 0; i<5;i++){
            toTest.add(new Pair(tph, tph, PairOperator.EQUALSDOT));
        }
        List<ASPStatement> undCons = new ArrayList<>();
        for(Pair p : toTest){
            undCons.add(generatePairStmt(p));
        }
        ASPStatement ret = convertListToUndConstraint(undCons);
        System.out.println(ret.getASP());
    }

    @Test
    public void oderConstraintTest(){
        TypePlaceholder tph = TypePlaceholder.fresh(new NullToken());
        Set<Constraint<Pair>> oderTest = new HashSet<>();
        for(int i = 0; i<5;i++){
            Constraint<Pair> toTest = new Constraint();
            toTest.add(new Pair(tph, tph, PairOperator.EQUALSDOT));
            oderTest.add(toTest);
        }
        this.convertOderConstraint(oderTest);
        System.out.println(this.writer.getASPFile());
    }
}