68 lines
2.2 KiB
Java
68 lines
2.2 KiB
Java
package testutil;
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
import sexpression.*;
|
|
|
|
public final class SExpressionTypeAssertions {
|
|
|
|
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());
|
|
}
|
|
|
|
}
|