2016-12-29 13:32:45 -05:00
|
|
|
package function.builtin;
|
|
|
|
|
|
|
|
import static testutil.TestUtilities.*;
|
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import function.ArgumentValidator.*;
|
|
|
|
|
|
|
|
public class EQUALTester {
|
|
|
|
|
|
|
|
@Test
|
2016-12-30 10:22:25 -05:00
|
|
|
public void testEqualWithTwoEqualAtoms() {
|
|
|
|
String input = "(equal 'a 'a)";
|
2016-12-29 13:32:45 -05:00
|
|
|
|
2016-12-30 10:22:25 -05:00
|
|
|
assertSExpressionsMatch(evaluateString(input), parseString("t"));
|
2016-12-29 13:32:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2016-12-30 10:22:25 -05:00
|
|
|
public void testEqualWithTwoUnequalAtoms() {
|
|
|
|
String input = "(equal 'a 'b)";
|
2016-12-29 13:32:45 -05:00
|
|
|
|
2016-12-30 10:22:25 -05:00
|
|
|
assertSExpressionsMatch(evaluateString(input), parseString("nil"));
|
2016-12-29 13:32:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2016-12-30 10:22:25 -05:00
|
|
|
public void testEqualWithAtomAndList() {
|
|
|
|
String input = "(equal \"string\" '(m i k e))";
|
2016-12-29 13:32:45 -05:00
|
|
|
|
2016-12-30 10:22:25 -05:00
|
|
|
assertSExpressionsMatch(evaluateString(input), parseString("nil"));
|
2016-12-29 13:32:45 -05:00
|
|
|
}
|
|
|
|
|
2016-12-30 10:22:25 -05:00
|
|
|
@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"));
|
2016-12-29 13:32:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test(expected = TooManyArgumentsException.class)
|
2016-12-30 10:22:25 -05:00
|
|
|
public void testEqualWithTooManyArguments() {
|
|
|
|
evaluateString("(equal 1 2 3)");
|
2016-12-29 13:32:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test(expected = TooFewArgumentsException.class)
|
2016-12-30 10:22:25 -05:00
|
|
|
public void testEqualWithTooFewArguments() {
|
|
|
|
evaluateString("(equal 1)");
|
2016-12-29 13:32:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|