transcendental-lisp/test/testutil/TypeAssertions.java

72 lines
2.3 KiB
Java
Raw Normal View History

package testutil;
import static org.junit.Assert.*;
import sexpression.*;
2017-01-27 11:37:11 -05:00
public final class TypeAssertions {
public static void assertList(SExpression sExpression) {
assertFalse(sExpression.atomp());
assertTrue(sExpression.consp());
assertFalse(sExpression.functionp());
assertTrue(sExpression.listp());
assertFalse(sExpression.nullp());
assertFalse(sExpression.numberp());
assertFalse(sExpression.stringp());
assertFalse(sExpression.symbolp());
}
public static void assertNil(SExpression sExpression) {
assertEquals(Nil.getInstance(), sExpression);
assertTrue(sExpression.atomp());
assertFalse(sExpression.consp());
assertFalse(sExpression.functionp());
assertTrue(sExpression.listp());
assertTrue(sExpression.nullp());
assertFalse(sExpression.numberp());
assertFalse(sExpression.stringp());
assertTrue(sExpression.symbolp());
}
public static void assertNumber(SExpression sExpression) {
assertTrue(sExpression.atomp());
assertFalse(sExpression.consp());
assertFalse(sExpression.functionp());
assertFalse(sExpression.listp());
assertFalse(sExpression.nullp());
assertTrue(sExpression.numberp());
assertFalse(sExpression.stringp());
assertFalse(sExpression.symbolp());
}
public static void assertString(SExpression sExpression) {
assertTrue(sExpression.atomp());
assertFalse(sExpression.consp());
assertFalse(sExpression.functionp());
assertFalse(sExpression.listp());
assertFalse(sExpression.nullp());
assertFalse(sExpression.numberp());
assertTrue(sExpression.stringp());
assertFalse(sExpression.symbolp());
}
public static void assertSymbol(SExpression sExpression) {
assertTrue(sExpression.atomp());
assertFalse(sExpression.consp());
assertFalse(sExpression.functionp());
assertFalse(sExpression.listp());
assertFalse(sExpression.nullp());
assertFalse(sExpression.numberp());
assertFalse(sExpression.stringp());
assertTrue(sExpression.symbolp());
}
2017-01-27 11:37:11 -05:00
public static void assertT(SExpression sExpression) {
assertEquals(Symbol.T, sExpression);
}
}