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;
|
2017-07-19 15:23:15 -04:00
|
|
|
import testutil.SymbolAndFunctionCleaner;
|
2017-03-10 13:14:16 -05:00
|
|
|
import token.TokenFactory.BadCharacterException;
|
|
|
|
|
2017-07-19 15:23:15 -04:00
|
|
|
public class GENSYMTest extends SymbolAndFunctionCleaner {
|
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)");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|