2017-03-10 13:14:16 -05:00
|
|
|
package function.builtin;
|
|
|
|
|
|
|
|
import static function.builtin.GENSYM.GENSYM_PREFIX;
|
|
|
|
import static testutil.TestUtilities.*;
|
|
|
|
import static testutil.TypeAssertions.assertSymbol;
|
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import function.ArgumentValidator.TooManyArgumentsException;
|
|
|
|
import token.TokenFactory.BadCharacterException;
|
|
|
|
|
2017-03-15 13:37:39 -04:00
|
|
|
public class GENSYMTest {
|
2017-03-10 13:14:16 -05:00
|
|
|
|
|
|
|
@Test
|
|
|
|
public void gensymCreatesSymbol() {
|
|
|
|
assertSymbol(evaluateString("(gensym)"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void gensymCreatesUniqueSymbol() {
|
|
|
|
assertSExpressionsDoNotMatch(evaluateString("(gensym)"), evaluateString("(gensym)"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void simpleGensymUsage() {
|
|
|
|
String input = "(let ((x (gensym))) (set x 23) (eval x))";
|
|
|
|
assertSExpressionsMatch(evaluateString("23"), evaluateString(input));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test(expected = BadCharacterException.class)
|
|
|
|
public void cannotUseGensymValueManually() {
|
|
|
|
String variableName = GENSYM_PREFIX + 1;
|
|
|
|
evaluateString("(setq " + variableName + " 100)");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test(expected = TooManyArgumentsException.class)
|
|
|
|
public void gensymWithTooManyArguments() {
|
|
|
|
evaluateString("(gensym 1)");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|