package function.builtin.cons; import static testutil.TestUtilities.*; import org.junit.Test; import function.ArgumentValidator.*; public class RESTTester { @Test public void restOfNil() { String input = "(rest nil)"; assertSExpressionsMatch(parseString("()"), evaluateString(input)); } @Test public void restOfList() { String input = "(rest '(1 2 3))"; assertSExpressionsMatch(parseString("(2 3)"), evaluateString(input)); } @Test public void cdrOfList() { String input = "(cdr '(1 2 3))"; assertSExpressionsMatch(parseString("(2 3)"), evaluateString(input)); } @Test public void nestedRestOfList() { String input = "(rest (rest '(1 2 3)))"; assertSExpressionsMatch(parseString("(3)"), evaluateString(input)); } @Test(expected = BadArgumentTypeException.class) public void restOfSymbol() { evaluateString("(rest 'x)"); } @Test(expected = TooManyArgumentsException.class) public void restWithTooManyArguments() { evaluateString("(rest '(1 2) '(1 2) \"oh\")"); } @Test(expected = TooFewArgumentsException.class) public void restWithTooFewArguments() { evaluateString("(rest)"); } }