Skip to content

Commit 8eef11c

Browse files
committed
Enable the disabled test for parameterization
1 parent 7f051a1 commit 8eef11c

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
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: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,9 +1487,8 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
14871487
substituteStaticFields(statics, isParametrized = true)
14881488

14891489
// build this instance
1490-
thisInstance =
1491-
genericExecution.stateBefore.thisInstance?.let {
1492-
variableConstructor.getOrCreateVariable(it)
1490+
thisInstance = genericExecution.stateBefore.thisInstance?.let {
1491+
currentMethodParameters[CgParameterKind.ThisInstance]
14931492
}
14941493

14951494
// build arguments for method under test and parameterized test
@@ -1552,6 +1551,20 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
15521551
val executableUnderTestParameters = testSet.executableId.executable.parameters
15531552

15541553
return mutableListOf<CgParameterDeclaration>().apply {
1554+
// this instance
1555+
genericExecution.stateBefore.thisInstance?.let {
1556+
val type = wrapTypeIfRequired(it.classId)
1557+
val thisInstance = CgParameterDeclaration(
1558+
parameter = declareParameter(
1559+
type = type,
1560+
name = nameGenerator.variableName(type)
1561+
),
1562+
isReferenceType = true
1563+
)
1564+
this += thisInstance
1565+
currentMethodParameters[CgParameterKind.ThisInstance] = thisInstance.parameter
1566+
}
1567+
15551568
// arguments
15561569
for (index in genericExecution.stateBefore.parameters.indices) {
15571570
val argumentName = paramNames[executableUnderTest]?.get(index)
@@ -1663,6 +1676,10 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
16631676
private fun createExecutionArguments(testSet: CgMethodTestSet, execution: UtExecution): List<CgExpression> {
16641677
val arguments = mutableListOf<CgExpression>()
16651678

1679+
execution.stateBefore.thisInstance?.let {
1680+
arguments += variableConstructor.getOrCreateVariable(it)
1681+
}
1682+
16661683
for ((paramIndex, paramModel) in execution.stateBefore.parameters.withIndex()) {
16671684
val argumentName = paramNames[testSet.executableId]?.get(paramIndex)
16681685
arguments += variableConstructor.getOrCreateVariable(paramModel, argumentName)
@@ -1673,7 +1690,6 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
16731690
arguments += variableConstructor.getOrCreateVariable(model, field.name)
16741691
}
16751692

1676-
16771693
val method = currentExecutable!!
16781694
val needsReturnValue = method.returnType != voidClassId
16791695
val containsFailureExecution = containsFailureExecution(testSet)

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
@@ -728,6 +728,7 @@ data class CgParameterDeclaration(
728728
* - exception expected from MUT with the given arguments
729729
*/
730730
sealed class CgParameterKind {
731+
object ThisInstance : CgParameterKind()
731732
data class Argument(val index: Int) : CgParameterKind()
732733
data class Statics(val model: UtModel) : CgParameterKind()
733734
object ExpectedResult : CgParameterKind()

0 commit comments

Comments
 (0)