59 lines
1.7 KiB
Java
59 lines
1.7 KiB
Java
package function.builtin.special;
|
|
|
|
import static testutil.TestUtilities.assertSExpressionsMatch;
|
|
import static testutil.TestUtilities.evaluateString;
|
|
|
|
import org.junit.Test;
|
|
|
|
import function.ArgumentValidator.BadArgumentTypeException;
|
|
import function.ArgumentValidator.TooFewArgumentsException;
|
|
import function.ArgumentValidator.TooManyArgumentsException;
|
|
import sexpression.Symbol;
|
|
import testutil.SymbolAndFunctionCleaner;
|
|
|
|
public class FUSETest extends SymbolAndFunctionCleaner {
|
|
|
|
@Test
|
|
public void fuseSymbolAndNumber() {
|
|
assertSExpressionsMatch(new Symbol("A-1"), evaluateString("(fuse 'a 1)"));
|
|
}
|
|
|
|
@Test
|
|
public void fuseTwoSymbols_NeitherQuoted() {
|
|
evaluateString("(setq a 'aaa)");
|
|
evaluateString("(setq b 'bbb)");
|
|
assertSExpressionsMatch(new Symbol("AAA-BBB"), evaluateString("(fuse a b)"));
|
|
}
|
|
|
|
@Test
|
|
public void fuseTwoSymbols_OneQuoted() {
|
|
evaluateString("(setq b 'bbb)");
|
|
assertSExpressionsMatch(new Symbol("A-BBB"), evaluateString("(fuse 'a b)"));
|
|
}
|
|
|
|
@Test
|
|
public void fuseTwoSymbols_BothQuoted() {
|
|
assertSExpressionsMatch(new Symbol("A-B"), evaluateString("(fuse 'a 'b)"));
|
|
}
|
|
|
|
@Test(expected = TooFewArgumentsException.class)
|
|
public void fuseWithTooFewArguments() {
|
|
evaluateString("(fuse 'a)");
|
|
}
|
|
|
|
@Test(expected = TooManyArgumentsException.class)
|
|
public void fuseWithTooManyArguments() {
|
|
evaluateString("(fuse 'a 'b 'c)");
|
|
}
|
|
|
|
@Test(expected = BadArgumentTypeException.class)
|
|
public void fuseWithBadFirstArgumentType() {
|
|
evaluateString("(fuse 1 'b)");
|
|
}
|
|
|
|
@Test(expected = BadArgumentTypeException.class)
|
|
public void fuseWithBadSecondArgumentType() {
|
|
evaluateString("(fuse 'a \"b\")");
|
|
}
|
|
}
|