2017-02-05 16:00:56 -05:00
|
|
|
package function.builtin.special;
|
|
|
|
|
|
|
|
import static testutil.TestUtilities.*;
|
|
|
|
import static testutil.TypeAssertions.*;
|
|
|
|
|
2017-07-19 15:23:15 -04:00
|
|
|
import org.junit.Test;
|
2017-02-05 16:00:56 -05:00
|
|
|
|
|
|
|
import function.builtin.EVAL.UndefinedSymbolException;
|
|
|
|
import sexpression.LispNumber;
|
2017-07-19 15:23:15 -04:00
|
|
|
import testutil.SymbolAndFunctionCleaner;
|
2017-02-05 16:00:56 -05:00
|
|
|
|
2017-07-19 15:23:15 -04:00
|
|
|
public class ORTest extends SymbolAndFunctionCleaner {
|
2017-02-05 16:00:56 -05:00
|
|
|
|
|
|
|
@Test
|
|
|
|
public void orByItself() {
|
|
|
|
String input = "(or)";
|
|
|
|
|
|
|
|
assertNil(evaluateString(input));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void orWithNil() {
|
|
|
|
String input = "(or nil)";
|
|
|
|
|
|
|
|
assertNil(evaluateString(input));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void orWithT() {
|
|
|
|
String input = "(or t)";
|
|
|
|
|
|
|
|
assertT(evaluateString(input));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void orWithNumber() {
|
|
|
|
String input = "(or 7)";
|
|
|
|
|
|
|
|
assertSExpressionsMatch(new LispNumber("7"), evaluateString(input));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void orWithSeveralValues() {
|
|
|
|
String input = "(or nil nil nil t nil)";
|
|
|
|
|
|
|
|
assertT(evaluateString(input));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void orWithSeveralNumbers() {
|
|
|
|
String input = "(or 1 2 3)";
|
|
|
|
|
|
|
|
assertSExpressionsMatch(new LispNumber("1"), evaluateString(input));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test(expected = UndefinedSymbolException.class)
|
|
|
|
public void orShortCircuits() {
|
2017-03-07 16:41:26 -05:00
|
|
|
String input = "(or t (setq x 22))";
|
2017-02-05 16:00:56 -05:00
|
|
|
|
|
|
|
assertT(evaluateString(input));
|
|
|
|
evaluateString("x");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|