transcendental-lisp/test/testutil/TypeAssertions.java

74 lines
2.4 KiB
Java
Raw Normal View History

package testutil;
import static org.junit.Assert.*;
import static sexpression.Nil.NIL;
import static sexpression.Symbol.T;
import sexpression.SExpression;
2017-01-27 11:37:11 -05:00
public final class TypeAssertions {
public static void assertList(SExpression sExpression) {
assertFalse(sExpression.isAtom());
assertTrue(sExpression.isCons());
assertFalse(sExpression.isFunction());
assertTrue(sExpression.isList());
assertFalse(sExpression.isNull());
assertFalse(sExpression.isNumber());
assertFalse(sExpression.isString());
assertFalse(sExpression.isSymbol());
}
public static void assertNil(SExpression sExpression) {
assertEquals(NIL, sExpression);
assertTrue(sExpression.isAtom());
assertFalse(sExpression.isCons());
assertFalse(sExpression.isFunction());
assertTrue(sExpression.isList());
assertTrue(sExpression.isNull());
assertFalse(sExpression.isNumber());
assertFalse(sExpression.isString());
assertTrue(sExpression.isSymbol());
}
public static void assertNumber(SExpression sExpression) {
assertTrue(sExpression.isAtom());
assertFalse(sExpression.isCons());
assertFalse(sExpression.isFunction());
assertFalse(sExpression.isList());
assertFalse(sExpression.isNull());
assertTrue(sExpression.isNumber());
assertFalse(sExpression.isString());
assertFalse(sExpression.isSymbol());
}
public static void assertString(SExpression sExpression) {
assertTrue(sExpression.isAtom());
assertFalse(sExpression.isCons());
assertFalse(sExpression.isFunction());
assertFalse(sExpression.isList());
assertFalse(sExpression.isNull());
assertFalse(sExpression.isNumber());
assertTrue(sExpression.isString());
assertFalse(sExpression.isSymbol());
}
public static void assertSymbol(SExpression sExpression) {
assertTrue(sExpression.isAtom());
assertFalse(sExpression.isCons());
assertFalse(sExpression.isFunction());
assertFalse(sExpression.isList());
assertFalse(sExpression.isNull());
assertFalse(sExpression.isNumber());
assertFalse(sExpression.isString());
assertTrue(sExpression.isSymbol());
}
2017-01-27 11:37:11 -05:00
public static void assertT(SExpression sExpression) {
assertEquals(T, sExpression);
2017-01-27 11:37:11 -05:00
}
}