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

70 lines
1.5 KiB
Java
Raw Normal View History

package function.builtin.predicate;
2017-01-27 11:37:11 -05:00
import static testutil.TestUtilities.evaluateString;
import static testutil.TypeAssertions.*;
import org.junit.Test;
import function.ArgumentValidator.*;
public class EQTester {
@Test
public void testEqWithEqualAtoms() {
String input = "(eq 1 1)";
2017-01-27 11:37:11 -05:00
assertT(evaluateString(input));
}
@Test
public void testEqWithUnequalAtoms() {
String input = "(eq 1 2)";
2017-01-27 11:37:11 -05:00
assertNil(evaluateString(input));
}
2017-01-27 11:37:11 -05:00
@Test
public void testEqWithAtomAndList() {
String input = "(eq 1 '(2))";
2017-01-27 11:37:11 -05:00
assertNil(evaluateString(input));
}
@Test
public void testEqWithSameList() {
String initializeL1 = "(setf l1 '(1 2 3))";
String initializeL2 = "(setf l2 l1)";
String input = "(eq l1 l2)";
evaluateString(initializeL1);
evaluateString(initializeL2);
2017-01-27 11:37:11 -05:00
assertT(evaluateString(input));
}
@Test
public void testEqWithEqualLists() {
String input = "(eq '(1 2) '(1 2))";
2017-01-27 11:37:11 -05:00
assertNil(evaluateString(input));
}
@Test
public void testEqWithUnequalLists() {
String input = "(eq '(1 2) '(3 4))";
2017-01-27 11:37:11 -05:00
assertNil(evaluateString(input));
}
@Test(expected = TooManyArgumentsException.class)
public void testEqWithTooManyArguments() {
evaluateString("(eq 'one 'two 'three)");
}
@Test(expected = TooFewArgumentsException.class)
public void testEqWithTooFewArguments() {
evaluateString("(eq 'one)");
}
}