transcendental-lisp/test/function/builtin/predicate/NUMERIC_LESSTest.java

61 lines
1.4 KiB
Java
Raw Normal View History

package function.builtin.predicate;
2017-01-05 18:00:21 -05:00
2017-01-27 11:37:11 -05:00
import static testutil.TestUtilities.evaluateString;
2017-11-12 09:42:25 -05:00
import static testutil.TypeAssertions.assertNil;
import static testutil.TypeAssertions.assertT;
2017-01-05 18:00:21 -05:00
import org.junit.Test;
2017-11-12 09:42:25 -05:00
import function.ArgumentValidator.BadArgumentTypeException;
import function.ArgumentValidator.TooFewArgumentsException;
import testutil.SymbolAndFunctionCleaner;
2017-01-05 18:00:21 -05:00
public class NUMERIC_LESSTest extends SymbolAndFunctionCleaner {
2017-01-05 18:00:21 -05:00
@Test
public void lessThanWithOneNumber_ReturnsT() {
2017-01-05 18:00:21 -05:00
String input = "(< 1)";
2017-01-27 11:37:11 -05:00
assertT(evaluateString(input));
2017-01-05 18:00:21 -05:00
}
@Test
public void lessThanWithTwoNumbers_ReturnsNil() {
2017-01-05 18:00:21 -05:00
String input = "(< 2 1)";
2017-01-27 11:37:11 -05:00
assertNil(evaluateString(input));
2017-01-05 18:00:21 -05:00
}
@Test
public void lessThanWithTwoNumbers_ReturnsT() {
2017-01-05 18:00:21 -05:00
String input = "(< 2 3)";
2017-01-27 11:37:11 -05:00
assertT(evaluateString(input));
2017-01-05 18:00:21 -05:00
}
@Test
public void lessThanWithManyNumbers_ReturnsNil() {
2017-01-05 18:00:21 -05:00
String input = "(< 4 3 2 5 1)";
2017-01-27 11:37:11 -05:00
assertNil(evaluateString(input));
2017-01-05 18:00:21 -05:00
}
@Test
public void lessThanWithManyNumbers_ReturnsT() {
2017-01-05 18:00:21 -05:00
String input = "(< 0 1 2 3 4)";
2017-01-27 11:37:11 -05:00
assertT(evaluateString(input));
2017-01-05 18:00:21 -05:00
}
@Test(expected = BadArgumentTypeException.class)
public void lessThanWithNonNumbers() {
2017-01-05 18:00:21 -05:00
evaluateString("(< '(1) '(2))");
}
@Test(expected = TooFewArgumentsException.class)
public void lessThanWithTooFewArguments() {
2017-01-05 18:00:21 -05:00
evaluateString("(<)");
}
}