@@ -65,15 +65,8 @@ class JcTestExecutor(
65
65
classConstants : Map <JcType , UConcreteHeapRef >,
66
66
allowSymbolicResult : Boolean
67
67
): JcExecution ? {
68
- val model = state.models.first()
69
- val mocker = state.memory.mocker as JcMocker
70
-
71
- val resolvedMethodMocks = mocker.symbols
72
- .entries
73
- .groupBy({ model.eval(it.key) }, { it.value })
74
- .mapValues { it.value.flatten() }
75
-
76
- val uTest = createUTest(method, state, stringConstants, classConstants)
68
+ val memoryScope = createMemoryScope(state, stringConstants, classConstants, method)
69
+ val uTest = memoryScope.createUTest()
77
70
78
71
val concreteResult = runCatching {
79
72
runBlocking {
@@ -90,17 +83,8 @@ class JcTestExecutor(
90
83
when (val methodResult = state.methodResult) {
91
84
is JcMethodResult .JcException -> UTestSymbolicExceptionResult (methodResult.type)
92
85
is JcMethodResult .Success -> {
93
- val resultScope = MemoryScope (
94
- state.ctx,
95
- model,
96
- state.memory,
97
- stringConstants,
98
- classConstants,
99
- resolvedMethodMocks,
100
- method
101
- )
102
- val resultExpr = resultScope.resolveExpr(methodResult.value, method.returnType)
103
- val resultInitializer = resultScope.decoderApi.initializerInstructions()
86
+ val resultExpr = memoryScope.resolveExpr(methodResult.value, method.returnType)
87
+ val resultInitializer = memoryScope.decoderApi.initializerInstructions()
104
88
UTestSymbolicSuccessResult (resultInitializer, resultExpr)
105
89
}
106
90
@@ -145,6 +129,16 @@ class JcTestExecutor(
145
129
stringConstants : Map <String , UConcreteHeapRef >,
146
130
classConstants : Map <JcType , UConcreteHeapRef >,
147
131
): UTest {
132
+ val memoryScope = createMemoryScope(state, stringConstants, classConstants, method)
133
+ return memoryScope.createUTest()
134
+ }
135
+
136
+ private fun createMemoryScope (
137
+ state : JcState ,
138
+ stringConstants : Map <String , UConcreteHeapRef >,
139
+ classConstants : Map <JcType , UConcreteHeapRef >,
140
+ method : JcTypedMethod
141
+ ): MemoryScope {
148
142
val model = state.models.first()
149
143
val ctx = state.ctx
150
144
@@ -158,8 +152,7 @@ class JcTestExecutor(
158
152
.mapValues { it.value.flatten() }
159
153
160
154
val memoryScope = MemoryScope (ctx, model, model, stringConstants, classConstants, resolvedMethodMocks, method)
161
-
162
- return memoryScope.createUTest()
155
+ return memoryScope
163
156
}
164
157
165
158
@Suppress(" UNUSED_PARAMETER" )
0 commit comments