@@ -29,6 +29,7 @@ import org.utbot.framework.plugin.api.util.isPrimitive
29
29
import org.utbot.framework.plugin.api.util.jClass
30
30
import org.utbot.framework.plugin.api.util.longClassId
31
31
import org.utbot.framework.plugin.api.util.method
32
+ import org.utbot.framework.plugin.api.util.objectClassId
32
33
import org.utbot.framework.plugin.api.util.primitiveTypeJvmNameOrNull
33
34
import org.utbot.framework.plugin.api.util.shortClassId
34
35
import org.utbot.framework.plugin.api.util.toReferenceTypeBytecodeSignature
@@ -98,26 +99,46 @@ data class UtMethodTestSet(
98
99
val clustersInfo : List <Pair <UtClusterInfo ?, IntRange >> = listOf(null to executions.indices)
99
100
)
100
101
101
- data class CgMethodTestSet internal constructor(
102
+ data class CgMethodTestSet private constructor(
102
103
val executableId : ExecutableId ,
103
- val executions : List <UtExecution > = emptyList(),
104
104
val jimpleBody : JimpleBody ? = null ,
105
105
val errors : Map <String , Int > = emptyMap(),
106
- val clustersInfo : List <Pair <UtClusterInfo ?, IntRange >> = listOf(null to executions.indices)
106
+ val clustersInfo : List <Pair <UtClusterInfo ?, IntRange >>,
107
107
) {
108
+ var executions: List <UtExecution > = emptyList()
109
+ private set
110
+
108
111
constructor (from: UtMethodTestSet ) : this (
109
112
from.method.callable.executableId,
110
- from.executions,
111
113
from.jimpleBody,
112
114
from.errors,
113
115
from.clustersInfo
114
- )
115
- }
116
+ ) {
117
+ executions = from.executions
118
+ }
116
119
117
- fun CgMethodTestSet.substituteExecutions (executions : List <UtExecution >): CgMethodTestSet {
118
- return CgMethodTestSet (this .executableId, executions, this .jimpleBody, this .errors, this .clustersInfo)
120
+ /* *
121
+ * Splits [CgMethodTestSet] into separate test sets having
122
+ * unique result model [ClassId] in each subset.
123
+ */
124
+ fun splitExecutionsByResult () : List <CgMethodTestSet > {
125
+ val executionsByResult: Map <ClassId , List <UtExecution >> =
126
+ if (executions.any { it.result is UtExecutionSuccess })
127
+ executions
128
+ .filter { it.result is UtExecutionSuccess }
129
+ .groupBy { (it.result as UtExecutionSuccess ).model.classId }
130
+ else {
131
+ mapOf (objectClassId to executions)
132
+ }
133
+
134
+ return executionsByResult.map{ (_, executions) -> substituteExecutions(executions) }
135
+ }
136
+
137
+ private fun substituteExecutions (newExecutions : List <UtExecution >): CgMethodTestSet =
138
+ this .copy().apply { executions = newExecutions }
119
139
}
120
140
141
+
121
142
data class Step (
122
143
val stmt : Stmt ,
123
144
val depth : Int ,
0 commit comments