package function.builtin; import static testutil.TestUtilities.*; import org.junit.Test; import function.ArgumentValidator.*; public class EQUALTester { @Test public void testCarWithNil() { String input = "(car nil)"; assertSExpressionsMatch(evaluateString(input), parseString("()")); } @Test public void testCarWithList() { String input = "(car '(1 2 3))"; assertSExpressionsMatch(evaluateString(input), parseString("1")); } @Test public void testNestedCarWithList() { String input = "(car (car '((1 2) 3)))"; assertSExpressionsMatch(evaluateString(input), parseString("1")); } @Test(expected = BadArgumentTypeException.class) public void testCarWithNonList() { evaluateString("(car 'x)"); } @Test(expected = TooManyArgumentsException.class) public void testCarWithTooManyArguments() { evaluateString("(car '(1 2) '(1 2) \"oh\")"); } @Test(expected = TooFewArgumentsException.class) public void testCarWithTooFewArguments() { evaluateString("(car)"); } }