Skip to content

Commit a1db2de

Browse files
committed
fix requested changes
1 parent dd24006 commit a1db2de

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

utbot-framework/src/main/kotlin/org/utbot/engine/Extensions.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ val <R> UtMethod<R>.isConstructor: Boolean
318318
val <R> UtMethod<R>.isMethod: Boolean
319319
get() = javaMethod != null
320320

321+
val <R> UtMethod<R>.hasThisInParameters: Boolean
322+
get() = !isConstructor && !isStatic
323+
321324
val <R> UtMethod<R>.signature: String
322325
get() {
323326
val methodName = this.callable.name

utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -587,12 +587,12 @@ class UtBotSymbolicEngine(
587587
/**
588588
* Construct sequence of [ExecutionState] that's initialized by fuzzing.
589589
*/
590-
private fun statesInitializedFromFuzzing(state: ExecutionState, hasThis: Boolean): Sequence<ExecutionState> =
590+
private fun statesInitializedFromFuzzing(state: ExecutionState): Sequence<ExecutionState> =
591591
withEnvironmentState(state) {
592592
fuzzInitialModels(::getModelProviderToFuzzingInitializing, FallbackModelProvider { nextDefaultModelId++ })
593593
.map { parameters ->
594594
withIsolatedUpdates {
595-
val stateParametersWithoutThis = if (hasThis) {
595+
val stateParametersWithoutThis = if (methodUnderTest.hasThisInParameters) {
596596
state.parameters.drop(1)
597597
} else {
598598
state.parameters
@@ -1321,32 +1321,33 @@ class UtBotSymbolicEngine(
13211321

13221322
environment.state.parameters += Parameter(localVariable, identityRef.type, value)
13231323

1324-
var nextState = environment.state.updateQueued(
1324+
val nextState = environment.state.updateQueued(
13251325
globalGraph.succ(current),
13261326
SymbolicStateUpdate(localMemoryUpdates = localMemoryUpdate(localVariable to value))
13271327
)
13281328
// TODO: refactor this
1329-
if (UtSettings.useFuzzingInitialization && !isInNestedMethod()) {
1330-
val hasThis = methodUnderTest.run {
1331-
!isStatic && !isConstructor
1332-
}
1329+
val initializedStateByFuzzing = if (UtSettings.useFuzzingInitialization && !isInNestedMethod()) {
13331330
var expectedParamsSize = if (methodUnderTest.isConstructor) {
13341331
methodUnderTest.javaConstructor!!.parameterCount
13351332
} else {
13361333
methodUnderTest.javaMethod!!.parameterCount
13371334
}
1338-
if (hasThis) {
1335+
if (methodUnderTest.hasThisInParameters) {
13391336
++expectedParamsSize
13401337
}
13411338

13421339
if (expectedParamsSize == environment.state.parameters.size) {
1343-
statesInitializedFromFuzzing(nextState, hasThis).firstOrNull()?.let {
1344-
nextState = it
1345-
}
1340+
statesInitializedFromFuzzing(nextState).firstOrNull()
1341+
} else {
1342+
null
13461343
}
1344+
} else {
1345+
null
13471346
}
13481347

1349-
pathSelector.offer(nextState)
1348+
initializedStateByFuzzing?.let {
1349+
pathSelector.offer(it)
1350+
} ?: pathSelector.offer(nextState)
13501351
}
13511352
is JCaughtExceptionRef -> {
13521353
val value = localVariableMemory.local(CAUGHT_EXCEPTION)

0 commit comments

Comments
 (0)