69 lines
2.2 KiB
Java
69 lines
2.2 KiB
Java
|
package parser;
|
||
|
|
||
|
import static org.junit.Assert.*;
|
||
|
|
||
|
import sexpression.Nil;
|
||
|
import sexpression.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(sExpression, Nil.getUniqueInstance());
|
||
|
|
||
|
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());
|
||
|
}
|
||
|
|
||
|
}
|