package function.builtin.predicate;

import static testutil.TestUtilities.evaluateString;
import static testutil.TypeAssertions.*;

import org.junit.Test;

import function.ArgumentValidator.*;

public class EQTester {

    @Test
    public void testEqWithEqualAtoms() {
        String input = "(eq 1 1)";

        assertT(evaluateString(input));
    }

    @Test
    public void testEqWithUnequalAtoms() {
        String input = "(eq 1 2)";

        assertNil(evaluateString(input));
    }

    @Test
    public void testEqWithAtomAndList() {
        String input = "(eq 1 '(2))";

        assertNil(evaluateString(input));
    }

    @Test
    public void testEqWithSameList() {
        String initializeL1 = "(setf l1 '(1 2 3))";
        String initializeL2 = "(setf l2 l1)";
        String input = "(eq l1 l2)";

        evaluateString(initializeL1);
        evaluateString(initializeL2);

        assertT(evaluateString(input));
    }

    @Test
    public void testEqWithEqualLists() {
        String input = "(eq '(1 2) '(1 2))";

        assertNil(evaluateString(input));
    }

    @Test
    public void testEqWithUnequalLists() {
        String input = "(eq '(1 2) '(3 4))";

        assertNil(evaluateString(input));
    }

    @Test(expected = TooManyArgumentsException.class)
    public void testEqWithTooManyArguments() {
        evaluateString("(eq 'one 'two 'three)");
    }

    @Test(expected = TooFewArgumentsException.class)
    public void testEqWithTooFewArguments() {
        evaluateString("(eq 'one)");
    }

}
