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.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.getInstance(), 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(Symbol.T, sExpression);
}
}