-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathJavaLangObject.kt
More file actions
35 lines (32 loc) · 1.36 KB
/
JavaLangObject.kt
File metadata and controls
35 lines (32 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package org.utbot.fuzzing.spring
import org.utbot.framework.plugin.api.ClassId
import org.utbot.framework.plugin.api.util.jClass
import org.utbot.framework.plugin.api.util.objectClassId
import org.utbot.fuzzer.FuzzedType
import org.utbot.fuzzer.FuzzedValue
import org.utbot.fuzzer.toTypeParametrizedByTypeVariables
import org.utbot.fuzzing.FuzzedDescription
import org.utbot.fuzzing.JavaValueProvider
import org.utbot.fuzzing.Routine
import org.utbot.fuzzing.Seed
import org.utbot.fuzzing.providers.nullRoutine
import org.utbot.fuzzing.toFuzzerType
class JavaLangObject(
private val classesToTryUsingAsJavaLangObject: List<ClassId>,
) : JavaValueProvider {
override fun accept(type: FuzzedType): Boolean {
return type.classId == objectClassId
}
override fun generate(description: FuzzedDescription, type: FuzzedType): Sequence<Seed<FuzzedType, FuzzedValue>> =
classesToTryUsingAsJavaLangObject.map { classToUseAsObject ->
val fuzzedType = toFuzzerType(
type = classToUseAsObject.jClass.toTypeParametrizedByTypeVariables(),
cache = description.typeCache
)
Seed.Recursive(
construct = Routine.Create(listOf(fuzzedType)) { (value) -> value },
modify = emptySequence(),
empty = nullRoutine(type.classId)
)
}.asSequence()
}