@@ -2,7 +2,6 @@ package org.utbot.framework.codegen.model.constructor.tree
2
2
3
3
import org.utbot.common.PathUtil
4
4
import org.utbot.common.packageName
5
- import org.utbot.engine.isStatic
6
5
import org.utbot.framework.assemble.assemble
7
6
import org.utbot.framework.codegen.ForceStaticMocking
8
7
import org.utbot.framework.codegen.Junit4
@@ -86,6 +85,7 @@ import org.utbot.framework.fields.ExecutionStateAnalyzer
86
85
import org.utbot.framework.fields.FieldPath
87
86
import org.utbot.framework.plugin.api.BuiltinClassId
88
87
import org.utbot.framework.plugin.api.BuiltinMethodId
88
+ import org.utbot.framework.plugin.api.CgMethodTestSet
89
89
import org.utbot.framework.plugin.api.ClassId
90
90
import org.utbot.framework.plugin.api.CodegenLanguage
91
91
import org.utbot.framework.plugin.api.ConcreteExecutionFailureException
@@ -106,8 +106,6 @@ import org.utbot.framework.plugin.api.UtExecution
106
106
import org.utbot.framework.plugin.api.UtExecutionFailure
107
107
import org.utbot.framework.plugin.api.UtExecutionSuccess
108
108
import org.utbot.framework.plugin.api.UtExplicitlyThrownException
109
- import org.utbot.framework.plugin.api.UtMethod
110
- import org.utbot.framework.plugin.api.UtMethodTestSet
111
109
import org.utbot.framework.plugin.api.UtModel
112
110
import org.utbot.framework.plugin.api.UtNewInstanceInstrumentation
113
111
import org.utbot.framework.plugin.api.UtNullModel
@@ -123,6 +121,7 @@ import org.utbot.framework.plugin.api.util.builtinStaticMethodId
123
121
import org.utbot.framework.plugin.api.util.doubleArrayClassId
124
122
import org.utbot.framework.plugin.api.util.doubleClassId
125
123
import org.utbot.framework.plugin.api.util.doubleWrapperClassId
124
+ import org.utbot.framework.plugin.api.util.executable
126
125
import org.utbot.framework.plugin.api.util.field
127
126
import org.utbot.framework.plugin.api.util.floatArrayClassId
128
127
import org.utbot.framework.plugin.api.util.floatClassId
@@ -149,7 +148,6 @@ import org.utbot.framework.util.isUnit
149
148
import org.utbot.summary.SummarySentenceConstants.TAB
150
149
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
151
150
import java.lang.reflect.InvocationTargetException
152
- import kotlin.reflect.jvm.javaType
153
151
154
152
private const val DEEP_EQUALS_MAX_DEPTH = 5 // TODO move it to plugin settings?
155
153
@@ -1086,11 +1084,11 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1086
1084
}
1087
1085
}
1088
1086
1089
- fun createTestMethod (utMethod : UtMethod < * > , execution : UtExecution ): CgTestMethod =
1087
+ fun createTestMethod (executableId : ExecutableId , execution : UtExecution ): CgTestMethod =
1090
1088
withTestMethodScope(execution) {
1091
- val testMethodName = nameGenerator.testMethodNameFor(utMethod , execution.testMethodName)
1089
+ val testMethodName = nameGenerator.testMethodNameFor(executableId , execution.testMethodName)
1092
1090
// TODO: remove this line when SAT-1273 is completed
1093
- execution.displayName = execution.displayName?.let { " ${utMethod.callable .name} : $it " }
1091
+ execution.displayName = execution.displayName?.let { " ${executableId .name} : $it " }
1094
1092
testMethod(testMethodName, execution.displayName) {
1095
1093
rememberInitialStaticFields()
1096
1094
val stateAnalyzer = ExecutionStateAnalyzer (execution)
@@ -1105,7 +1103,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1105
1103
}
1106
1104
// build arguments
1107
1105
for ((index, param) in execution.stateBefore.parameters.withIndex()) {
1108
- val name = paramNames[utMethod ]?.get(index)
1106
+ val name = paramNames[executableId ]?.get(index)
1109
1107
methodArguments + = variableConstructor.getOrCreateVariable(param, name)
1110
1108
}
1111
1109
rememberInitialEnvironmentState(modificationInfo)
@@ -1165,7 +1163,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1165
1163
private val expectedResultVarName = " expectedResult"
1166
1164
private val expectedErrorVarName = " expectedError"
1167
1165
1168
- fun createParameterizedTestMethod (testSet : UtMethodTestSet , dataProviderMethodName : String ): CgTestMethod {
1166
+ fun createParameterizedTestMethod (testSet : CgMethodTestSet , dataProviderMethodName : String ): CgTestMethod {
1169
1167
// TODO: orientation on generic execution may be misleading, but what is the alternative?
1170
1168
// may be a heuristic to select a model with minimal number of internal nulls should be used
1171
1169
val genericExecution = testSet.executions
@@ -1217,11 +1215,11 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1217
1215
}
1218
1216
1219
1217
private fun createParameterDeclarations (
1220
- testSet : UtMethodTestSet ,
1218
+ testSet : CgMethodTestSet ,
1221
1219
genericExecution : UtExecution ,
1222
1220
): List <CgParameterDeclaration > {
1223
- val methodUnderTest = testSet.method
1224
- val methodUnderTestParameters = testSet.method.callable .parameters
1221
+ val executableUnderTest = testSet.executableId
1222
+ val executableUnderTestParameters = testSet.executableId.executable .parameters
1225
1223
1226
1224
return mutableListOf<CgParameterDeclaration >().apply {
1227
1225
// this instance
@@ -1240,9 +1238,9 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1240
1238
}
1241
1239
// arguments
1242
1240
for (index in genericExecution.stateBefore.parameters.indices) {
1243
- val argumentName = paramNames[methodUnderTest ]?.get(index)
1244
- val paramIndex = if (methodUnderTest .isStatic) index else index + 1
1245
- val paramType = methodUnderTestParameters [paramIndex].type.javaType
1241
+ val argumentName = paramNames[executableUnderTest ]?.get(index)
1242
+ val paramIndex = if (executableUnderTest is MethodId && executableUnderTest .isStatic) index else index + 1
1243
+ val paramType = executableUnderTestParameters [paramIndex].parameterizedType
1246
1244
1247
1245
val argumentType = when {
1248
1246
paramType is Class <* > && paramType.isArray -> paramType.id
@@ -1310,7 +1308,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1310
1308
* Standard logic for generating each test case parameter code is used.
1311
1309
*/
1312
1310
fun createParameterizedTestDataProvider (
1313
- testSet : UtMethodTestSet ,
1311
+ testSet : CgMethodTestSet ,
1314
1312
dataProviderMethodName : String
1315
1313
): CgParameterizedTestDataProviderMethod {
1316
1314
return withDataProviderScope {
@@ -1335,14 +1333,14 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1335
1333
}
1336
1334
}
1337
1335
1338
- private fun createExecutionArguments (testSet : UtMethodTestSet , execution : UtExecution ): List <CgExpression > {
1336
+ private fun createExecutionArguments (testSet : CgMethodTestSet , execution : UtExecution ): List <CgExpression > {
1339
1337
val arguments = mutableListOf<CgExpression >()
1340
1338
execution.stateBefore.thisInstance?.let {
1341
1339
arguments + = variableConstructor.getOrCreateVariable(it)
1342
1340
}
1343
1341
1344
1342
for ((paramIndex, paramModel) in execution.stateBefore.parameters.withIndex()) {
1345
- val argumentName = paramNames[testSet.method ]?.get(paramIndex)
1343
+ val argumentName = paramNames[testSet.executableId ]?.get(paramIndex)
1346
1344
arguments + = variableConstructor.getOrCreateVariable(paramModel, argumentName)
1347
1345
}
1348
1346
@@ -1567,7 +1565,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1567
1565
arguments = arrayOf(objectArrayClassId)
1568
1566
)
1569
1567
1570
- private fun containsFailureExecution (testSet : UtMethodTestSet ) =
1568
+ private fun containsFailureExecution (testSet : CgMethodTestSet ) =
1571
1569
testSet.executions.any { it.result is UtExecutionFailure }
1572
1570
1573
1571
@@ -1668,7 +1666,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1668
1666
}
1669
1667
}
1670
1668
1671
- fun errorMethod (method : UtMethod < * > , errors : Map <String , Int >): CgRegion <CgMethod > {
1669
+ fun errorMethod (method : ExecutableId , errors : Map <String , Int >): CgRegion <CgMethod > {
1672
1670
val name = nameGenerator.errorMethodNameFor(method)
1673
1671
val body = block {
1674
1672
comment(" Couldn't generate some tests. List of errors:" )
@@ -1697,7 +1695,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1697
1695
}
1698
1696
}
1699
1697
val errorTestMethod = CgErrorTestMethod (name, body)
1700
- return CgSimpleRegion (" Errors report for ${method.callable. name} " , listOf (errorTestMethod))
1698
+ return CgSimpleRegion (" Errors report for ${method.name} " , listOf (errorTestMethod))
1701
1699
}
1702
1700
1703
1701
private fun getJvmReportDocumentation (jvmReportPath : String ): String {
0 commit comments