@@ -34,7 +34,6 @@ import org.usvm.instrumentation.testcase.api.UTestShortExpression
34
34
import org.usvm.instrumentation.testcase.api.UTestStaticMethodCall
35
35
import org.usvm.instrumentation.testcase.api.UTestStringExpression
36
36
import org.utbot.framework.codegen.domain.builtin.UtilMethodProvider
37
- import org.utbot.framework.plugin.api.ConstructorId
38
37
import org.utbot.framework.plugin.api.ExecutableId
39
38
import org.utbot.framework.plugin.api.FieldId
40
39
import org.utbot.framework.plugin.api.MethodId
@@ -54,19 +53,19 @@ import org.utbot.framework.plugin.api.util.objectClassId
54
53
import org.utbot.fuzzer.IdGenerator
55
54
56
55
class UTestInst2UtModelConverter (
57
- private val idGenerator : IdGenerator < Int > ,
56
+ private val uTest : UTest ,
58
57
private val jcClasspath : JcClasspath ,
58
+ private val idGenerator : IdGenerator <Int >,
59
59
private val utilMethodProvider : UtilMethodProvider ,
60
60
) {
61
61
private val exprToModelCache = mutableMapOf<UTestExpression , UtModel >()
62
62
private val instrumentations = mutableListOf<UtInstrumentation >()
63
63
64
- fun processUTest (uTest : UTest ) {
65
- exprToModelCache.clear()
66
- instrumentations.clear()
67
-
64
+ fun processUTest (): UTestAnalysisResult {
68
65
uTest.initStatements.forEach { uInst -> processInst(uInst) }
69
66
removeInstantiationCallFromThisInstanceModificationChain(processExpr(uTest.callMethodExpression))
67
+
68
+ return UTestAnalysisResult (instrumentations)
70
69
}
71
70
72
71
fun findModelByInst (expr : UTestExpression ): UtModel {
@@ -75,8 +74,6 @@ class UTestInst2UtModelConverter(
75
74
return alreadyCreatedModel
76
75
}
77
76
78
- fun findInstrumentations (): List <UtInstrumentation > = instrumentations
79
-
80
77
private fun removeInstantiationCallFromThisInstanceModificationChain (model : UtModel ) {
81
78
if (model is UtAssembleModel ) {
82
79
val instantiationCall = model.instantiationCall
@@ -307,11 +304,11 @@ class UTestInst2UtModelConverter(
307
304
}
308
305
309
306
is UTestGlobalMock -> {
310
- // Daniil said that we can miss [type] and [fields] when converting to [UtInstrumentation]
311
307
val methodsToExprs = uTestExpr.methods.entries
308
+ val initMethodExprs = methodsToExprs.filter { it.key.isConstructor }
309
+ val otherMethodsExprs = methodsToExprs.minus(initMethodExprs.toSet())
312
310
313
- methodsToExprs
314
- .filter { it.key is MethodId }
311
+ otherMethodsExprs
315
312
.forEach { (jcMethod, uTestExprs) ->
316
313
val methodId = jcMethod.toExecutableId(jcClasspath) as MethodId
317
314
val valueModels = uTestExprs.map { expr -> processExpr(expr) }
@@ -323,15 +320,15 @@ class UTestInst2UtModelConverter(
323
320
instrumentations + = methodInstrumentation
324
321
}
325
322
326
- methodsToExprs
327
- .filter { it.key is ConstructorId }
323
+ initMethodExprs
328
324
.forEach { (jcMethod, uTestExprs) ->
329
325
val valueModels = uTestExprs.map { expr -> processExpr(expr) }
330
326
val methodInstrumentation = UtNewInstanceInstrumentation (
331
- // TODO usvm-sbft looking at [Traverser] ln 1682, this classId does not seem correct
332
327
classId = jcMethod.enclosingClass.classId,
333
328
instances = valueModels,
334
- callSites = setOf (jcMethod.enclosingClass.classId),
329
+ // [UTestGlobalMock] does not have an equivalent of [callSites],
330
+ // but it is used only in UtBot instrumentation. We use USVM one, so it is not a problem.
331
+ callSites = emptySet(),
335
332
)
336
333
337
334
instrumentations + = methodInstrumentation
@@ -355,4 +352,8 @@ class UTestInst2UtModelConverter(
355
352
is UTestArrayLengthExpression -> error(" This expression type is not supported" )
356
353
}
357
354
}
358
- }
355
+ }
356
+
357
+ data class UTestAnalysisResult (
358
+ val instrumentation : List <UtInstrumentation >,
359
+ )
0 commit comments