Properly handle REPL snippets with exceptions ...
so the REPL remain operational after exception in one of the snippets: - separately return script class and script instance on evaluation ( because in case of an exception the class is valid, while the instance is not). - store both the class and the instance in the history - handle this data accordingly
This commit is contained in:
+9
-6
@@ -80,9 +80,11 @@ class ReplTest : TestCase() {
|
||||
simpleScriptompilationConfiguration,
|
||||
simpleScriptEvaluationConfiguration,
|
||||
sequenceOf(
|
||||
"throw RuntimeException(\"abc\")"
|
||||
"throw RuntimeException(\"abc\")",
|
||||
"val x = 3",
|
||||
"x + 1"
|
||||
),
|
||||
sequenceOf(RuntimeException("abc"))
|
||||
sequenceOf(RuntimeException("abc"), null, 4)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -107,11 +109,12 @@ class ReplTest : TestCase() {
|
||||
}
|
||||
}
|
||||
.onSuccess {
|
||||
it.returnValue.scriptInstance?.let { snippetInstance ->
|
||||
currentEvalConfig = ScriptEvaluationConfiguration(currentEvalConfig) {
|
||||
previousSnippets.append(snippetInstance)
|
||||
val snippetClass = it.returnValue.scriptClass
|
||||
currentEvalConfig = ScriptEvaluationConfiguration(currentEvalConfig) {
|
||||
previousSnippets.append(it.returnValue.scriptInstance)
|
||||
if (snippetClass != null) {
|
||||
jvm {
|
||||
baseClassLoader(snippetInstance::class.java.classLoader)
|
||||
baseClassLoader(snippetClass.java.classLoader)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user