@@ -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+
3951fun Boolean.toLong () = if (this ) 1L else 0L
4052
4153fun String.toPyInstruction (): PyInstruction ? {
@@ -61,8 +73,17 @@ fun String.toPyInstruction(): PyInstruction? {
6173}
6274
6375fun 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