Convert Fuse tests to kotlin

This commit is contained in:
Mike Cifelli 2018-10-21 10:14:21 -04:00
parent 84467388bb
commit c603c443ec
3 changed files with 65 additions and 58 deletions

View File

@ -7,7 +7,6 @@ import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import testutil.LispTestInstance
@LispTestInstance
class RuntimeEnvironmentTest {

View File

@ -1,57 +0,0 @@
package function.builtin;
import function.ArgumentValidator.BadArgumentTypeException;
import function.ArgumentValidator.TooFewArgumentsException;
import function.ArgumentValidator.TooManyArgumentsException;
import org.junit.Test;
import sexpression.Symbol;
import testutil.SymbolAndFunctionCleaner;
import static testutil.TestUtilities.assertSExpressionsMatch;
import static testutil.TestUtilities.evaluateString;
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\")");
}
}

View File

@ -0,0 +1,65 @@
package function.builtin
import function.ArgumentValidator.BadArgumentTypeException
import function.ArgumentValidator.TooFewArgumentsException
import function.ArgumentValidator.TooManyArgumentsException
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.Test
import sexpression.Symbol
import testutil.SymbolAndFunctionCleaner
import testutil.TestUtilities.assertSExpressionsMatch
import testutil.TestUtilities.evaluateString
class FuseTest : SymbolAndFunctionCleaner() {
@Test
fun fuseSymbolAndNumber() {
assertSExpressionsMatch(Symbol("A-1"), evaluateString("(fuse 'a 1)"))
}
@Test
fun fuseTwoSymbols_NeitherQuoted() {
evaluateString("(setq a 'aaa)")
evaluateString("(setq b 'bbb)")
assertSExpressionsMatch(Symbol("AAA-BBB"), evaluateString("(fuse a b)"))
}
@Test
fun fuseTwoSymbols_OneQuoted() {
evaluateString("(setq b 'bbb)")
assertSExpressionsMatch(Symbol("A-BBB"), evaluateString("(fuse 'a b)"))
}
@Test
fun fuseTwoSymbols_BothQuoted() {
assertSExpressionsMatch(Symbol("A-B"), evaluateString("(fuse 'a 'b)"))
}
@Test
fun fuseWithTooFewArguments() {
assertThrows(TooFewArgumentsException::class.java) {
evaluateString("(fuse 'a)")
}
}
@Test
fun fuseWithTooManyArguments() {
assertThrows(TooManyArgumentsException::class.java) {
evaluateString("(fuse 'a 'b 'c)")
}
}
@Test
fun fuseWithBadFirstArgumentType() {
assertThrows(BadArgumentTypeException::class.java) {
evaluateString("(fuse 1 'b)")
}
}
@Test
fun fuseWithBadSecondArgumentType() {
assertThrows(BadArgumentTypeException::class.java) {
evaluateString("(fuse 'a \"b\")")
}
}
}