From c603c443ecd861ac0dc76e4e14ced9bc711a4abd Mon Sep 17 00:00:00 2001 From: Mike Cifelli Date: Sun, 21 Oct 2018 10:14:21 -0400 Subject: [PATCH] Convert Fuse tests to kotlin --- .../environment/RuntimeEnvironmentTest.kt | 1 - .../kotlin/function/builtin/FuseTest.java | 57 ---------------- src/test/kotlin/function/builtin/FuseTest.kt | 65 +++++++++++++++++++ 3 files changed, 65 insertions(+), 58 deletions(-) delete mode 100644 src/test/kotlin/function/builtin/FuseTest.java create mode 100644 src/test/kotlin/function/builtin/FuseTest.kt diff --git a/src/test/kotlin/environment/RuntimeEnvironmentTest.kt b/src/test/kotlin/environment/RuntimeEnvironmentTest.kt index 9b8104b..dc01b15 100644 --- a/src/test/kotlin/environment/RuntimeEnvironmentTest.kt +++ b/src/test/kotlin/environment/RuntimeEnvironmentTest.kt @@ -7,7 +7,6 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import testutil.LispTestInstance - @LispTestInstance class RuntimeEnvironmentTest { diff --git a/src/test/kotlin/function/builtin/FuseTest.java b/src/test/kotlin/function/builtin/FuseTest.java deleted file mode 100644 index 1728c6c..0000000 --- a/src/test/kotlin/function/builtin/FuseTest.java +++ /dev/null @@ -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\")"); - } -} diff --git a/src/test/kotlin/function/builtin/FuseTest.kt b/src/test/kotlin/function/builtin/FuseTest.kt new file mode 100644 index 0000000..fc59fa3 --- /dev/null +++ b/src/test/kotlin/function/builtin/FuseTest.kt @@ -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\")") + } + } +}