Convert Fuse tests to kotlin
This commit is contained in:
parent
84467388bb
commit
c603c443ec
|
@ -7,7 +7,6 @@ import org.junit.jupiter.api.BeforeEach
|
|||
import org.junit.jupiter.api.Test
|
||||
import testutil.LispTestInstance
|
||||
|
||||
|
||||
@LispTestInstance
|
||||
class RuntimeEnvironmentTest {
|
||||
|
||||
|
|
|
@ -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\")");
|
||||
}
|
||||
}
|
|
@ -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\")")
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue