Skip to content

Commit 8835a63

Browse files
committed
Review fixes
1 parent 8d48a93 commit 8835a63

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

docs/AssumptionsMechanism.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ int foo(List<Integer> list) {
8080
}
8181
}
8282
```
83-
Now we will cover all two branches of the MUT. How did we do it?
83+
Now we will cover both branches of the MUT. How did we do it?
8484
At the moment we processed `if` condition we got conflicting constraints: `list.size <= 10` and
8585
`list.size > 10`. In contrast to the example with `assume` method usage, here we know that
8686
we got conflict with the provided predicate and we stop symbolic analysis, remove this assumption from

utbot-framework/src/main/kotlin/org/utbot/engine/pc/UtSolver.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ data class UtSolver constructor(
194194
New solver hasn't already added constraints thus we must add them again
195195
*/
196196
copy(
197-
constraints = newConstraints,
197+
// We pass here undefined status to force calculation
198+
// at the next `check` call. Otherwise, we'd ignore
199+
// the given assumptions and return already calculated status.
200+
constraints = newConstraints.withStatus(UtSolverStatusUNDEFINED),
198201
hardConstraintsNotYetAddedToZ3Solver = newConstraints.hard,
199202
assumption = this.assumption + assumption,
200203
z3Solver = context.mkSolver().also { it.setParameters(params) },
@@ -208,14 +211,12 @@ data class UtSolver constructor(
208211
}
209212

210213
val translatedSoft = if (respectSoft && preferredCexOption) {
211-
constraints.soft.associateByTo(mutableMapOf()) { translator.translate(it) as BoolExpr }
214+
constraints.soft.translate()
212215
} else {
213216
mutableMapOf()
214217
}
215218

216-
val translatedAssumes = assumption.constraints.associateByTo(mutableMapOf()) {
217-
translator.translate(it) as BoolExpr
218-
}
219+
val translatedAssumes = assumption.constraints.translate()
219220

220221
val statusHolder = logger.trace().bracket("High level check(): ", { it }) {
221222
Predictors.smtIncremental.learnOn(IncrementalData(constraints.hard, hardConstraintsNotYetAddedToZ3Solver)) {
@@ -309,6 +310,9 @@ data class UtSolver constructor(
309310
}
310311
}
311312
}
313+
314+
private fun Collection<UtBoolExpression>.translate(): MutableMap<BoolExpr, UtBoolExpression> =
315+
associateByTo(mutableMapOf()) { translator.translate(it) as BoolExpr }
312316
}
313317

314318
enum class UtSolverStatusKind {

0 commit comments

Comments
 (0)