Skip to content

Commit af37218

Browse files
committed
Change non-visible expectedResult type to Object
1 parent 08ded2a commit af37218

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgMethodConstructor.kt

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,10 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
231231
val fieldAccessible = field.isAccessibleFrom(testClassPackageName)
232232

233233
// prevValue is nullable if not accessible because of getStaticFieldValue(..) : Any?
234-
val prevValue = newVar(CgClassId(field.type, isNullable = !fieldAccessible),
235-
"prev${field.name.capitalize()}") {
234+
val prevValue = newVar(
235+
CgClassId(field.type, isNullable = !fieldAccessible),
236+
"prev${field.name.capitalize()}"
237+
) {
236238
if (fieldAccessible) {
237239
declaringClass[field]
238240
} else {
@@ -1072,7 +1074,8 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
10721074
ParametrizedTestSource.DO_NOT_PARAMETRIZE ->
10731075
currentBlock = currentBlock.addAll(generateDeepEqualsAssertion(expected, actual))
10741076
ParametrizedTestSource.PARAMETRIZE -> {
1075-
val assertNullStmt = listOf(testFrameworkManager.assertions[testFramework.assertNull](actual).toStatement())
1077+
val assertNullStmt =
1078+
listOf(testFrameworkManager.assertions[testFramework.assertNull](actual).toStatement())
10761079
currentBlock = currentBlock.add(
10771080
CgIfStatement(
10781081
CgEqualTo(expected, nullLiteral()),
@@ -1198,7 +1201,8 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
11981201
it.variableName,
11991202
// guard initializer to reuse typecast creation logic
12001203
initializer = guardExpression(varType, nullLiteral()).expression,
1201-
isMutable = true)
1204+
isMutable = true
1205+
)
12021206
}
12031207
+tryWithMocksFinallyClosing
12041208
}
@@ -1253,10 +1257,16 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
12531257
}
12541258
val method = currentExecutable as MethodId
12551259
val containsFailureExecution = containsFailureExecution(testSet)
1256-
if (method.returnType != voidClassId) {
1260+
1261+
val expectedResultClassIdType = when {
1262+
method.returnType.isPrivate && !method.returnType.isPublic -> objectClassId
1263+
else -> method.returnType
1264+
}
1265+
1266+
if (expectedResultClassIdType != voidClassId) {
12571267
testArguments += CgParameterDeclaration(
1258-
expectedResultVarName, resultClassId(method.returnType),
1259-
isReferenceType = containsFailureExecution || !method.returnType.isPrimitive
1268+
expectedResultVarName, resultClassId(expectedResultClassIdType),
1269+
isReferenceType = containsFailureExecution || !expectedResultClassIdType.isPrimitive
12601270
)
12611271
}
12621272
if (containsFailureExecution) {
@@ -1676,7 +1686,10 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
16761686
val pureJvmReportPath = jvmReportPath.substringAfter("# ")
16771687

16781688
// \n is here because IntellijIdea cannot process other separators
1679-
return PathUtil.toHtmlLinkTag(PathUtil.replaceSeparator(pureJvmReportPath), fileName = "JVM crash report") + "\n"
1689+
return PathUtil.toHtmlLinkTag(
1690+
PathUtil.replaceSeparator(pureJvmReportPath),
1691+
fileName = "JVM crash report"
1692+
) + "\n"
16801693
}
16811694

16821695
private fun UtConcreteExecutionFailure.extractJvmReportPathOrNull(): String? =

0 commit comments

Comments
 (0)