Skip to content

Commit 9b60442

Browse files
committed
small refactoring
1 parent 1a43085 commit 9b60442

File tree

4 files changed

+29
-20
lines changed

4 files changed

+29
-20
lines changed

utbot-fuzzers/src/main/kotlin/org/utbot/fuzzer/RandomExtensions.kt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,5 @@ fun Long.invertBit(bitIndex: Int): Long {
3939
return this xor (1L shl bitIndex)
4040
}
4141

42-
43-
fun ModelProvider.assembleModel(id: Int, constructorId: ConstructorId, params: List<FuzzedValue>): FuzzedValue {
44-
val instantiationChain = mutableListOf<UtStatementModel>()
45-
return UtAssembleModel(
46-
id,
47-
constructorId.classId,
48-
"${constructorId.classId.name}${constructorId.parameters}#" + id.hex(),
49-
instantiationChain = instantiationChain,
50-
modificationsChain = mutableListOf()
51-
).apply {
52-
instantiationChain += UtExecutableCallModel(null, constructorId, params.map { it.model }, this)
53-
}.fuzzed {
54-
summary = "%var% = ${constructorId.classId.simpleName}(${constructorId.parameters.joinToString { it.simpleName }})"
55-
}
56-
}
57-
5842
fun Int.hex(): String =
5943
toString(16)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.utbot.fuzzer.objects
2+
3+
import org.utbot.framework.plugin.api.ConstructorId
4+
import org.utbot.framework.plugin.api.UtAssembleModel
5+
import org.utbot.framework.plugin.api.UtExecutableCallModel
6+
import org.utbot.framework.plugin.api.UtStatementModel
7+
import org.utbot.fuzzer.FuzzedValue
8+
import org.utbot.fuzzer.ModelProvider
9+
import org.utbot.fuzzer.hex
10+
11+
12+
fun ModelProvider.assembleModel(id: Int, constructorId: ConstructorId, params: List<FuzzedValue>): FuzzedValue {
13+
val instantiationChain = mutableListOf<UtStatementModel>()
14+
return UtAssembleModel(
15+
id,
16+
constructorId.classId,
17+
"${constructorId.classId.name}${constructorId.parameters}#" + id.hex(),
18+
instantiationChain = instantiationChain,
19+
modificationsChain = mutableListOf()
20+
).apply {
21+
instantiationChain += UtExecutableCallModel(null, constructorId, params.map { it.model }, this)
22+
}.fuzzed {
23+
summary = "%var% = ${constructorId.classId.simpleName}(${constructorId.parameters.joinToString { it.simpleName }})"
24+
}
25+
}

utbot-fuzzers/src/main/kotlin/org/utbot/fuzzer/providers/DateConstantModelProvider.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import org.utbot.fuzzer.FuzzedValue
2020
import org.utbot.fuzzer.IdentityPreservingIdGenerator
2121
import org.utbot.fuzzer.ModelProvider
2222
import org.utbot.fuzzer.ModelProvider.Companion.yieldAllValues
23-
import org.utbot.fuzzer.assembleModel
2423
import org.utbot.fuzzer.defaultModelProviders
2524
import org.utbot.fuzzer.fuzz
2625
import org.utbot.fuzzer.hex
26+
import org.utbot.fuzzer.objects.assembleModel
2727

2828
class DateConstantModelProvider(
2929
private val idGenerator: IdentityPreservingIdGenerator<Int>,
@@ -63,7 +63,7 @@ class DateConstantModelProvider(
6363
return sequence {
6464
constructorsFromNumbers.forEach { constructor ->
6565
yieldAll(
66-
fuzzValuesRecursively(
66+
fuzzValues(
6767
constructor.neededTypes,
6868
baseMethodDescription,
6969
defaultModelProviders(idGenerator)
@@ -113,7 +113,7 @@ class DateConstantModelProvider(
113113
}.take(totalLimit)
114114
}
115115

116-
private fun fuzzValuesRecursively(
116+
private fun fuzzValues(
117117
types: List<ClassId>,
118118
baseMethodDescription: FuzzedMethodDescription,
119119
modelProvider: ModelProvider,

utbot-fuzzers/src/main/kotlin/org/utbot/fuzzer/providers/ObjectModelProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import org.utbot.framework.plugin.api.util.stringClassId
2626
import org.utbot.fuzzer.FuzzedMethodDescription
2727
import org.utbot.fuzzer.FuzzedValue
2828
import org.utbot.fuzzer.IdentityPreservingIdGenerator
29-
import org.utbot.fuzzer.assembleModel
29+
import org.utbot.fuzzer.objects.assembleModel
3030

3131
/**
3232
* Creates [UtAssembleModel] for objects which have public constructors

0 commit comments

Comments
 (0)