package function.builtin.predicate; import static testutil.TestUtilities.*; import org.junit.Test; import function.ArgumentValidator.*; public class EQTester { @Test public void testEqWithEqualAtoms() { String input = "(eq 1 1)"; assertSExpressionsMatch(parseString("t"), evaluateString(input)); } @Test public void testEqWithUnequalAtoms() { String input = "(eq 1 2)"; assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test public void testEqWithAtomAndList() { String input = "(eq 1 '(2))"; assertSExpressionsMatch(parseString("nil"), 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); assertSExpressionsMatch(parseString("t"), evaluateString(input)); } @Test public void testEqWithEqualLists() { String input = "(eq '(1 2) '(1 2))"; assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test public void testEqWithUnequalLists() { String input = "(eq '(1 2) '(3 4))"; assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test(expected = TooManyArgumentsException.class) public void testEqWithTooManyArguments() { evaluateString("(eq 'one 'two 'three)"); } @Test(expected = TooFewArgumentsException.class) public void testEqWithTooFewArguments() { evaluateString("(eq 'one)"); } }