42 lines
1.0 KiB
Java
42 lines
1.0 KiB
Java
package function.builtin.special;
|
|
|
|
import static testutil.TestUtilities.*;
|
|
|
|
import org.junit.Test;
|
|
|
|
import function.ArgumentValidator.*;
|
|
|
|
public class DEFUNTester {
|
|
|
|
@Test
|
|
public void testDefun() {
|
|
String input = "(defun f () nil)";
|
|
|
|
assertSExpressionsMatch(parseString("f"), evaluateString(input));
|
|
assertSExpressionsMatch(parseString("()"), evaluateString("(f)"));
|
|
}
|
|
|
|
@Test(expected = DottedArgumentListException.class)
|
|
public void testDefunWithDottedLambdaList() {
|
|
String input = "(funcall 'defun 'x (cons 'a 'b) ())";
|
|
|
|
evaluateString(input);
|
|
}
|
|
|
|
@Test(expected = BadArgumentTypeException.class)
|
|
public void testDefunWithNonSymbolName() {
|
|
evaluateString("(defun 1 () ())");
|
|
}
|
|
|
|
@Test(expected = BadArgumentTypeException.class)
|
|
public void testDefunWithBadLambdaList() {
|
|
evaluateString("(defun x a ())");
|
|
}
|
|
|
|
@Test(expected = TooFewArgumentsException.class)
|
|
public void testApplyWithTooFewArguments() {
|
|
evaluateString("(defun x ())");
|
|
}
|
|
|
|
}
|