transcendental-lisp/test/function/builtin/special/ANDTest.java

65 lines
1.4 KiB
Java

package function.builtin.special;
import static testutil.TestUtilities.*;
import static testutil.TypeAssertions.*;
import org.junit.Test;
import function.builtin.EVAL.UndefinedSymbolException;
import sexpression.LispNumber;
import testutil.SymbolAndFunctionCleaner;
public class ANDTest extends SymbolAndFunctionCleaner {
@Test
public void andByItself() {
String input = "(and)";
assertT(evaluateString(input));
}
@Test
public void andWithNil() {
String input = "(and nil)";
assertNil(evaluateString(input));
}
@Test
public void andWithT() {
String input = "(and t)";
assertT(evaluateString(input));
}
@Test
public void andWithNumber() {
String input = "(and 7)";
assertSExpressionsMatch(new LispNumber("7"), evaluateString(input));
}
@Test
public void andWithSeveralValues() {
String input = "(and t t nil t t)";
assertNil(evaluateString(input));
}
@Test
public void andWithSeveralNumbers() {
String input = "(and 1 2 3)";
assertSExpressionsMatch(new LispNumber("3"), evaluateString(input));
}
@Test(expected = UndefinedSymbolException.class)
public void andShortCircuits() {
String input = "(and nil (setq x 22))";
assertNil(evaluateString(input));
evaluateString("x");
}
}