2017-01-14 18:01:14 -05:00
|
|
|
package function.builtin.predicate;
|
2016-12-29 13:32:45 -05:00
|
|
|
|
2017-01-27 11:37:11 -05:00
|
|
|
import static testutil.TestUtilities.evaluateString;
|
|
|
|
import static testutil.TypeAssertions.*;
|
2016-12-29 13:32:45 -05:00
|
|
|
|
|
|
|
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));
|
2016-12-29 13:32:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testEqWithUnequalAtoms() {
|
|
|
|
String input = "(eq 1 2)";
|
|
|
|
|
2017-01-27 11:37:11 -05:00
|
|
|
assertNil(evaluateString(input));
|
2016-12-29 13:32:45 -05:00
|
|
|
}
|
2017-01-27 11:37:11 -05:00
|
|
|
|
2016-12-29 13:32:45 -05:00
|
|
|
@Test
|
|
|
|
public void testEqWithAtomAndList() {
|
|
|
|
String input = "(eq 1 '(2))";
|
|
|
|
|
2017-01-27 11:37:11 -05:00
|
|
|
assertNil(evaluateString(input));
|
2016-12-29 13:32:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@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));
|
2016-12-29 13:32:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testEqWithEqualLists() {
|
|
|
|
String input = "(eq '(1 2) '(1 2))";
|
|
|
|
|
2017-01-27 11:37:11 -05:00
|
|
|
assertNil(evaluateString(input));
|
2016-12-29 13:32:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testEqWithUnequalLists() {
|
|
|
|
String input = "(eq '(1 2) '(3 4))";
|
|
|
|
|
2017-01-27 11:37:11 -05:00
|
|
|
assertNil(evaluateString(input));
|
2016-12-29 13:32:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test(expected = TooManyArgumentsException.class)
|
|
|
|
public void testEqWithTooManyArguments() {
|
|
|
|
evaluateString("(eq 'one 'two 'three)");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test(expected = TooFewArgumentsException.class)
|
|
|
|
public void testEqWithTooFewArguments() {
|
|
|
|
evaluateString("(eq 'one)");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|