Skip to content

Commit af2cbdf

Browse files
committed
Avoid recording multiple mock answers if same answer is reused over and over again
1 parent b1baf5c commit af2cbdf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/InstrumentationContextAwareValueConstructor.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,13 @@ class InstrumentationContextAwareValueConstructor(
236236
val answerValue = answerValues[pointer]
237237
val answerModel = answerModels[pointer]
238238
pointer = (pointer + 1) % answerValues.size
239-
(mockModel.mocks.getOrPut(executableId) { mutableListOf() } as MutableList).add(answerModel)
239+
240+
// Record mock answers into `mockModel.mocks` as these answers are used.
241+
// Avoid recording multiple answers if same answer is reused over and over again.
242+
if (answerValues.size > 1 || executableId !in mockModel.mocks) {
243+
(mockModel.mocks.getOrPut(executableId) { mutableListOf() } as MutableList).add(answerModel)
244+
}
245+
240246
return answerValue
241247
}
242248
}

0 commit comments

Comments
 (0)