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

72 lines
1.6 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 EQUALTester {
@Test
public void testEqualWithTwoEqualAtoms() {
String input = "(equal 'a 'a)";
2017-01-27 11:37:11 -05:00
assertT(evaluateString(input));
}
@Test
public void testEqualWithTwoUnequalAtoms() {
String input = "(equal 'a 'b)";
2017-01-27 11:37:11 -05:00
assertNil(evaluateString(input));
}
@Test
public void testEqualWithAtomAndList() {
String input = "(equal \"string\" '(m i k e))";
2017-01-27 11:37:11 -05:00
assertNil(evaluateString(input));
}
@Test
public void testEqualWithListAndAtom() {
String input = "(equal '(m i k e) \"string\")";
2017-01-27 11:37:11 -05:00
assertNil(evaluateString(input));
}
@Test
public void testEqualWithTwoEqualLists() {
String input = "(equal '(1 2 3) '(1 2 3))";
2017-01-27 11:37:11 -05:00
assertT(evaluateString(input));
}
@Test
public void testEqualWithTwoUnequalLists() {
String input = "(equal '(1 2 3) '(1 3 3))";
2017-01-27 11:37:11 -05:00
assertNil(evaluateString(input));
}
@Test
public void testEqualWithTwoEqualNestedLists() {
String input = "(equal '(1 ((2) 3)) '(1 ((2) 3)))";
2017-01-27 11:37:11 -05:00
assertT(evaluateString(input));
}
@Test(expected = TooManyArgumentsException.class)
public void testEqualWithTooManyArguments() {
evaluateString("(equal 1 2 3)");
}
@Test(expected = TooFewArgumentsException.class)
public void testEqualWithTooFewArguments() {
evaluateString("(equal 1)");
}
}