33 lines
812 B
Java
33 lines
812 B
Java
|
package function.builtin;
|
||
|
|
||
|
import static testutil.TestUtilities.*;
|
||
|
|
||
|
import org.junit.Test;
|
||
|
|
||
|
import function.ArgumentValidator.TooFewArgumentsException;
|
||
|
|
||
|
public class FUNCALLTester {
|
||
|
|
||
|
@Test
|
||
|
public void testFuncallWithNumbers() {
|
||
|
String input = "(funcall '+ 1 2 3)";
|
||
|
|
||
|
assertSExpressionsMatch(evaluateString(input), parseString("6"));
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
public void testFuncallWithUserDefinedFunction() {
|
||
|
String defineUserFunction = "(defun x (n m) (+ n m))";
|
||
|
String input = "(funcall 'x 2 30)";
|
||
|
|
||
|
evaluateString(defineUserFunction);
|
||
|
assertSExpressionsMatch(evaluateString(input), parseString("32"));
|
||
|
}
|
||
|
|
||
|
@Test(expected = TooFewArgumentsException.class)
|
||
|
public void testFuncallWithTooFewArguments() {
|
||
|
evaluateString("(funcall)");
|
||
|
}
|
||
|
|
||
|
}
|