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

161 lines
4.2 KiB
Java

package function.builtin.predicate;
import static testutil.TestUtilities.evaluateString;
import static testutil.TypeAssertions.*;
import org.junit.Test;
import function.ArgumentValidator.*;
import testutil.SymbolAndFunctionCleaner;
public class GENSYM_EQUALTest extends SymbolAndFunctionCleaner {
@Test
public void gensymEqualWithTwoEqualAtoms() {
String input = "(gensym-equal 'a 'a)";
assertT(evaluateString(input));
}
@Test
public void gensymEqualWithTwoEqualAtomsAndAlias() {
String input = "(gensym-equal? 'a 'a)";
assertT(evaluateString(input));
}
@Test
public void gensymEqualWithTwoUnequalAtoms() {
String input = "(gensym-equal 'a 'b)";
assertNil(evaluateString(input));
}
@Test
public void gensymEqualWithTwoEqualNumbers() {
String input = "(gensym-equal -4 -4)";
assertT(evaluateString(input));
}
@Test
public void gensymEqualWithTwoUnequalNumbers() {
String input = "(gensym-equal +5 +7)";
assertNil(evaluateString(input));
}
@Test
public void gensymEqualWithTwoEqualStrings() {
String input = "(gensym-equal \"potato\" \"potato\")";
assertT(evaluateString(input));
}
@Test
public void gensymEqualWithTwoUnequalStrings() {
String input = "(gensym-equal \"tomato\" \"potato\")";
assertNil(evaluateString(input));
}
@Test
public void gensymEqualWithTwoDifferentCasedStrings() {
String input = "(gensym-equal \"Potato\" \"potato\")";
assertNil(evaluateString(input));
}
@Test
public void gensymEqualWithAtomAndList() {
String input = "(gensym-equal \"string\" '(m i k e))";
assertNil(evaluateString(input));
}
@Test
public void gensymEqualWithListAndAtom() {
String input = "(gensym-equal '(m i k e) \"string\")";
assertNil(evaluateString(input));
}
@Test
public void gensymEqualWithTwoEqualLists() {
String input = "(gensym-equal '(1 2 3) '(1 2 3))";
assertT(evaluateString(input));
}
@Test
public void gensymEqualWithTwoUnequalLists() {
String input = "(gensym-equal '(1 2 3) '(1 3 3))";
assertNil(evaluateString(input));
}
@Test
public void gensymEqualWithTwoEqualNestedLists() {
String input = "(gensym-equal '(1 ((2) 3)) '(1 ((2) 3)))";
assertT(evaluateString(input));
}
@Test(expected = TooManyArgumentsException.class)
public void gensymEqualWithTooManyArguments() {
evaluateString("(gensym-equal 1 2 3)");
}
@Test(expected = TooFewArgumentsException.class)
public void gensymEqualWithTooFewArguments() {
evaluateString("(gensym-equal 1)");
}
@Test
public void gensymEqualWithGensyms() {
String input = "(gensym-equal (gensym) (gensym))";
assertT(evaluateString(input));
}
@Test
public void gensymEqualWithNestedGensyms() {
String input = "(gensym-equal `(1 ,(gensym) (2 ,(gensym))) `(1 ,(gensym) (2 ,(gensym))))";
assertT(evaluateString(input));
}
@Test
public void gensymEqualWithUnmatchedGensymPositions() {
String input = "(gensym-equal (let ((one (gensym))) `(,one ,one))"
+ " (let ((one (gensym)) (two (gensym))) `(,one ,two)))";
assertNil(evaluateString(input));
}
@Test
public void gensymEqualWithMatchedGensymPositions() {
String input = "(gensym-equal (let ((one (gensym))) `(,one ,one))"
+ " (let ((one (gensym)) (two (gensym))) `(,one ,one)))";
assertT(evaluateString(input));
}
@Test
public void gensymEqualWithComplexMatchedGensymPositions() {
String input = "(gensym-equal (let ((x (gensym)) (y (gensym)) (z (gensym))) `(,x (,y ,z)))"
+ " (let ((a (gensym)) (b (gensym)) (c (gensym))) `(,c (,a ,b))))";
assertT(evaluateString(input));
}
@Test
public void gensymEqualWithComplexUnmatchedGensymPositions() {
String input = "(gensym-equal (let ((x (gensym)) (y (gensym)) (z (gensym))) `(,x , y (,z ,z)))"
+ " (let ((a (gensym)) (b (gensym)) (c (gensym))) `(,a ,c (,b ,c))))";
assertNil(evaluateString(input));
}
}