2016-12-22 10:32:48 -05:00
|
|
|
package testutil;
|
2016-12-16 11:26:53 -05:00
|
|
|
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
2016-12-22 10:32:48 -05:00
|
|
|
import sexpression.*;
|
2016-12-16 11:26:53 -05:00
|
|
|
|
2017-01-27 11:37:11 -05:00
|
|
|
public final class TypeAssertions {
|
2016-12-16 11:26:53 -05:00
|
|
|
|
|
|
|
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) {
|
2017-01-18 16:25:09 -05:00
|
|
|
assertEquals(Nil.getInstance(), sExpression);
|
2016-12-16 11:26:53 -05:00
|
|
|
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
2017-01-27 11:37:11 -05:00
|
|
|
public static void assertT(SExpression sExpression) {
|
|
|
|
assertEquals(Symbol.T, sExpression);
|
|
|
|
}
|
|
|
|
|
2016-12-16 11:26:53 -05:00
|
|
|
}
|