Built-in function names are now defined through annotations
This commit is contained in:
parent
8fdaaeb23d
commit
462e5ea15e
|
@ -0,0 +1,11 @@
|
|||
package function;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface FunctionNames {
|
||||
|
||||
String[] value();
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package function.builtin;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "APPLY" })
|
||||
public class APPLY extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -9,6 +9,7 @@ import function.builtin.special.LAMBDA;
|
|||
import sexpression.*;
|
||||
import table.*;
|
||||
|
||||
@FunctionNames({ "EVAL" })
|
||||
public class EVAL extends LispFunction {
|
||||
|
||||
public static LispFunction lookupFunctionOrLambda(SExpression functionExpression) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import environment.RuntimeEnvironment;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "EXIT" })
|
||||
public class EXIT extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -6,6 +6,7 @@ import static function.builtin.cons.LIST.makeList;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "FUNCALL" })
|
||||
public class FUNCALL extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -11,6 +11,7 @@ import function.*;
|
|||
import parser.LispParser;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "LOAD" })
|
||||
public class LOAD extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -4,6 +4,7 @@ import environment.RuntimeEnvironment;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "PRINT" })
|
||||
public class PRINT extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -4,6 +4,7 @@ import function.*;
|
|||
import sexpression.*;
|
||||
import table.*;
|
||||
|
||||
@FunctionNames({ "SET" })
|
||||
public class SET extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -7,6 +7,7 @@ import function.*;
|
|||
import sexpression.*;
|
||||
import table.FunctionTable;
|
||||
|
||||
@FunctionNames({ "SYMBOL-FUNCTION" })
|
||||
public class SYMBOL_FUNCTION extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -3,6 +3,7 @@ package function.builtin.cons;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "CONS" })
|
||||
public class CONS extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -3,6 +3,7 @@ package function.builtin.cons;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "FIRST", "CAR" })
|
||||
public class FIRST extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.math.BigInteger;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "LENGTH" })
|
||||
public class LENGTH extends LispFunction {
|
||||
|
||||
public static BigInteger getLength(Cons list) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package function.builtin.cons;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "LIST" })
|
||||
public class LIST extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -3,6 +3,7 @@ package function.builtin.cons;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "REST", "CDR" })
|
||||
public class REST extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.math.BigInteger;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "/" })
|
||||
public class DIVIDE extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.math.BigInteger;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "-" })
|
||||
public class MINUS extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -3,6 +3,7 @@ package function.builtin.math;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "*" })
|
||||
public class MULTIPLY extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -3,6 +3,7 @@ package function.builtin.math;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "+" })
|
||||
public class PLUS extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -3,6 +3,7 @@ package function.builtin.predicate;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "ATOM" })
|
||||
public class ATOM extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -3,6 +3,7 @@ package function.builtin.predicate;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "EQ" })
|
||||
public class EQ extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -4,6 +4,7 @@ import function.*;
|
|||
import function.builtin.cons.LIST;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "EQUAL" })
|
||||
public class EQUAL extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -3,6 +3,7 @@ package function.builtin.predicate;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "=" })
|
||||
public class EQUALSP extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -3,6 +3,7 @@ package function.builtin.predicate;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ ">" })
|
||||
public class GREATERP extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -3,6 +3,7 @@ package function.builtin.predicate;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "<" })
|
||||
public class LESSP extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -3,6 +3,7 @@ package function.builtin.predicate;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "LISTP" })
|
||||
public class LISTP extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -3,6 +3,7 @@ package function.builtin.predicate;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "NULL" })
|
||||
public class NULL extends LispFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -5,6 +5,7 @@ import static function.builtin.EVAL.eval;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "AND" })
|
||||
public class AND extends LispSpecialFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -5,6 +5,7 @@ import static function.builtin.EVAL.eval;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "COND" })
|
||||
public class COND extends LispSpecialFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -3,6 +3,7 @@ package function.builtin.special;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "DEFINE-MACRO" })
|
||||
public class DEFINE_MACRO extends Define {
|
||||
|
||||
public DEFINE_MACRO() {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package function.builtin.special;
|
||||
|
||||
import function.UserDefinedFunction;
|
||||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "DEFUN" })
|
||||
public class DEFUN extends Define {
|
||||
|
||||
public DEFUN() {
|
||||
|
|
|
@ -5,6 +5,7 @@ import static function.builtin.EVAL.eval;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "IF" })
|
||||
public class IF extends LispSpecialFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -5,6 +5,7 @@ import static function.builtin.cons.LIST.makeList;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "LAMBDA" })
|
||||
public class LAMBDA extends LispSpecialFunction {
|
||||
|
||||
public static boolean isLambdaExpression(SExpression sexpr) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import function.*;
|
|||
import sexpression.*;
|
||||
import table.*;
|
||||
|
||||
@FunctionNames({ "LET" })
|
||||
public class LET extends LispSpecialFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -5,6 +5,7 @@ import static function.builtin.EVAL.eval;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "OR" })
|
||||
public class OR extends LispSpecialFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -3,6 +3,7 @@ package function.builtin.special;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "QUOTE" })
|
||||
public class QUOTE extends LispSpecialFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -7,6 +7,7 @@ import static function.builtin.cons.LIST.makeList;
|
|||
import function.*;
|
||||
import sexpression.*;
|
||||
|
||||
@FunctionNames({ "SETF", "SETQ" })
|
||||
public class SETF extends LispSpecialFunction {
|
||||
|
||||
private ArgumentValidator argumentValidator;
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package table;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
|
||||
import function.LispFunction;
|
||||
import error.CriticalLispException;
|
||||
import function.*;
|
||||
import function.builtin.*;
|
||||
import function.builtin.cons.*;
|
||||
import function.builtin.math.*;
|
||||
|
@ -11,72 +13,132 @@ import function.builtin.special.*;
|
|||
|
||||
public class FunctionTable {
|
||||
|
||||
private static FunctionTable uniqueInstance = new FunctionTable();
|
||||
|
||||
public static LispFunction lookupFunction(String functionName) {
|
||||
return uniqueInstance.functionTable.get(functionName);
|
||||
return getTable().get(functionName);
|
||||
}
|
||||
|
||||
public static boolean isAlreadyDefined(String functionName) {
|
||||
return uniqueInstance.functionTable.containsKey(functionName);
|
||||
return getTable().containsKey(functionName);
|
||||
}
|
||||
|
||||
public static void defineFunction(String functionName, LispFunction function) {
|
||||
uniqueInstance.functionTable.put(functionName, function);
|
||||
getTable().put(functionName, function);
|
||||
}
|
||||
|
||||
public static void reset() {
|
||||
uniqueInstance.initializeFunctionTable();
|
||||
getUniqueInstance().initializeFunctionTable(allBuiltIns);
|
||||
}
|
||||
|
||||
private HashMap<String, LispFunction> functionTable;
|
||||
static void reset(Set<Class<? extends LispFunction>> builtIns) {
|
||||
getUniqueInstance().initializeFunctionTable(builtIns);
|
||||
}
|
||||
|
||||
private static Set<Class<? extends LispFunction>> allBuiltIns = new HashSet<>();
|
||||
|
||||
static {
|
||||
allBuiltIns.add(AND.class);
|
||||
allBuiltIns.add(APPLY.class);
|
||||
allBuiltIns.add(ATOM.class);
|
||||
allBuiltIns.add(COND.class);
|
||||
allBuiltIns.add(CONS.class);
|
||||
allBuiltIns.add(DEFINE_MACRO.class);
|
||||
allBuiltIns.add(DEFUN.class);
|
||||
allBuiltIns.add(DIVIDE.class);
|
||||
allBuiltIns.add(EQ.class);
|
||||
allBuiltIns.add(EQUAL.class);
|
||||
allBuiltIns.add(EQUALSP.class);
|
||||
allBuiltIns.add(EVAL.class);
|
||||
allBuiltIns.add(EXIT.class);
|
||||
allBuiltIns.add(FIRST.class);
|
||||
allBuiltIns.add(FUNCALL.class);
|
||||
allBuiltIns.add(GREATERP.class);
|
||||
allBuiltIns.add(IF.class);
|
||||
allBuiltIns.add(LAMBDA.class);
|
||||
allBuiltIns.add(LENGTH.class);
|
||||
allBuiltIns.add(LESSP.class);
|
||||
allBuiltIns.add(LET.class);
|
||||
allBuiltIns.add(LIST.class);
|
||||
allBuiltIns.add(LISTP.class);
|
||||
allBuiltIns.add(LOAD.class);
|
||||
allBuiltIns.add(MINUS.class);
|
||||
allBuiltIns.add(MULTIPLY.class);
|
||||
allBuiltIns.add(NULL.class);
|
||||
allBuiltIns.add(OR.class);
|
||||
allBuiltIns.add(PLUS.class);
|
||||
allBuiltIns.add(PRINT.class);
|
||||
allBuiltIns.add(QUOTE.class);
|
||||
allBuiltIns.add(REST.class);
|
||||
allBuiltIns.add(SET.class);
|
||||
allBuiltIns.add(SETF.class);
|
||||
allBuiltIns.add(SYMBOL_FUNCTION.class);
|
||||
}
|
||||
|
||||
private static FunctionTable uniqueInstance;
|
||||
|
||||
private static FunctionTable getUniqueInstance() {
|
||||
if (uniqueInstance == null) {
|
||||
uniqueInstance = new FunctionTable();
|
||||
}
|
||||
|
||||
return uniqueInstance;
|
||||
}
|
||||
|
||||
private static Map<String, LispFunction> getTable() {
|
||||
return getUniqueInstance().table;
|
||||
}
|
||||
|
||||
private Map<String, LispFunction> table;
|
||||
|
||||
private FunctionTable() {
|
||||
initializeFunctionTable();
|
||||
initializeFunctionTable(allBuiltIns);
|
||||
}
|
||||
|
||||
private void initializeFunctionTable() {
|
||||
functionTable = new HashMap<>();
|
||||
private void initializeFunctionTable(Set<Class<? extends LispFunction>> builtIns) {
|
||||
table = new HashMap<>();
|
||||
|
||||
functionTable.put("*", new MULTIPLY());
|
||||
functionTable.put("+", new PLUS());
|
||||
functionTable.put("-", new MINUS());
|
||||
functionTable.put("/", new DIVIDE());
|
||||
functionTable.put("<", new LESSP());
|
||||
functionTable.put("=", new EQUALSP());
|
||||
functionTable.put(">", new GREATERP());
|
||||
functionTable.put("AND", new AND());
|
||||
functionTable.put("APPLY", new APPLY());
|
||||
functionTable.put("ATOM", new ATOM());
|
||||
functionTable.put("CAR", new FIRST());
|
||||
functionTable.put("CDR", new REST());
|
||||
functionTable.put("COND", new COND());
|
||||
functionTable.put("CONS", new CONS());
|
||||
functionTable.put("DEFINE-MACRO", new DEFINE_MACRO());
|
||||
functionTable.put("DEFUN", new DEFUN());
|
||||
functionTable.put("EQ", new EQ());
|
||||
functionTable.put("EQUAL", new EQUAL());
|
||||
functionTable.put("EVAL", new EVAL());
|
||||
functionTable.put("EXIT", new EXIT());
|
||||
functionTable.put("FIRST", new FIRST());
|
||||
functionTable.put("FUNCALL", new FUNCALL());
|
||||
functionTable.put("GREATERP", new GREATERP());
|
||||
functionTable.put("IF", new IF());
|
||||
functionTable.put("LAMBDA", new LAMBDA());
|
||||
functionTable.put("LENGTH", new LENGTH());
|
||||
functionTable.put("LET", new LET());
|
||||
functionTable.put("LIST", new LIST());
|
||||
functionTable.put("LISTP", new LISTP());
|
||||
functionTable.put("LOAD", new LOAD());
|
||||
functionTable.put("NULL", new NULL());
|
||||
functionTable.put("OR", new OR());
|
||||
functionTable.put("PRINT", new PRINT());
|
||||
functionTable.put("QUOTE", new QUOTE());
|
||||
functionTable.put("REST", new REST());
|
||||
functionTable.put("SET", new SET());
|
||||
functionTable.put("SETF", new SETF());
|
||||
functionTable.put("SETQ", new SETF());
|
||||
functionTable.put("SYMBOL-FUNCTION", new SYMBOL_FUNCTION());
|
||||
for (Class<? extends LispFunction> function : builtIns)
|
||||
addBuiltInFunctionToTable(function);
|
||||
}
|
||||
|
||||
private void addBuiltInFunctionToTable(Class<? extends LispFunction> function) {
|
||||
FunctionNames functionNames = function.getAnnotation(FunctionNames.class);
|
||||
|
||||
if (functionNames != null)
|
||||
addAllFunctionNamesToTable(function, functionNames.value());
|
||||
}
|
||||
|
||||
private void addAllFunctionNamesToTable(Class<? extends LispFunction> function, String[] names) {
|
||||
LispFunction instance = createInstance(function);
|
||||
|
||||
for (String name : names)
|
||||
table.put(name, instance);
|
||||
}
|
||||
|
||||
private LispFunction createInstance(Class<? extends LispFunction> function) {
|
||||
LispFunction instance = null;
|
||||
|
||||
try {
|
||||
instance = function.getConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new LispFunctionInstantiationException(function.getName());
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static class LispFunctionInstantiationException extends CriticalLispException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String functionName;
|
||||
|
||||
public LispFunctionInstantiationException(String functionName) {
|
||||
this.functionName = functionName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return MessageFormat.format("Could not create an instance of ''{0}''", functionName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,13 +2,47 @@ package table;
|
|||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.junit.*;
|
||||
|
||||
import function.LispFunction;
|
||||
import error.ErrorManager;
|
||||
import function.*;
|
||||
import sexpression.*;
|
||||
import table.FunctionTable.LispFunctionInstantiationException;
|
||||
|
||||
public class FunctionTableTester {
|
||||
|
||||
@FunctionNames({ "GOOD" })
|
||||
public static class GoodFunction extends LispFunction {
|
||||
|
||||
@Override
|
||||
public SExpression call(Cons argList) {
|
||||
return Nil.getInstance();
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionNames({ "BAD" })
|
||||
public static class BadFunction extends LispFunction {
|
||||
|
||||
public BadFunction() {
|
||||
throw new IllegalArgumentException("bad function");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SExpression call(Cons argList) {
|
||||
return Nil.getInstance();
|
||||
}
|
||||
}
|
||||
|
||||
public static class NamelessFunction extends LispFunction {
|
||||
|
||||
@Override
|
||||
public SExpression call(Cons argList) {
|
||||
return Nil.getInstance();
|
||||
}
|
||||
}
|
||||
|
||||
private LispFunction createLispFunction() {
|
||||
return new LispFunction() {
|
||||
|
||||
|
@ -30,7 +64,7 @@ public class FunctionTableTester {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void builtinFunctionIsDefined() {
|
||||
public void builtInFunctionIsDefined() {
|
||||
assertTrue(FunctionTable.isAlreadyDefined("CONS"));
|
||||
}
|
||||
|
||||
|
@ -40,7 +74,7 @@ public class FunctionTableTester {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void lookupBuiltinFunction_ReturnsFunction() {
|
||||
public void lookupBuiltInFunction_ReturnsFunction() {
|
||||
assertNotNull(FunctionTable.lookupFunction("CONS"));
|
||||
}
|
||||
|
||||
|
@ -68,10 +102,50 @@ public class FunctionTableTester {
|
|||
String functionName = "testFunction";
|
||||
LispFunction testFunction = createLispFunction();
|
||||
FunctionTable.defineFunction(functionName, testFunction);
|
||||
|
||||
FunctionTable.reset();
|
||||
|
||||
assertFalse(FunctionTable.isAlreadyDefined(functionName));
|
||||
assertNull(FunctionTable.lookupFunction(functionName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resetWithCustomBuitIns() {
|
||||
Set<Class<? extends LispFunction>> goodBuiltIns = new HashSet<>();
|
||||
goodBuiltIns.add(GoodFunction.class);
|
||||
|
||||
FunctionTable.reset(goodBuiltIns);
|
||||
|
||||
assertTrue(FunctionTable.isAlreadyDefined("GOOD"));
|
||||
assertNotNull(FunctionTable.lookupFunction("GOOD"));
|
||||
}
|
||||
|
||||
@Test(expected = LispFunctionInstantiationException.class)
|
||||
public void unableToInitializeBuiltIn() {
|
||||
Set<Class<? extends LispFunction>> badBuiltIns = new HashSet<>();
|
||||
badBuiltIns.add(BadFunction.class);
|
||||
|
||||
FunctionTable.reset(badBuiltIns);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lispFunctionInstantiationException_HasCorrectAttributes() {
|
||||
LispFunctionInstantiationException e = new LispFunctionInstantiationException("Bad");
|
||||
|
||||
assertNotNull(e.getMessage());
|
||||
assertTrue(e.getMessage().length() > 0);
|
||||
assertEquals(ErrorManager.Severity.CRITICAL, e.getSeverity());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void namelessBuiltIn_DoesNotCauseNPE() {
|
||||
Set<Class<? extends LispFunction>> namelessBuiltins = new HashSet<>();
|
||||
namelessBuiltins.add(NamelessFunction.class);
|
||||
|
||||
FunctionTable.reset(namelessBuiltins);
|
||||
|
||||
assertFalse(FunctionTable.isAlreadyDefined("NAMELESS"));
|
||||
assertNull(FunctionTable.lookupFunction("NAMELESS"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue