-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
abb6268
commit 0587302
Showing
19 changed files
with
250 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...uzzing/src/main/kotlin/org/utbot/fuzzing/providers/ModifyingWithMethodsProviderWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.utbot.fuzzing.providers | ||
|
||
import org.utbot.framework.plugin.api.ClassId | ||
import org.utbot.framework.plugin.api.UtAssembleModel | ||
import org.utbot.framework.plugin.api.UtExecutableCallModel | ||
import org.utbot.framework.plugin.api.util.executableId | ||
import org.utbot.fuzzer.FuzzedType | ||
import org.utbot.fuzzer.FuzzedValue | ||
import org.utbot.fuzzing.FuzzedDescription | ||
import org.utbot.fuzzing.JavaValueProvider | ||
import org.utbot.fuzzing.Routine | ||
import org.utbot.fuzzing.Scope | ||
import org.utbot.fuzzing.Seed | ||
|
||
/** | ||
* Value provider that is a buddy for another provider | ||
* that keeps all it's functionality and also allows | ||
* to use methods to mutate field states of an object. | ||
* | ||
* NOTE!!! | ||
* Instances represented by [UtAssembleModel] only can be mutated with methods. | ||
*/ | ||
class ModifyingWithMethodsProviderWrapper( | ||
private val classUnderTest: ClassId, | ||
private val delegate: JavaValueProvider | ||
) : JavaValueProvider by delegate { | ||
|
||
override fun generate(description: FuzzedDescription, type: FuzzedType): Sequence<Seed<FuzzedType, FuzzedValue>> = | ||
delegate | ||
.generate(description, type) | ||
.map { seed -> | ||
if (seed is Seed.Recursive) { | ||
Seed.Recursive( | ||
construct = seed.construct, | ||
modify = seed.modify + | ||
findMethodsToModifyWith(description, type.classId, classUnderTest) | ||
.asSequence() | ||
.map { md -> | ||
Routine.Call(md.parameterTypes) { self, values -> | ||
val model = self.model as UtAssembleModel | ||
model.modificationsChain as MutableList += | ||
UtExecutableCallModel( | ||
model, | ||
md.method.executableId, | ||
values.map { it.model } | ||
) | ||
} | ||
}, | ||
empty = seed.empty, | ||
) | ||
} else seed | ||
} | ||
|
||
override fun enrich(description: FuzzedDescription, type: FuzzedType, scope: Scope) = | ||
delegate.enrich(description, type, scope) | ||
|
||
override fun accept(type: FuzzedType): Boolean = delegate.accept(type) | ||
} |
Oops, something went wrong.