117 lines
2.7 KiB
Java
117 lines
2.7 KiB
Java
package function.builtin.predicate;
|
|
|
|
import static testutil.TestUtilities.evaluateString;
|
|
import static testutil.TypeAssertions.assertNil;
|
|
import static testutil.TypeAssertions.assertT;
|
|
|
|
import org.junit.Test;
|
|
|
|
import function.ArgumentValidator.TooFewArgumentsException;
|
|
import function.ArgumentValidator.TooManyArgumentsException;
|
|
import testutil.SymbolAndFunctionCleaner;
|
|
|
|
public class EQUALTest extends SymbolAndFunctionCleaner {
|
|
|
|
@Test
|
|
public void equalWithTwoEqualAtoms() {
|
|
String input = "(equal 'a 'a)";
|
|
|
|
assertT(evaluateString(input));
|
|
}
|
|
|
|
@Test
|
|
public void equalWithTwoEqualAtomsAndAlias() {
|
|
String input = "(equal? 'a 'a)";
|
|
|
|
assertT(evaluateString(input));
|
|
}
|
|
|
|
@Test
|
|
public void equalWithTwoUnequalAtoms() {
|
|
String input = "(equal 'a 'b)";
|
|
|
|
assertNil(evaluateString(input));
|
|
}
|
|
|
|
@Test
|
|
public void equalWithTwoEqualNumbers() {
|
|
String input = "(equal -4 -4)";
|
|
|
|
assertT(evaluateString(input));
|
|
}
|
|
|
|
@Test
|
|
public void equalWithTwoUnequalNumbers() {
|
|
String input = "(equal +5 +7)";
|
|
|
|
assertNil(evaluateString(input));
|
|
}
|
|
|
|
@Test
|
|
public void equalWithTwoEqualStrings() {
|
|
String input = "(equal \"potato\" \"potato\")";
|
|
|
|
assertT(evaluateString(input));
|
|
}
|
|
|
|
@Test
|
|
public void equalWithTwoUnequalStrings() {
|
|
String input = "(equal \"tomato\" \"potato\")";
|
|
|
|
assertNil(evaluateString(input));
|
|
}
|
|
|
|
@Test
|
|
public void equalWithTwoDifferentCasedStrings() {
|
|
String input = "(equal \"Potato\" \"potato\")";
|
|
|
|
assertNil(evaluateString(input));
|
|
}
|
|
|
|
@Test
|
|
public void equalWithAtomAndList() {
|
|
String input = "(equal \"string\" '(m i k e))";
|
|
|
|
assertNil(evaluateString(input));
|
|
}
|
|
|
|
@Test
|
|
public void equalWithListAndAtom() {
|
|
String input = "(equal '(m i k e) \"string\")";
|
|
|
|
assertNil(evaluateString(input));
|
|
}
|
|
|
|
@Test
|
|
public void equalWithTwoEqualLists() {
|
|
String input = "(equal '(1 2 3) '(1 2 3))";
|
|
|
|
assertT(evaluateString(input));
|
|
}
|
|
|
|
@Test
|
|
public void equalWithTwoUnequalLists() {
|
|
String input = "(equal '(1 2 3) '(1 3 3))";
|
|
|
|
assertNil(evaluateString(input));
|
|
}
|
|
|
|
@Test
|
|
public void equalWithTwoEqualNestedLists() {
|
|
String input = "(equal '(1 ((2) 3)) '(1 ((2) 3)))";
|
|
|
|
assertT(evaluateString(input));
|
|
}
|
|
|
|
@Test(expected = TooManyArgumentsException.class)
|
|
public void equalWithTooManyArguments() {
|
|
evaluateString("(equal 1 2 3)");
|
|
}
|
|
|
|
@Test(expected = TooFewArgumentsException.class)
|
|
public void equalWithTooFewArguments() {
|
|
evaluateString("(equal 1)");
|
|
}
|
|
|
|
}
|