transcendental-lisp/test/testutil/TypeAssertions.java

130 lines
4.7 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());
2017-03-11 15:41:07 -05:00
assertFalse(sExpression.isBackTick());
assertFalse(sExpression.isComma());
assertFalse(sExpression.isAtSign());
}
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());
2017-03-11 15:41:07 -05:00
assertFalse(sExpression.isBackTick());
assertFalse(sExpression.isComma());
assertFalse(sExpression.isAtSign());
}
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());
2017-03-11 15:41:07 -05:00
assertFalse(sExpression.isBackTick());
assertFalse(sExpression.isComma());
assertFalse(sExpression.isAtSign());
}
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());
2017-03-11 15:41:07 -05:00
assertFalse(sExpression.isBackTick());
assertFalse(sExpression.isComma());
assertFalse(sExpression.isAtSign());
}
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-03-11 15:41:07 -05:00
assertFalse(sExpression.isBackTick());
assertFalse(sExpression.isComma());
assertFalse(sExpression.isAtSign());
}
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
}
2017-03-11 15:41:07 -05:00
public static void assertBackTickExpression(SExpression sExpression) {
assertFalse(sExpression.isAtom());
assertFalse(sExpression.isCons());
assertFalse(sExpression.isFunction());
assertFalse(sExpression.isList());
assertFalse(sExpression.isNull());
assertFalse(sExpression.isNumber());
assertFalse(sExpression.isString());
assertFalse(sExpression.isSymbol());
assertTrue(sExpression.isBackTick());
assertFalse(sExpression.isComma());
assertFalse(sExpression.isAtSign());
}
public static void assertCommaExpression(SExpression sExpression) {
assertFalse(sExpression.isAtom());
assertFalse(sExpression.isCons());
assertFalse(sExpression.isFunction());
assertFalse(sExpression.isList());
assertFalse(sExpression.isNull());
assertFalse(sExpression.isNumber());
assertFalse(sExpression.isString());
assertFalse(sExpression.isSymbol());
assertFalse(sExpression.isBackTick());
assertTrue(sExpression.isComma());
assertFalse(sExpression.isAtSign());
}
public static void assertAtSignExpression(SExpression sExpression) {
assertFalse(sExpression.isAtom());
assertFalse(sExpression.isCons());
assertFalse(sExpression.isFunction());
assertFalse(sExpression.isList());
assertFalse(sExpression.isNull());
assertFalse(sExpression.isNumber());
assertFalse(sExpression.isString());
assertFalse(sExpression.isSymbol());
assertFalse(sExpression.isBackTick());
assertFalse(sExpression.isComma());
assertTrue(sExpression.isAtSign());
}
}