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

71 lines
1.8 KiB
Java
Raw Normal View History

package function.builtin;
import static testutil.TestUtilities.*;
import org.junit.Test;
import function.ArgumentValidator.*;
public class EQUALTester {
@Test
public void testEqualWithTwoEqualAtoms() {
String input = "(equal 'a 'a)";
assertSExpressionsMatch(evaluateString(input), parseString("t"));
}
@Test
public void testEqualWithTwoUnequalAtoms() {
String input = "(equal 'a 'b)";
assertSExpressionsMatch(evaluateString(input), parseString("nil"));
}
@Test
public void testEqualWithAtomAndList() {
String input = "(equal \"string\" '(m i k e))";
assertSExpressionsMatch(evaluateString(input), parseString("nil"));
}
@Test
public void testEqualWithListAndAtom() {
String input = "(equal '(m i k e) \"string\")";
assertSExpressionsMatch(evaluateString(input), parseString("nil"));
}
@Test
public void testEqualWithTwoEqualLists() {
String input = "(equal '(1 2 3) '(1 2 3))";
assertSExpressionsMatch(evaluateString(input), parseString("t"));
}
@Test
public void testEqualWithTwoUnequalLists() {
String input = "(equal '(1 2 3) '(1 3 3))";
assertSExpressionsMatch(evaluateString(input), parseString("nil"));
}
@Test
public void testEqualWithTwoEqualNestedLists() {
String input = "(equal '(1 ((2) 3)) '(1 ((2) 3)))";
assertSExpressionsMatch(evaluateString(input), parseString("t"));
}
@Test(expected = TooManyArgumentsException.class)
public void testEqualWithTooManyArguments() {
evaluateString("(equal 1 2 3)");
}
@Test(expected = TooFewArgumentsException.class)
public void testEqualWithTooFewArguments() {
evaluateString("(equal 1)");
}
}