package function.builtin; import static testutil.TestUtilities.*; import org.junit.Test; import function.ArgumentValidator.*; public class CDRTester { @Test public void testCdrWithNil() { String input = "(cdr nil)"; assertSExpressionsMatch(evaluateString(input), parseString("()")); } @Test public void testCdrWithList() { String input = "(cdr '(1 2 3))"; assertSExpressionsMatch(evaluateString(input), parseString("(2 3)")); } @Test public void testNestedCdrWithList() { String input = "(cdr (cdr '(1 2 3)))"; assertSExpressionsMatch(evaluateString(input), parseString("(3)")); } @Test(expected = BadArgumentTypeException.class) public void testCdrWithNonList() { evaluateString("(cdr 'x)"); } @Test(expected = TooManyArgumentsException.class) public void testCdrWithTooManyArguments() { evaluateString("(cdr '(1 2) '(1 2) \"oh\")"); } @Test(expected = TooFewArgumentsException.class) public void testCdrWithTooFewArguments() { evaluateString("(cdr)"); } }