<commit_before>package org.clafer;

import java.util.HashSet;
import java.util.Set;
import org.clafer.ast.AstConcreteClafer;
import org.clafer.ast.AstModel;
import static org.clafer.ast.Asts.*;
import org.clafer.collection.Pair;
import org.clafer.compiler.ClaferCompiler;
import org.clafer.compiler.ClaferSolver;
import org.clafer.instance.InstanceClafer;
import org.clafer.instance.InstanceModel;
import org.clafer.scope.Scope;
import static org.junit.Assert.*;
import org.junit.Test;

/**
 *
 * @author jimmy
 */
public class RelationalTest {

    /**
     * <pre>
     * A *
     *     B -> A*
     * [ (B -> parent) = (B -> ref) ]
     * </pre>
     */
    @Test(timeout = 60000)
    public void testFunctionEqualityFunction() {
        AstModel model = newModel();

        AstConcreteClafer a = model.addChild("A");
        AstConcreteClafer b = a.addChild("B").refToUnique(a);
        model.addConstraint(equal(parent(b), ref(b)));

        ClaferSolver solver = ClaferCompiler.compile(model, Scope.defaultScope(3).intLow(-3).intHigh(3));
        assertEquals(10, solver.allInstances().length);
    }

    /**
     * <pre>
     * A -> B
     *     B
     * [ (A -> ref) = (A -> B) ]
     * </pre>
     */
    @Test(timeout = 60000)
    public void testFunctionEqualityRelation() {
        AstModel model = newModel();

        AstConcreteClafer a = model.addChild("A");
        AstConcreteClafer b = a.addChild("B");
        a.refToUnique(b);
        model.addConstraint(equal(ref(a), relation(b)));

        ClaferSolver solver = ClaferCompiler.compile(model, Scope.defaultScope(3).intLow(-3).intHigh(3));
        assertEquals(1, solver.allInstances().length);<commit_msg>Fixed test to match example.<commit_after>package org.clafer;

import java.util.HashSet;
import java.util.Set;
import org.clafer.ast.AstConcreteClafer;
import org.clafer.ast.AstModel;
import static org.clafer.ast.Asts.*;
import org.clafer.collection.Pair;
import org.clafer.compiler.ClaferCompiler;
import org.clafer.compiler.ClaferSolver;
import org.clafer.instance.InstanceClafer;
import org.clafer.instance.InstanceModel;
import org.clafer.scope.Scope;
import static org.junit.Assert.*;
import org.junit.Test;

/**
 *
 * @author jimmy
 */
public class RelationalTest {

    /**
     * <pre>
     * A *
     *     B ->> A*
     * [ (B -> parent) = (B -> ref) ]
     * </pre>
     */
    @Test(timeout = 60000)
    public void testFunctionEqualityFunction() {
        AstModel model = newModel();

        AstConcreteClafer a = model.addChild("A");
        AstConcreteClafer b = a.addChild("B").refTo(a);
        model.addConstraint(equal(parent(b), ref(b)));

        ClaferSolver solver = ClaferCompiler.compile(model, Scope.defaultScope(3).intLow(-3).intHigh(3));
        assertEquals(18, solver.allInstances().length);
    }

    /**
     * <pre>
     * A -> B
     *     B
     * [ (A -> ref) = (A -> B) ]
     * </pre>
     */
    @Test(timeout = 60000)
    public void testFunctionEqualityRelation() {
        AstModel model = newModel();

        AstConcreteClafer a = model.addChild("A");
        AstConcreteClafer b = a.addChild("B");
        a.refToUnique(b);
        model.addConstraint(equal(ref(a), relation(b)));

        ClaferSolver solver = ClaferCompiler.compile(model, Scope.defaultScope(3).intLow(-3).intHigh(3));
        assertEquals(1, solver.allInstances().length);
{'fraction_non_alphanumeric': 0.15014836795252226, 'fraction_numerical': 0.011275964391691394, 'mean_word_length': 2.9197674418604653, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6977352', 'n_tokens_mistral': 1191, 'n_tokens_neox': 1124, 'n_words': 199}