Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,9 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
substituteStaticFields(statics, isParametrized = true)

// build this instance
thisInstance = genericExecution.stateBefore.thisInstance?.let { currentMethodParameters[CgParameterKind.ThisInstance] }
thisInstance = genericExecution.stateBefore.thisInstance?.let {
variableConstructor.getOrCreateVariable(it)
}

// build arguments for method under test and parameterized test
for (index in genericExecution.stateBefore.parameters.indices) {
Expand Down Expand Up @@ -1430,20 +1432,6 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
val executableUnderTestParameters = testSet.executableId.executable.parameters

return mutableListOf<CgParameterDeclaration>().apply {
// this instance
val thisInstanceModel = genericExecution.stateBefore.thisInstance
if (thisInstanceModel != null) {
val type = wrapTypeIfRequired(thisInstanceModel.classId)
val thisInstance = CgParameterDeclaration(
parameter = declareParameter(
type = type,
name = nameGenerator.variableName(type)
),
isReferenceType = true
)
this += thisInstance
currentMethodParameters[CgParameterKind.ThisInstance] = thisInstance.parameter
}
// arguments
for (index in genericExecution.stateBefore.parameters.indices) {
val argumentName = paramNames[executableUnderTest]?.get(index)
Expand Down Expand Up @@ -1555,9 +1543,6 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c

private fun createExecutionArguments(testSet: CgMethodTestSet, execution: UtExecution): List<CgExpression> {
val arguments = mutableListOf<CgExpression>()
execution.stateBefore.thisInstance?.let {
arguments += variableConstructor.getOrCreateVariable(it)
}

for ((paramIndex, paramModel) in execution.stateBefore.parameters.withIndex()) {
val argumentName = paramNames[testSet.executableId]?.get(paramIndex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,13 +745,11 @@ data class CgParameterDeclaration(

/**
* Test method parameter can be one of the following types:
* - this instance for method under test (MUT)
* - argument of MUT with a certain index
* - result expected from MUT with the given arguments
* - exception expected from MUT with the given arguments
*/
sealed class CgParameterKind {
object ThisInstance : CgParameterKind()
data class Argument(val index: Int) : CgParameterKind()
data class Statics(val model: UtModel) : CgParameterKind()
object ExpectedResult : CgParameterKind()
Expand Down