Implement import test, fix import support in compiler and evaluator

This commit is contained in:
Ilya Chernikov
2018-12-09 22:35:39 +01:00
parent fce68102bd
commit 1e74ab5a62
10 changed files with 133 additions and 49 deletions
@@ -14,6 +14,7 @@ import kotlin.script.experimental.dependencies.AsyncDependenciesResolver
import kotlin.script.experimental.dependencies.DependenciesResolver
import kotlin.script.experimental.dependencies.ScriptDependencies
import kotlin.script.experimental.dependencies.ScriptReport
import kotlin.script.experimental.host.FileScriptSource
import kotlin.script.experimental.host.toScriptSource
import kotlin.script.experimental.jvm.JvmDependency
import kotlin.script.experimental.jvm.compat.mapToLegacyScriptReportPosition
@@ -94,8 +95,8 @@ internal fun List<ScriptDiagnostic>.mapScriptReportsToDiagnostics() =
map { ScriptReport(it.message, mapToLegacyScriptReportSeverity(it.severity), mapToLegacyScriptReportPosition(it.location)) }
internal fun ScriptContents.toScriptSource(): SourceCode = when {
file != null -> FileScriptSource(file!!, text?.toString())
text != null -> text!!.toString().toScriptSource()
file != null -> file!!.toScriptSource()
else -> throw IllegalArgumentException("Unable to convert script contents $this into script source")
}