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

112 lines
2.3 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.*;
2017-03-15 13:37:39 -04:00
public class EQTest {
@Test
public void eqWithEqualAtoms() {
String input = "(eq 1 1)";
2017-01-27 11:37:11 -05:00
assertT(evaluateString(input));
}
2017-03-07 13:15:40 -05:00
@Test
public void eqWithEqualAtomsAndAlias() {
String input = "(eq? 1 1)";
assertT(evaluateString(input));
}
@Test
public void eqWithUnequalAtoms() {
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 eqWithTwoEqualNumbers() {
String input = "(eq -4 -4)";
assertT(evaluateString(input));
}
@Test
public void eqWithTwoUnequalNumbers() {
String input = "(eq +5 +7)";
assertNil(evaluateString(input));
}
@Test
public void eqWithTwoEqualStrings() {
String input = "(eq \"potato\" \"potato\")";
assertT(evaluateString(input));
}
@Test
public void eqWithTwoUnequalStrings() {
String input = "(eq \"tomato\" \"potato\")";
assertNil(evaluateString(input));
}
@Test
public void eqWithTwoDifferentCasedStrings() {
String input = "(eq \"Potato\" \"potato\")";
assertNil(evaluateString(input));
}
@Test
public void eqWithAtomAndList() {
String input = "(eq 1 '(2))";
2017-01-27 11:37:11 -05:00
assertNil(evaluateString(input));
}
@Test
public void eqWithSameList() {
2017-03-07 16:41:26 -05:00
String initializeL1 = "(setq l1 '(1 2 3))";
String initializeL2 = "(setq 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 eqWithEqualLists() {
String input = "(eq '(1 2) '(1 2))";
2017-01-27 11:37:11 -05:00
assertNil(evaluateString(input));
}
@Test
public void eqWithUnequalLists() {
String input = "(eq '(1 2) '(3 4))";
2017-01-27 11:37:11 -05:00
assertNil(evaluateString(input));
}
@Test(expected = TooManyArgumentsException.class)
public void eqWithTooManyArguments() {
evaluateString("(eq 'one 'two 'three)");
}
@Test(expected = TooFewArgumentsException.class)
public void eqWithTooFewArguments() {
evaluateString("(eq 'one)");
}
}