diff options
author | nea <nea@nea.moe> | 2023-08-21 16:15:59 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-08-21 16:15:59 +0200 |
commit | 4bbfede4060d38083aafd8a6c7ab2847e0e55ebf (patch) | |
tree | f0ab50180d2fa1c872ba8c20a4b055cd87bed3c9 /test/src/TestLisp.kt | |
parent | de694f30b5e2f6fd62a00e5a622abe0a2411afb9 (diff) | |
download | nealisp-4bbfede4060d38083aafd8a6c7ab2847e0e55ebf.tar.gz nealisp-4bbfede4060d38083aafd8a6c7ab2847e0e55ebf.tar.bz2 nealisp-4bbfede4060d38083aafd8a6c7ab2847e0e55ebf.zip |
method binding
Diffstat (limited to 'test/src/TestLisp.kt')
-rw-r--r-- | test/src/TestLisp.kt | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/test/src/TestLisp.kt b/test/src/TestLisp.kt index 1f287ca..205bea2 100644 --- a/test/src/TestLisp.kt +++ b/test/src/TestLisp.kt @@ -1,15 +1,27 @@ +import moe.nea.lisp.LispData import moe.nea.lisp.LispExecutionContext import moe.nea.lisp.LispParser import moe.nea.lisp.TestResultFormatter +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): LispData { + if (boolean) + println("From java: $test") + return LispData.LispNumber(arg.toDouble()) + } + +} fun main() { - val otherP = LispParser.parse(File(T::class.java.getResource("/test.lisp")!!.file)) + val otherP = LispParser.parse(File(T::class.java.getResource("/scratch.lisp")!!.file)) val executionContext = LispExecutionContext() executionContext.setupStandardBindings() executionContext.registerModule( @@ -17,6 +29,7 @@ fun main() { 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()) |