@@ -155,6 +155,7 @@ import org.utbot.framework.plugin.api.util.shortClassId
155
155
import org.utbot.framework.plugin.api.util.shortWrapperClassId
156
156
import org.utbot.framework.plugin.api.util.stringClassId
157
157
import org.utbot.framework.plugin.api.util.voidClassId
158
+ import org.utbot.framework.plugin.api.util.wrapPrimitives
158
159
import org.utbot.framework.util.isUnit
159
160
import org.utbot.summary.SummarySentenceConstants.TAB
160
161
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
@@ -430,22 +431,15 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
430
431
* Generates result assertions in parameterized tests for successful executions
431
432
* and just runs the method if all executions are unsuccessful.
432
433
*/
433
- private fun generateAssertionsForParameterizedTest () {
434
+ private fun generateAssertionsForParameterizedTest (method : MethodId , expectedResult : CgVariable ) {
434
435
emptyLineIfNeeded()
435
- val method = currentExecutable as MethodId
436
436
currentExecution!! .result
437
437
.onSuccess { result ->
438
438
if (result.isUnit()) {
439
439
+ thisInstance[method](* methodArguments.toTypedArray())
440
440
} else {
441
441
resultModel = result
442
442
443
- val expected = variableConstructor.parameterizedVariable(
444
- result.classId,
445
- expectedResultVarName,
446
- isNotNull = true
447
- )
448
-
449
443
val actualVariableName = when (codegenLanguage) {
450
444
CodegenLanguage .JAVA -> when (method.returnType) {
451
445
intClassId -> " ${intWrapperClassId.simpleName.capitalize()} .valueOf(actual)"
@@ -461,7 +455,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
461
455
CodegenLanguage .KOTLIN -> " actual"
462
456
}
463
457
464
- assertEquality(expected , CgVariable (actualVariableName, method.returnType))
458
+ assertEquality(expectedResult , CgVariable (actualVariableName, method.returnType))
465
459
}
466
460
}
467
461
.onFailure { thisInstance[method](* methodArguments.toTypedArray()).intercepted() }
@@ -1254,15 +1248,19 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1254
1248
argument.name, argument.type, isReferenceType = ! argument.type.isPrimitive
1255
1249
)
1256
1250
}
1251
+
1257
1252
val method = currentExecutable as MethodId
1258
1253
val containsFailureExecution = containsFailureExecution(testSet)
1259
1254
1260
- val expectedResultClassId = wrapTypeIfRequired(method.returnType)
1255
+ val expectedResult = variableConstructor.parameterizedVariable(
1256
+ method.returnType.wrapPrimitives(),
1257
+ expectedResultVarName,
1258
+ )
1261
1259
1262
- if (expectedResultClassId != voidClassId) {
1260
+ if (method.returnType != voidClassId) {
1263
1261
testArguments + = CgParameterDeclaration (
1264
- expectedResultVarName, resultClassId(expectedResultClassId) ,
1265
- isReferenceType = containsFailureExecution || ! expectedResultClassId. isPrimitive
1262
+ expectedResult ,
1263
+ isReferenceType = containsFailureExecution || ! expectedResult.type. isPrimitive,
1266
1264
)
1267
1265
}
1268
1266
if (containsFailureExecution) {
@@ -1275,7 +1273,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1275
1273
1276
1274
// record result and generate result assertions
1277
1275
recordActualResult()
1278
- generateAssertionsForParameterizedTest()
1276
+ generateAssertionsForParameterizedTest(method, expectedResult )
1279
1277
}
1280
1278
1281
1279
methodType = PARAMETRIZED
@@ -1539,18 +1537,6 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1539
1537
private fun containsFailureExecution (testSet : UtMethodTestSet ) =
1540
1538
testSet.executions.any { it.result is UtExecutionFailure }
1541
1539
1542
- private fun resultClassId (returnType : ClassId ): ClassId = when (returnType) {
1543
- booleanClassId -> booleanWrapperClassId
1544
- byteClassId -> byteWrapperClassId
1545
- charClassId -> charWrapperClassId
1546
- shortClassId -> shortWrapperClassId
1547
- intClassId -> intWrapperClassId
1548
- longClassId -> longWrapperClassId
1549
- floatClassId -> floatWrapperClassId
1550
- doubleClassId -> doubleWrapperClassId
1551
- else -> returnType
1552
- }
1553
-
1554
1540
/* *
1555
1541
* A [ClassId] for Class<Throwable>.
1556
1542
*/
0 commit comments