parent
698df036ff
commit
5c183e94fb
40
pom.xml
40
pom.xml
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<kotlin.version>1.3.0</kotlin.version>
|
<kotlin.version>1.3.10</kotlin.version>
|
||||||
<junit5.version>5.3.1</junit5.version>
|
<junit5.version>5.3.1</junit5.version>
|
||||||
<skipTests>false</skipTests>
|
<skipTests>false</skipTests>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -57,7 +57,6 @@
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<!-- TODO - remove when everything is converted to kotlin -->
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
@ -75,14 +74,14 @@
|
||||||
</execution>
|
</execution>
|
||||||
<execution>
|
<execution>
|
||||||
<id>java-compile</id>
|
<id>java-compile</id>
|
||||||
<phase>compile</phase>
|
<phase>none</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>compile</goal>
|
<goal>compile</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
<execution>
|
<execution>
|
||||||
<id>java-test-compile</id>
|
<id>java-test-compile</id>
|
||||||
<phase>test-compile</phase>
|
<phase>none</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>testCompile</goal>
|
<goal>testCompile</goal>
|
||||||
</goals>
|
</goals>
|
||||||
|
@ -97,25 +96,9 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.22.1</version>
|
<version>3.0.0-M1</version>
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.junit.jupiter</groupId>
|
|
||||||
<artifactId>junit-jupiter-engine</artifactId>
|
|
||||||
<version>${junit5.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- TODO - remove when all test cases converted to junit 5 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.junit.vintage</groupId>
|
|
||||||
<artifactId>junit-vintage-engine</artifactId>
|
|
||||||
<version>${junit5.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<skipTests>${skipTests}</skipTests>
|
<skipTests>${skipTests}</skipTests>
|
||||||
<!-- TODO - this is a workaround for a bug, remove when surefire is updated to 3.x -->
|
|
||||||
<useSystemClassLoader>false</useSystemClassLoader>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
@ -190,26 +173,19 @@
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
<version>${junit5.version}</version>
|
<version>${junit5.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- TODO - remove when all test cases converted to junit 5 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.vintage</groupId>
|
||||||
<artifactId>junit-jupiter-params</artifactId>
|
<artifactId>junit-vintage-engine</artifactId>
|
||||||
<version>${junit5.version}</version>
|
<version>${junit5.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- TODO - remove when test cases all converted to junit 5 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<version>4.12</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.fitnesse</groupId>
|
<groupId>org.fitnesse</groupId>
|
||||||
<artifactId>fitnesse</artifactId>
|
<artifactId>fitnesse</artifactId>
|
||||||
|
|
|
@ -101,7 +101,6 @@ class Eval(name: String) : LispFunction() {
|
||||||
|
|
||||||
private fun lookupEval() = lookupFunction("EVAL") as Eval
|
private fun lookupEval() = lookupFunction("EVAL") as Eval
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun eval(sExpression: SExpression): SExpression {
|
fun eval(sExpression: SExpression): SExpression {
|
||||||
try {
|
try {
|
||||||
return lookupEval().call(makeList(sExpression))
|
return lookupEval().call(makeList(sExpression))
|
||||||
|
@ -111,14 +110,11 @@ class Eval(name: String) : LispFunction() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun applyFunction(function: LispFunction, argumentList: Cons) =
|
fun applyFunction(function: LispFunction, argumentList: Cons) =
|
||||||
lookupEval().applyFunctionWithoutEvaluatingArguments(function, argumentList)
|
lookupEval().applyFunctionWithoutEvaluatingArguments(function, argumentList)
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun evaluateFunctionArgumentList(argumentList: Cons) = lookupEval().evaluateArgumentList(argumentList)
|
fun evaluateFunctionArgumentList(argumentList: Cons) = lookupEval().evaluateArgumentList(argumentList)
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun lookupSymbol(symbolName: String) = when {
|
fun lookupSymbol(symbolName: String) = when {
|
||||||
symbolName == "NIL" -> Nil
|
symbolName == "NIL" -> Nil
|
||||||
symbolName == "T" -> T
|
symbolName == "T" -> T
|
||||||
|
@ -126,7 +122,6 @@ class Eval(name: String) : LispFunction() {
|
||||||
else -> ExecutionContext.lookupSymbolValue(symbolName)
|
else -> ExecutionContext.lookupSymbolValue(symbolName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun lookupFunctionOrLambda(functionExpression: SExpression): LispFunction {
|
fun lookupFunctionOrLambda(functionExpression: SExpression): LispFunction {
|
||||||
val function = lookupFunction(functionExpression.toString())
|
val function = lookupFunction(functionExpression.toString())
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,6 @@ class Set(name: String) : LispFunction() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun set(argumentList: Cons) = lookupFunction("SET")!!.call(argumentList)
|
fun set(argumentList: Cons) = lookupFunction("SET")!!.call(argumentList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,6 @@ class Append(name: String) : LispFunction() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun append(firstList: Cons, secondList: Cons): Cons {
|
fun append(firstList: Cons, secondList: Cons): Cons {
|
||||||
return lookupAppend().appendLists(firstList, secondList)
|
return lookupAppend().appendLists(firstList, secondList)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ class List(name: String) : LispFunction() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun makeList(sexpr: SExpression): Cons {
|
fun makeList(sexpr: SExpression): Cons {
|
||||||
return Cons(sexpr, Nil)
|
return Cons(sexpr, Nil)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,10 @@ package recursion
|
||||||
|
|
||||||
object TailCalls {
|
object TailCalls {
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun <T> tailCall(nextCall: () -> TailCall<T>) = object : TailCall<T> {
|
fun <T> tailCall(nextCall: () -> TailCall<T>) = object : TailCall<T> {
|
||||||
override fun apply() = nextCall()
|
override fun apply() = nextCall()
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun <T> done(value: T) = object : TailCall<T> {
|
fun <T> done(value: T) = object : TailCall<T> {
|
||||||
override fun isComplete() = true
|
override fun isComplete() = true
|
||||||
override fun result() = value
|
override fun result() = value
|
||||||
|
|
|
@ -45,7 +45,6 @@ class ControlSequenceHandler {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun isEscape(c: Char): Boolean {
|
fun isEscape(c: Char): Boolean {
|
||||||
return c == UNICODE_ESCAPE
|
return c == UNICODE_ESCAPE
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,6 @@ enum class SelectGraphicRendition : ControlSequence {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
val SGR_COMMAND = 'm'
|
val SGR_COMMAND = 'm'
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,10 +16,8 @@ import java.util.Arrays
|
||||||
|
|
||||||
object TestUtilities {
|
object TestUtilities {
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun createInputStreamFromString(string: String) = ByteArrayInputStream(string.toByteArray())
|
fun createInputStreamFromString(string: String) = ByteArrayInputStream(string.toByteArray())
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun createIOExceptionThrowingInputStream() = object : InputStream() {
|
fun createIOExceptionThrowingInputStream() = object : InputStream() {
|
||||||
|
|
||||||
override fun read(): Int {
|
override fun read(): Int {
|
||||||
|
@ -31,7 +29,6 @@ object TestUtilities {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun createIOExceptionThrowingOutputStream() = object : OutputStream() {
|
fun createIOExceptionThrowingOutputStream() = object : OutputStream() {
|
||||||
|
|
||||||
override fun write(b: ByteArray) {
|
override fun write(b: ByteArray) {
|
||||||
|
@ -51,17 +48,14 @@ object TestUtilities {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun evaluateString(input: String): SExpression = eval(parseString(input))
|
fun evaluateString(input: String): SExpression = eval(parseString(input))
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun parseString(input: String): SExpression {
|
fun parseString(input: String): SExpression {
|
||||||
val stringInputStream = TestUtilities.createInputStreamFromString(input)
|
val stringInputStream = TestUtilities.createInputStreamFromString(input)
|
||||||
|
|
||||||
return LispParser(stringInputStream, "testFile").nextSExpression()
|
return LispParser(stringInputStream, "testFile").nextSExpression()
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun makeList(vararg expressionList: SExpression): Cons {
|
fun makeList(vararg expressionList: SExpression): Cons {
|
||||||
if (expressionList.isEmpty())
|
if (expressionList.isEmpty())
|
||||||
return Nil
|
return Nil
|
||||||
|
@ -71,17 +65,14 @@ object TestUtilities {
|
||||||
return Cons(expressionList[0], rest)
|
return Cons(expressionList[0], rest)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun assertSExpressionsMatch(expected: SExpression, actual: SExpression) {
|
fun assertSExpressionsMatch(expected: SExpression, actual: SExpression) {
|
||||||
assertThat(actual.toString()).isEqualTo(expected.toString())
|
assertThat(actual.toString()).isEqualTo(expected.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun assertSExpressionsDoNotMatch(unexpected: SExpression, actual: SExpression) {
|
fun assertSExpressionsDoNotMatch(unexpected: SExpression, actual: SExpression) {
|
||||||
assertThat(actual.toString()).isNotEqualTo(unexpected.toString())
|
assertThat(actual.toString()).isNotEqualTo(unexpected.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun assertIsErrorWithMessage(e: LispException) {
|
fun assertIsErrorWithMessage(e: LispException) {
|
||||||
assertThat(e.severity).isEqualTo(ERROR)
|
assertThat(e.severity).isEqualTo(ERROR)
|
||||||
assertThat(e.message).isNotEmpty()
|
assertThat(e.message).isNotEmpty()
|
||||||
|
|
|
@ -7,7 +7,6 @@ import sexpression.Symbol.Companion.T
|
||||||
|
|
||||||
object TypeAssertions {
|
object TypeAssertions {
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun assertList(sExpression: SExpression) {
|
fun assertList(sExpression: SExpression) {
|
||||||
assertThat(sExpression.isAtom).isFalse()
|
assertThat(sExpression.isAtom).isFalse()
|
||||||
assertThat(sExpression.isCons).isTrue()
|
assertThat(sExpression.isCons).isTrue()
|
||||||
|
@ -22,7 +21,6 @@ object TypeAssertions {
|
||||||
assertThat(sExpression.isAtSign).isFalse()
|
assertThat(sExpression.isAtSign).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun assertNil(sExpression: SExpression) {
|
fun assertNil(sExpression: SExpression) {
|
||||||
assertThat(sExpression).isEqualTo(Nil)
|
assertThat(sExpression).isEqualTo(Nil)
|
||||||
|
|
||||||
|
@ -39,7 +37,6 @@ object TypeAssertions {
|
||||||
assertThat(sExpression.isAtSign).isFalse()
|
assertThat(sExpression.isAtSign).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun assertNumber(sExpression: SExpression) {
|
fun assertNumber(sExpression: SExpression) {
|
||||||
assertThat(sExpression.isAtom).isTrue()
|
assertThat(sExpression.isAtom).isTrue()
|
||||||
assertThat(sExpression.isCons).isFalse()
|
assertThat(sExpression.isCons).isFalse()
|
||||||
|
@ -54,7 +51,6 @@ object TypeAssertions {
|
||||||
assertThat(sExpression.isAtSign).isFalse()
|
assertThat(sExpression.isAtSign).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun assertString(sExpression: SExpression) {
|
fun assertString(sExpression: SExpression) {
|
||||||
assertThat(sExpression.isAtom).isTrue()
|
assertThat(sExpression.isAtom).isTrue()
|
||||||
assertThat(sExpression.isCons).isFalse()
|
assertThat(sExpression.isCons).isFalse()
|
||||||
|
@ -69,7 +65,6 @@ object TypeAssertions {
|
||||||
assertThat(sExpression.isAtSign).isFalse()
|
assertThat(sExpression.isAtSign).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun assertSymbol(sExpression: SExpression) {
|
fun assertSymbol(sExpression: SExpression) {
|
||||||
assertThat(sExpression.isAtom).isTrue()
|
assertThat(sExpression.isAtom).isTrue()
|
||||||
assertThat(sExpression.isCons).isFalse()
|
assertThat(sExpression.isCons).isFalse()
|
||||||
|
@ -84,12 +79,10 @@ object TypeAssertions {
|
||||||
assertThat(sExpression.isAtSign).isFalse()
|
assertThat(sExpression.isAtSign).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun assertT(sExpression: SExpression) {
|
fun assertT(sExpression: SExpression) {
|
||||||
assertThat(sExpression).isEqualTo(T)
|
assertThat(sExpression).isEqualTo(T)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun assertBackTickExpression(sExpression: SExpression) {
|
fun assertBackTickExpression(sExpression: SExpression) {
|
||||||
assertThat(sExpression.isAtom).isFalse()
|
assertThat(sExpression.isAtom).isFalse()
|
||||||
assertThat(sExpression.isCons).isFalse()
|
assertThat(sExpression.isCons).isFalse()
|
||||||
|
@ -104,7 +97,6 @@ object TypeAssertions {
|
||||||
assertThat(sExpression.isAtSign).isFalse()
|
assertThat(sExpression.isAtSign).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun assertCommaExpression(sExpression: SExpression) {
|
fun assertCommaExpression(sExpression: SExpression) {
|
||||||
assertThat(sExpression.isAtom).isFalse()
|
assertThat(sExpression.isAtom).isFalse()
|
||||||
assertThat(sExpression.isCons).isFalse()
|
assertThat(sExpression.isCons).isFalse()
|
||||||
|
@ -119,7 +111,6 @@ object TypeAssertions {
|
||||||
assertThat(sExpression.isAtSign).isFalse()
|
assertThat(sExpression.isAtSign).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun assertAtSignExpression(sExpression: SExpression) {
|
fun assertAtSignExpression(sExpression: SExpression) {
|
||||||
assertThat(sExpression.isAtom).isFalse()
|
assertThat(sExpression.isAtom).isFalse()
|
||||||
assertThat(sExpression.isCons).isFalse()
|
assertThat(sExpression.isCons).isFalse()
|
||||||
|
|
Loading…
Reference in New Issue