transcendental-lisp/test/function/builtin/cons/CDRTester.java

48 lines
1.1 KiB
Java
Raw Normal View History

package function.builtin.cons;
import static testutil.TestUtilities.*;
import org.junit.Test;
import function.ArgumentValidator.*;
public class CDRTester {
@Test
public void testCdrWithNil() {
String input = "(cdr nil)";
assertSExpressionsMatch(parseString("()"), evaluateString(input));
}
@Test
public void testCdrWithList() {
String input = "(cdr '(1 2 3))";
assertSExpressionsMatch(parseString("(2 3)"), evaluateString(input));
}
@Test
public void testNestedCdrWithList() {
String input = "(cdr (cdr '(1 2 3)))";
assertSExpressionsMatch(parseString("(3)"), evaluateString(input));
}
@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)");
}
}