[JS][IC][test] Fix step numbers in tests

This commit is contained in:
Dmitriy Dolovov
2023-03-02 15:35:00 +01:00
committed by Space Team
parent 3e7043e1f5
commit 153aed29ba
4 changed files with 21 additions and 9 deletions
@@ -95,9 +95,8 @@ abstract class InfoParser<Info>(protected val infoFile: File) {
}
protected fun diagnosticMessage(message: String, line: String): String {
return "$message in '$line' at ${infoFile.path}:${lineCounter - 1}"
}
protected fun diagnosticMessage(message: String, line: String): String = diagnosticMessage("$message in '$line'")
protected fun diagnosticMessage(message: String): String = "$message at ${infoFile.path}:${lineCounter - 1}"
protected fun throwSyntaxError(line: String): Nothing {
throw AssertionError(diagnosticMessage("Syntax error", line))
@@ -169,7 +168,19 @@ class ProjectInfoParser(infoFile: File) : InfoParser<ProjectInfo>(infoFile) {
val firstId = Integer.parseInt(m.group(1))
val lastId = m.group(2)?.let { Integer.parseInt(it) } ?: firstId
steps += parseSteps(firstId, lastId)
val newSteps = parseSteps(firstId, lastId)
check(newSteps.isNotEmpty()) { diagnosticMessage("No steps have been found") }
val lastStepId = steps.lastOrNull()?.id ?: -1
newSteps.forEachIndexed { index, newStep ->
val expectedStepId = lastStepId + 1 + index
val stepId = newStep.id
check(stepId == expectedStepId) {
diagnosticMessage("Unexpected step number $stepId, expected: $expectedStepId")
}
steps += newStep
}
}
else -> error(diagnosticMessage("Unknown op $op", line))
}
@@ -198,7 +209,7 @@ class ModuleInfoParser(infoFile: File) : InfoParser<ModuleInfo>(infoFile) {
modifications.add(ModuleInfo.Modification.Update(from.trim(), to.trim()))
}
MODIFICATION_DELETE -> modifications.add(ModuleInfo.Modification.Delete(cmd.trim()))
else -> error("Unknown modification $line")
else -> error(diagnosticMessage("Unknown modification: $mop", line))
}
false
} else {
@@ -277,7 +288,8 @@ class ModuleInfoParser(infoFile: File) : InfoParser<ModuleInfo>(infoFile) {
val firstId = Integer.parseInt(stepMatcher.group(1))
val lastId = stepMatcher.group(2)?.let { Integer.parseInt(it) } ?: firstId
parseSteps(firstId, lastId).forEach { step ->
result.steps[step.id] = step
val overwrittenStep = result.steps.put(step.id, step)
check(overwrittenStep == null) { diagnosticMessage("Step ${step.id} redeclaration found") }
}
}
false
@@ -7,7 +7,7 @@ STEP 2:
modifications:
U : l1b.2.kt -> l1b.kt
modified ir: l1b.kt
STEP 2:
STEP 3:
modifications:
U : l1b.3.kt -> l1b.kt
modified ir: l1b.kt
@@ -31,7 +31,7 @@ STEP 6:
modified ir: l1a.kt
STEP 7:
updated exports: l1a.kt, l1b.kt, l1c.kt
STEP 6:
STEP 8:
modifications:
U : l1a.8.kt -> l1a.kt
U : l1b.8.kt -> l1b.kt
@@ -6,7 +6,7 @@ STEP 1:
modifications:
U : l1.1.kt -> l1.kt
modified ir: l1.kt
STEP 1:
STEP 2:
modifications:
U : l1.2.kt -> l1.kt
modified ir: l1.kt