Skip to content

Commit 809d6e8

Browse files
committed
Change coverage format for minimization
1 parent f38f44f commit 809d6e8

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

utbot-python/src/main/kotlin/org/utbot/python/coverage/CoverageApi.kt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ data class PyInstruction(
3636
constructor(lineNumber: Int, id: Long) : this(lineNumber, id.floorDiv(2).toPair().second, id % 2 == 1L)
3737
}
3838

39+
data class PyInstructionEdge(
40+
val instruction1: PyInstruction,
41+
val instruction2: PyInstruction,
42+
) : Instruction(
43+
"",
44+
"",
45+
instruction2.pyLineNumber,
46+
(instruction1.id to instruction2.id).toCoverageId()
47+
) {
48+
override fun toString(): String = "$instruction1 -> $instruction2"
49+
}
50+
3951
fun Boolean.toLong() = if (this) 1L else 0L
4052

4153
fun String.toPyInstruction(): PyInstruction? {
@@ -61,8 +73,17 @@ fun String.toPyInstruction(): PyInstruction? {
6173
}
6274

6375
fun buildCoverage(coveredStatements: List<PyInstruction>, missedStatements: List<PyInstruction>): Coverage {
76+
return buildEdgeCoverage(coveredStatements, missedStatements)
77+
// return Coverage(
78+
// coveredInstructions = coveredStatements,
79+
// instructionsCount = (coveredStatements.size + missedStatements.size).toLong(),
80+
// missedInstructions = missedStatements
81+
// )
82+
}
83+
84+
fun buildEdgeCoverage(coveredStatements: List<PyInstruction>, missedStatements: List<PyInstruction>): Coverage {
6485
return Coverage(
65-
coveredInstructions = coveredStatements,
86+
coveredInstructions = coveredStatements.windowed(2, 1).map { PyInstructionEdge(it[0], it[1]) },
6687
instructionsCount = (coveredStatements.size + missedStatements.size).toLong(),
6788
missedInstructions = missedStatements
6889
)

0 commit comments

Comments
 (0)