Skip to content

Cleanup CgMethodTestSet class #1367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -11,51 +11,28 @@ import org.utbot.framework.plugin.api.UtSymbolicExecution
import org.utbot.framework.plugin.api.util.objectClassId
import org.utbot.framework.plugin.api.util.voidClassId
import org.utbot.fuzzer.UtFuzzedExecution
import soot.jimple.JimpleBody

data class CgMethodTestSet constructor(
val executableId: ExecutableId,
val jimpleBody: JimpleBody? = null,
val errors: Map<String, Int> = emptyMap(),
val clustersInfo: List<Pair<UtClusterInfo?, IntRange>>,
) {
var executions: List<UtExecution> = emptyList()
private set

constructor(from: UtMethodTestSet) : this(
from.method,
from.jimpleBody,
from.errors,
from.clustersInfo
) {
constructor(from: UtMethodTestSet) : this(from.method, from.errors, from.clustersInfo) {
executions = from.executions
}

/**
* For JavaScript purposes.
* Constructor for JavaScript and Python purposes.
*/
constructor(
executableId: ExecutableId,
execs: List<UtExecution> = emptyList(),
errors: Map<String, Int> = emptyMap()
) : this(
executableId,
null,
errors,
listOf(null to execs.indices)
) {
executions = execs
}

constructor(
executableId: ExecutableId,
errors: Map<String, Int> = emptyMap(),
executions: List<UtExecution> = emptyList(),
) : this(
executableId,
null,
emptyMap(),

listOf(null to executions.indices)
) {
clustersInfo: List<Pair<UtClusterInfo?, IntRange>> = listOf(null to executions.indices),
) : this(executableId, errors, clustersInfo) {
this.executions = executions
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ open class CgTestClassConstructor(val context: CgContext) :
testSet: CgMethodTestSet,
regions: MutableList<CgRegion<CgMethod>>
) {
val (methodUnderTest, _, _, clustersInfo) = testSet
val (methodUnderTest, _, clustersInfo) = testSet

for ((clusterSummary, executionIndices) in clustersInfo) {
val currentTestCaseTestMethods = mutableListOf<CgTestMethod>()
Expand Down Expand Up @@ -208,7 +208,7 @@ open class CgTestClassConstructor(val context: CgContext) :
testSet: CgMethodTestSet,
regions: MutableList<CgRegion<CgMethod>>
) {
val (methodUnderTest, _, _, _) = testSet
val (methodUnderTest, _, _) = testSet

for (preparedTestSet in testSet.prepareTestSetsForParameterizedTestGeneration()) {
val dataProviderMethodName = nameGenerator.dataProviderMethodNameFor(preparedTestSet.executableId)
Expand Down
6 changes: 3 additions & 3 deletions utbot-js/src/main/kotlin/api/JsTestGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ class JsTestGenerator(
)
}
val testSet = CgMethodTestSet(
execId,
testsForGenerator,
errorsForGenerator
executableId = execId,
errors = errorsForGenerator,
executions = testsForGenerator,
)
testSets += testSet
paramNames[execId] = funcNode.parameters.map { it.name.toString() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ object PythonTestGenerationProcessor {
val testCode = codegen.pythonGenerateAsStringWithTestReport(
notEmptyTests.map { testSet ->
CgMethodTestSet(
methodIds[testSet.method] as ExecutableId,
testSet.executions
executableId = methodIds[testSet.method] as ExecutableId,
executions = testSet.executions
)
},
allImports
Expand Down