blob: 0e5d2d84a4965ebda990419e4752e98b898a8aa0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import moe.nea.lisp.*
import moe.nea.lisp.bind.AutoBinder
import moe.nea.lisp.bind.LispBinding
import java.io.File
import javax.xml.stream.XMLOutputFactory
import kotlin.system.exitProcess
object T
object TestBindings {
@LispBinding("funny-method")
fun funnyMethod(arg: Int, test: String, boolean: Boolean, vararg ast: LispAst): LispData {
if (boolean)
println("From java: $test")
ast.forEach { println(it.toSource()) }
return LispData.LispNumber(arg.toDouble())
}
}
fun main() {
val otherP = LispParser.parse(File(T::class.java.getResource("/scratch.lisp")!!.file))
val executionContext = LispExecutionContext()
executionContext.setupStandardBindings()
executionContext.registerModule(
"secondary",
LispParser.parse(File(T::class.java.getResource("/secondary.lisp")!!.file))
)
val bindings = executionContext.genBindings()
AutoBinder().bindTo(TestBindings, bindings)
val testResults = executionContext.runTests(otherP, "Test", bindings)
val w = XMLOutputFactory.newFactory()
.createXMLStreamWriter(File("TestOutput.xml").bufferedWriter())
TestResultFormatter.write(w, listOf(testResults))
w.close()
if (testResults.allTests.any { it.failures.isNotEmpty() }) {
exitProcess(1)
}
}
|