transcendental-lisp/test/function/builtin/special/DEFUNTester.java

42 lines
1.0 KiB
Java
Raw Normal View History

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(evaluateString(input), parseString("f"));
assertSExpressionsMatch(evaluateString("(f)"), parseString("()"));
}
@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 ())");
}
}