68 lines
1.6 KiB
Java
68 lines
1.6 KiB
Java
package function.builtin;
|
|
|
|
import static testutil.TestUtilities.*;
|
|
|
|
import org.junit.Test;
|
|
|
|
import function.ArgumentValidator.*;
|
|
|
|
public class EQTester {
|
|
|
|
@Test
|
|
public void testEqWithEqualAtoms() {
|
|
String input = "(eq 1 1)";
|
|
|
|
assertSExpressionsMatch(evaluateString(input), parseString("t"));
|
|
}
|
|
|
|
@Test
|
|
public void testEqWithUnequalAtoms() {
|
|
String input = "(eq 1 2)";
|
|
|
|
assertSExpressionsMatch(evaluateString(input), parseString("nil"));
|
|
}
|
|
@Test
|
|
public void testEqWithAtomAndList() {
|
|
String input = "(eq 1 '(2))";
|
|
|
|
assertSExpressionsMatch(evaluateString(input), parseString("nil"));
|
|
}
|
|
|
|
@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);
|
|
|
|
assertSExpressionsMatch(evaluateString(input), parseString("t"));
|
|
}
|
|
|
|
@Test
|
|
public void testEqWithEqualLists() {
|
|
String input = "(eq '(1 2) '(1 2))";
|
|
|
|
assertSExpressionsMatch(evaluateString(input), parseString("nil"));
|
|
}
|
|
|
|
@Test
|
|
public void testEqWithUnequalLists() {
|
|
String input = "(eq '(1 2) '(3 4))";
|
|
|
|
assertSExpressionsMatch(evaluateString(input), parseString("nil"));
|
|
}
|
|
|
|
@Test(expected = TooManyArgumentsException.class)
|
|
public void testEqWithTooManyArguments() {
|
|
evaluateString("(eq 'one 'two 'three)");
|
|
}
|
|
|
|
@Test(expected = TooFewArgumentsException.class)
|
|
public void testEqWithTooFewArguments() {
|
|
evaluateString("(eq 'one)");
|
|
}
|
|
|
|
}
|