2017-01-14 18:01:14 -05:00
|
|
|
package function.builtin.predicate;
|
2017-01-05 18:00:21 -05:00
|
|
|
|
|
|
|
import static testutil.TestUtilities.*;
|
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import function.ArgumentValidator.*;
|
|
|
|
|
|
|
|
public class LESSPTester {
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testLesspWithOneNumber_ReturnsT() {
|
|
|
|
String input = "(< 1)";
|
|
|
|
|
2017-01-27 10:51:25 -05:00
|
|
|
assertSExpressionsMatch(parseString("t"), evaluateString(input));
|
2017-01-05 18:00:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testLesspWithTwoNumbers_ReturnsNil() {
|
|
|
|
String input = "(< 2 1)";
|
|
|
|
|
2017-01-27 10:51:25 -05:00
|
|
|
assertSExpressionsMatch(parseString("nil"), evaluateString(input));
|
2017-01-05 18:00:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testLesspWithTwoNumbers_ReturnsT() {
|
|
|
|
String input = "(< 2 3)";
|
|
|
|
|
2017-01-27 10:51:25 -05:00
|
|
|
assertSExpressionsMatch(parseString("t"), evaluateString(input));
|
2017-01-05 18:00:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testLesspWithManyNumbers_ReturnsNil() {
|
|
|
|
String input = "(< 4 3 2 5 1)";
|
|
|
|
|
2017-01-27 10:51:25 -05:00
|
|
|
assertSExpressionsMatch(parseString("nil"), evaluateString(input));
|
2017-01-05 18:00:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testLesspWithManyNumbers_ReturnsT() {
|
|
|
|
String input = "(< 0 1 2 3 4)";
|
|
|
|
|
2017-01-27 10:51:25 -05:00
|
|
|
assertSExpressionsMatch(parseString("t"), evaluateString(input));
|
2017-01-05 18:00:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test(expected = BadArgumentTypeException.class)
|
|
|
|
public void testLesspWithNonNumbers() {
|
|
|
|
evaluateString("(< '(1) '(2))");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test(expected = TooFewArgumentsException.class)
|
|
|
|
public void testLesspWithTooFewArguments() {
|
|
|
|
evaluateString("(<)");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|