Skip to content

Commit 06f6e95

Browse files
committed
Enable disabled test due to the fix
1 parent 1115aad commit 06f6e95

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

utbot-framework-test/src/test/kotlin/org/utbot/examples/collections/CustomerExamplesTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal class CustomerExamplesTest: UtValueTestCaseChecker(
1616
testClass = CustomerExamples::class,
1717
testCodeGeneration = true,
1818
pipelines = listOf(
19-
TestLastStage(CodegenLanguage.JAVA, lastStage = TestExecution, parameterizedModeLastStage = Compilation),
19+
TestLastStage(CodegenLanguage.JAVA, lastStage = TestExecution),
2020
TestLastStage(CodegenLanguage.KOTLIN, lastStage = CodeGeneration)
2121
)
2222
) {

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

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,9 +1484,12 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
14841484
substituteStaticFields(statics, isParametrized = true)
14851485

14861486
// build this instance
1487-
thisInstance =
1488-
genericExecution.stateBefore.thisInstance?.let {
1489-
variableConstructor.getOrCreateVariable(it)
1487+
thisInstance = genericExecution.stateBefore.thisInstance?.let {
1488+
if (statics.isNotEmpty()) {
1489+
currentMethodParameters[CgParameterKind.ThisInstance]
1490+
} else {
1491+
variableConstructor.getOrCreateVariable(it)
1492+
}
14901493
}
14911494

14921495
// build arguments for method under test and parameterized test
@@ -1549,6 +1552,24 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
15491552
val executableUnderTestParameters = testSet.executableId.executable.parameters
15501553

15511554
return mutableListOf<CgParameterDeclaration>().apply {
1555+
val statics = genericExecution.stateBefore.statics
1556+
1557+
// this instance
1558+
genericExecution.stateBefore.thisInstance?.let {
1559+
if (statics.isNotEmpty()) {
1560+
val type = wrapTypeIfRequired(it.classId)
1561+
val thisInstance = CgParameterDeclaration(
1562+
parameter = declareParameter(
1563+
type = type,
1564+
name = nameGenerator.variableName(type)
1565+
),
1566+
isReferenceType = true
1567+
)
1568+
this += thisInstance
1569+
currentMethodParameters[CgParameterKind.ThisInstance] = thisInstance.parameter
1570+
}
1571+
}
1572+
15521573
// arguments
15531574
for (index in genericExecution.stateBefore.parameters.indices) {
15541575
val argumentName = paramNames[executableUnderTest]?.get(index)
@@ -1571,7 +1592,6 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
15711592
currentMethodParameters[CgParameterKind.Argument(index)] = argument.parameter
15721593
}
15731594

1574-
val statics = genericExecution.stateBefore.statics
15751595
if (statics.isNotEmpty()) {
15761596
for ((fieldId, model) in statics) {
15771597
val staticType = wrapTypeIfRequired(model.classId)
@@ -1660,12 +1680,18 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
16601680
private fun createExecutionArguments(testSet: CgMethodTestSet, execution: UtExecution): List<CgExpression> {
16611681
val arguments = mutableListOf<CgExpression>()
16621682

1683+
val statics = execution.stateBefore.statics
1684+
execution.stateBefore.thisInstance?.let {
1685+
if (statics.isNotEmpty()) {
1686+
arguments += variableConstructor.getOrCreateVariable(it)
1687+
}
1688+
}
1689+
16631690
for ((paramIndex, paramModel) in execution.stateBefore.parameters.withIndex()) {
16641691
val argumentName = paramNames[testSet.executableId]?.get(paramIndex)
16651692
arguments += variableConstructor.getOrCreateVariable(paramModel, argumentName)
16661693
}
16671694

1668-
val statics = execution.stateBefore.statics
16691695
for ((field, model) in statics) {
16701696
arguments += variableConstructor.getOrCreateVariable(model, field.name)
16711697
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,7 @@ data class CgParameterDeclaration(
750750
* - exception expected from MUT with the given arguments
751751
*/
752752
sealed class CgParameterKind {
753+
object ThisInstance : CgParameterKind()
753754
data class Argument(val index: Int) : CgParameterKind()
754755
data class Statics(val model: UtModel) : CgParameterKind()
755756
object ExpectedResult : CgParameterKind()

0 commit comments

Comments
 (0)