From 5c183e94fb9e736142cf81e9a7686043caa798aa Mon Sep 17 00:00:00 2001 From: Mike Cifelli Date: Sun, 18 Nov 2018 08:42:51 -0500 Subject: [PATCH] Complete conversion to kotlin Resolves #5 and #16 --- pom.xml | 40 ++++--------------- src/main/kotlin/function/builtin/Eval.kt | 5 --- src/main/kotlin/function/builtin/Set.kt | 1 - .../kotlin/function/builtin/cons/Append.kt | 1 - src/main/kotlin/function/builtin/cons/List.kt | 1 - src/main/kotlin/recursion/TailCalls.kt | 2 - .../kotlin/terminal/ControlSequenceHandler.kt | 1 - .../kotlin/terminal/SelectGraphicRendition.kt | 1 - src/test/kotlin/testutil/TestUtilities.kt | 9 ----- src/test/kotlin/testutil/TypeAssertions.kt | 9 ----- 10 files changed, 8 insertions(+), 62 deletions(-) diff --git a/pom.xml b/pom.xml index 93e3d40..1efe38e 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ UTF-8 - 1.3.0 + 1.3.10 5.3.1 false @@ -57,7 +57,6 @@ - org.apache.maven.plugins maven-compiler-plugin @@ -75,14 +74,14 @@ java-compile - compile + none compile java-test-compile - test-compile + none testCompile @@ -97,25 +96,9 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.1 - - - org.junit.jupiter - junit-jupiter-engine - ${junit5.version} - - - - - org.junit.vintage - junit-vintage-engine - ${junit5.version} - - + 3.0.0-M1 ${skipTests} - - false @@ -190,26 +173,19 @@ org.junit.jupiter - junit-jupiter-api + junit-jupiter-engine ${junit5.version} test + - org.junit.jupiter - junit-jupiter-params + org.junit.vintage + junit-vintage-engine ${junit5.version} test - - - junit - junit - 4.12 - test - - org.fitnesse fitnesse diff --git a/src/main/kotlin/function/builtin/Eval.kt b/src/main/kotlin/function/builtin/Eval.kt index 93aad4c..ca50efe 100644 --- a/src/main/kotlin/function/builtin/Eval.kt +++ b/src/main/kotlin/function/builtin/Eval.kt @@ -101,7 +101,6 @@ class Eval(name: String) : LispFunction() { private fun lookupEval() = lookupFunction("EVAL") as Eval - @JvmStatic fun eval(sExpression: SExpression): SExpression { try { return lookupEval().call(makeList(sExpression)) @@ -111,14 +110,11 @@ class Eval(name: String) : LispFunction() { } } - @JvmStatic fun applyFunction(function: LispFunction, argumentList: Cons) = lookupEval().applyFunctionWithoutEvaluatingArguments(function, argumentList) - @JvmStatic fun evaluateFunctionArgumentList(argumentList: Cons) = lookupEval().evaluateArgumentList(argumentList) - @JvmStatic fun lookupSymbol(symbolName: String) = when { symbolName == "NIL" -> Nil symbolName == "T" -> T @@ -126,7 +122,6 @@ class Eval(name: String) : LispFunction() { else -> ExecutionContext.lookupSymbolValue(symbolName) } - @JvmStatic fun lookupFunctionOrLambda(functionExpression: SExpression): LispFunction { val function = lookupFunction(functionExpression.toString()) diff --git a/src/main/kotlin/function/builtin/Set.kt b/src/main/kotlin/function/builtin/Set.kt index f14e2d7..c396235 100644 --- a/src/main/kotlin/function/builtin/Set.kt +++ b/src/main/kotlin/function/builtin/Set.kt @@ -46,7 +46,6 @@ class Set(name: String) : LispFunction() { companion object { - @JvmStatic fun set(argumentList: Cons) = lookupFunction("SET")!!.call(argumentList) } } diff --git a/src/main/kotlin/function/builtin/cons/Append.kt b/src/main/kotlin/function/builtin/cons/Append.kt index 1868c54..fd2b312 100644 --- a/src/main/kotlin/function/builtin/cons/Append.kt +++ b/src/main/kotlin/function/builtin/cons/Append.kt @@ -53,7 +53,6 @@ class Append(name: String) : LispFunction() { companion object { - @JvmStatic fun append(firstList: Cons, secondList: Cons): Cons { return lookupAppend().appendLists(firstList, secondList) } diff --git a/src/main/kotlin/function/builtin/cons/List.kt b/src/main/kotlin/function/builtin/cons/List.kt index aebbb1b..6869b5c 100644 --- a/src/main/kotlin/function/builtin/cons/List.kt +++ b/src/main/kotlin/function/builtin/cons/List.kt @@ -20,7 +20,6 @@ class List(name: String) : LispFunction() { companion object { - @JvmStatic fun makeList(sexpr: SExpression): Cons { return Cons(sexpr, Nil) } diff --git a/src/main/kotlin/recursion/TailCalls.kt b/src/main/kotlin/recursion/TailCalls.kt index 1c9d7f7..3e24c2d 100644 --- a/src/main/kotlin/recursion/TailCalls.kt +++ b/src/main/kotlin/recursion/TailCalls.kt @@ -2,12 +2,10 @@ package recursion object TailCalls { - @JvmStatic fun tailCall(nextCall: () -> TailCall) = object : TailCall { override fun apply() = nextCall() } - @JvmStatic fun done(value: T) = object : TailCall { override fun isComplete() = true override fun result() = value diff --git a/src/main/kotlin/terminal/ControlSequenceHandler.kt b/src/main/kotlin/terminal/ControlSequenceHandler.kt index c87c1d1..f6c21d4 100644 --- a/src/main/kotlin/terminal/ControlSequenceHandler.kt +++ b/src/main/kotlin/terminal/ControlSequenceHandler.kt @@ -45,7 +45,6 @@ class ControlSequenceHandler { companion object { - @JvmStatic fun isEscape(c: Char): Boolean { return c == UNICODE_ESCAPE } diff --git a/src/main/kotlin/terminal/SelectGraphicRendition.kt b/src/main/kotlin/terminal/SelectGraphicRendition.kt index 0edcae7..64bfadc 100644 --- a/src/main/kotlin/terminal/SelectGraphicRendition.kt +++ b/src/main/kotlin/terminal/SelectGraphicRendition.kt @@ -47,7 +47,6 @@ enum class SelectGraphicRendition : ControlSequence { companion object { - @JvmStatic val SGR_COMMAND = 'm' } } \ No newline at end of file diff --git a/src/test/kotlin/testutil/TestUtilities.kt b/src/test/kotlin/testutil/TestUtilities.kt index 5bfdb7f..4f6d162 100644 --- a/src/test/kotlin/testutil/TestUtilities.kt +++ b/src/test/kotlin/testutil/TestUtilities.kt @@ -16,10 +16,8 @@ import java.util.Arrays object TestUtilities { - @JvmStatic fun createInputStreamFromString(string: String) = ByteArrayInputStream(string.toByteArray()) - @JvmStatic fun createIOExceptionThrowingInputStream() = object : InputStream() { override fun read(): Int { @@ -31,7 +29,6 @@ object TestUtilities { } } - @JvmStatic fun createIOExceptionThrowingOutputStream() = object : OutputStream() { override fun write(b: ByteArray) { @@ -51,17 +48,14 @@ object TestUtilities { } } - @JvmStatic fun evaluateString(input: String): SExpression = eval(parseString(input)) - @JvmStatic fun parseString(input: String): SExpression { val stringInputStream = TestUtilities.createInputStreamFromString(input) return LispParser(stringInputStream, "testFile").nextSExpression() } - @JvmStatic fun makeList(vararg expressionList: SExpression): Cons { if (expressionList.isEmpty()) return Nil @@ -71,17 +65,14 @@ object TestUtilities { return Cons(expressionList[0], rest) } - @JvmStatic fun assertSExpressionsMatch(expected: SExpression, actual: SExpression) { assertThat(actual.toString()).isEqualTo(expected.toString()) } - @JvmStatic fun assertSExpressionsDoNotMatch(unexpected: SExpression, actual: SExpression) { assertThat(actual.toString()).isNotEqualTo(unexpected.toString()) } - @JvmStatic fun assertIsErrorWithMessage(e: LispException) { assertThat(e.severity).isEqualTo(ERROR) assertThat(e.message).isNotEmpty() diff --git a/src/test/kotlin/testutil/TypeAssertions.kt b/src/test/kotlin/testutil/TypeAssertions.kt index 75005da..75e2e0e 100644 --- a/src/test/kotlin/testutil/TypeAssertions.kt +++ b/src/test/kotlin/testutil/TypeAssertions.kt @@ -7,7 +7,6 @@ import sexpression.Symbol.Companion.T object TypeAssertions { - @JvmStatic fun assertList(sExpression: SExpression) { assertThat(sExpression.isAtom).isFalse() assertThat(sExpression.isCons).isTrue() @@ -22,7 +21,6 @@ object TypeAssertions { assertThat(sExpression.isAtSign).isFalse() } - @JvmStatic fun assertNil(sExpression: SExpression) { assertThat(sExpression).isEqualTo(Nil) @@ -39,7 +37,6 @@ object TypeAssertions { assertThat(sExpression.isAtSign).isFalse() } - @JvmStatic fun assertNumber(sExpression: SExpression) { assertThat(sExpression.isAtom).isTrue() assertThat(sExpression.isCons).isFalse() @@ -54,7 +51,6 @@ object TypeAssertions { assertThat(sExpression.isAtSign).isFalse() } - @JvmStatic fun assertString(sExpression: SExpression) { assertThat(sExpression.isAtom).isTrue() assertThat(sExpression.isCons).isFalse() @@ -69,7 +65,6 @@ object TypeAssertions { assertThat(sExpression.isAtSign).isFalse() } - @JvmStatic fun assertSymbol(sExpression: SExpression) { assertThat(sExpression.isAtom).isTrue() assertThat(sExpression.isCons).isFalse() @@ -84,12 +79,10 @@ object TypeAssertions { assertThat(sExpression.isAtSign).isFalse() } - @JvmStatic fun assertT(sExpression: SExpression) { assertThat(sExpression).isEqualTo(T) } - @JvmStatic fun assertBackTickExpression(sExpression: SExpression) { assertThat(sExpression.isAtom).isFalse() assertThat(sExpression.isCons).isFalse() @@ -104,7 +97,6 @@ object TypeAssertions { assertThat(sExpression.isAtSign).isFalse() } - @JvmStatic fun assertCommaExpression(sExpression: SExpression) { assertThat(sExpression.isAtom).isFalse() assertThat(sExpression.isCons).isFalse() @@ -119,7 +111,6 @@ object TypeAssertions { assertThat(sExpression.isAtSign).isFalse() } - @JvmStatic fun assertAtSignExpression(sExpression: SExpression) { assertThat(sExpression.isAtom).isFalse() assertThat(sExpression.isCons).isFalse()