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) {
|
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-01-18 16:25:09 -05:00
|
|
|
assertEquals(Nil.getInstance(), 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) {
|
|
|
|
assertEquals(Symbol.T, sExpression);
|
|
|
|
}
|
|
|
|
|
2016-12-16 11:26:53 -05:00
|
|
|
}
|