2016-12-22 10:32:48 -05:00
|
|
|
package testutil;
|
2016-12-16 11:26:53 -05:00
|
|
|
|
|
|
|
import static org.junit.Assert.*;
|
2017-03-02 09:54:23 -05:00
|
|
|
import static sexpression.Nil.NIL;
|
|
|
|
import static sexpression.Symbol.T;
|
2016-12-16 11:26:53 -05:00
|
|
|
|
2017-03-02 09:54:23 -05:00
|
|
|
import sexpression.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) {
|
2017-02-25 17:29:37 -05:00
|
|
|
assertFalse(sExpression.isAtom());
|
|
|
|
assertTrue(sExpression.isCons());
|
|
|
|
assertFalse(sExpression.isFunction());
|
|
|
|
assertTrue(sExpression.isList());
|
|
|
|
assertFalse(sExpression.isNull());
|
|
|
|
assertFalse(sExpression.isNumber());
|
|
|
|
assertFalse(sExpression.isString());
|
|
|
|
assertFalse(sExpression.isSymbol());
|
2016-12-16 11:26:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void assertNil(SExpression sExpression) {
|
2017-03-02 09:54:23 -05:00
|
|
|
assertEquals(NIL, sExpression);
|
2016-12-16 11:26:53 -05:00
|
|
|
|
2017-02-25 17:29:37 -05:00
|
|
|
assertTrue(sExpression.isAtom());
|
|
|
|
assertFalse(sExpression.isCons());
|
|
|
|
assertFalse(sExpression.isFunction());
|
|
|
|
assertTrue(sExpression.isList());
|
|
|
|
assertTrue(sExpression.isNull());
|
|
|
|
assertFalse(sExpression.isNumber());
|
|
|
|
assertFalse(sExpression.isString());
|
|
|
|
assertTrue(sExpression.isSymbol());
|
2016-12-16 11:26:53 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void assertNumber(SExpression sExpression) {
|
2017-02-25 17:29:37 -05:00
|
|
|
assertTrue(sExpression.isAtom());
|
|
|
|
assertFalse(sExpression.isCons());
|
|
|
|
assertFalse(sExpression.isFunction());
|
|
|
|
assertFalse(sExpression.isList());
|
|
|
|
assertFalse(sExpression.isNull());
|
|
|
|
assertTrue(sExpression.isNumber());
|
|
|
|
assertFalse(sExpression.isString());
|
|
|
|
assertFalse(sExpression.isSymbol());
|
2016-12-16 11:26:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void assertString(SExpression sExpression) {
|
2017-02-25 17:29:37 -05:00
|
|
|
assertTrue(sExpression.isAtom());
|
|
|
|
assertFalse(sExpression.isCons());
|
|
|
|
assertFalse(sExpression.isFunction());
|
|
|
|
assertFalse(sExpression.isList());
|
|
|
|
assertFalse(sExpression.isNull());
|
|
|
|
assertFalse(sExpression.isNumber());
|
|
|
|
assertTrue(sExpression.isString());
|
|
|
|
assertFalse(sExpression.isSymbol());
|
2016-12-16 11:26:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void assertSymbol(SExpression sExpression) {
|
2017-02-25 17:29:37 -05:00
|
|
|
assertTrue(sExpression.isAtom());
|
|
|
|
assertFalse(sExpression.isCons());
|
|
|
|
assertFalse(sExpression.isFunction());
|
|
|
|
assertFalse(sExpression.isList());
|
|
|
|
assertFalse(sExpression.isNull());
|
|
|
|
assertFalse(sExpression.isNumber());
|
|
|
|
assertFalse(sExpression.isString());
|
|
|
|
assertTrue(sExpression.isSymbol());
|
2016-12-16 11:26:53 -05:00
|
|
|
}
|
|
|
|
|
2017-01-27 11:37:11 -05:00
|
|
|
public static void assertT(SExpression sExpression) {
|
2017-03-02 09:54:23 -05:00
|
|
|
assertEquals(T, sExpression);
|
2017-01-27 11:37:11 -05:00
|
|
|
}
|
|
|
|
|
2016-12-16 11:26:53 -05:00
|
|
|
}
|