[REPL] Fix syntax errors analysis and incompleteness detection

This commit is contained in:
Ilya Muradyan
2021-03-29 14:37:10 +03:00
parent 736efe0403
commit d40ada5d07
5 changed files with 45 additions and 12 deletions
@@ -198,6 +198,20 @@ class ReplCompletionAndErrorsAnalysisTest : TestCase() {
}
}
@Test
fun testIncompleteCode() = test {
run {
doErrorCheck
code = "fun g(): Int { return 1"
expect {
addError(1, 24, 1, 24, "Expecting '}'", "ERROR")
errors.add(ScriptDiagnostic(ScriptDiagnostic.incompleteCode, "Incomplete code"))
}
}
}
@Test
fun testCompletionDuplication() = test {
for (i in 1..6) {
@@ -283,7 +283,7 @@ private suspend fun checkEvaluateInRepl(
checkLists(index, "completions", expectedCompletions.list, completionsRes, expectedCompletions)
val expectedErrorsWithPath = expectedErrors.list.map {
it.copy(sourcePath = errorsRes.firstOrNull()?.sourcePath)
if (it.location != null) it.copy(sourcePath = errorsRes.firstOrNull()?.sourcePath) else it
}
checkLists(index, "errors", expectedErrorsWithPath, errorsRes, expectedErrors)
TestCase.assertEquals("Analysis result types are different", expectedResultType, resultType)