@@ -21,6 +21,9 @@ import org.utbot.python.fuzzing.provider.StrValueProvider
21
21
import org.utbot.python.fuzzing.provider.TupleFixSizeValueProvider
22
22
import org.utbot.python.fuzzing.provider.TupleValueProvider
23
23
import org.utbot.python.fuzzing.provider.UnionValueProvider
24
+ import org.utbot.python.newtyping.PythonProtocolDescription
25
+ import org.utbot.python.newtyping.PythonSubtypeChecker
26
+ import org.utbot.python.newtyping.PythonTypeStorage
24
27
import org.utbot.python.newtyping.general.Type
25
28
26
29
data class PythonFuzzedConcreteValue (
@@ -64,24 +67,31 @@ fun pythonDefaultValueProviders(idGenerator: IdGenerator<Long>) = listOf(
64
67
)
65
68
66
69
class PythonFuzzing (
67
- val execute : suspend (description: PythonMethodDescription , values: List <PythonTreeModel >) -> PythonFeedback
70
+ val pythonTypeStorage : PythonTypeStorage ,
71
+ val execute : suspend (description: PythonMethodDescription , values: List <PythonTreeModel >) -> PythonFeedback ,
68
72
) : Fuzzing<Type, PythonTreeModel, PythonMethodDescription, PythonFeedback> {
69
- override fun generate (description : PythonMethodDescription , type : Type ): Sequence <Seed <Type , PythonTreeModel >> {
73
+ fun generateDefault (description : PythonMethodDescription , type : Type ): Sequence <Seed <Type , PythonTreeModel >> {
70
74
val idGenerator = PythonIdGenerator ()
71
75
return pythonDefaultValueProviders(idGenerator).asSequence().flatMap { provider ->
72
- try {
73
- if (provider.accept(type)) {
74
- provider.generate(description, type)
75
- } else {
76
- emptySequence()
77
- }
78
- } catch (t: Throwable ) {
79
- logger.error(t) { " Error occurs in value provider: $provider " }
76
+ if (provider.accept(type)) {
77
+ provider.generate(description, type)
78
+ } else {
80
79
emptySequence()
81
80
}
82
81
}
83
82
}
84
83
84
+ override fun generate (description : PythonMethodDescription , type : Type ): Sequence <Seed <Type , PythonTreeModel >> {
85
+ var providers = generateDefault(description, type)
86
+ if (type.meta is PythonProtocolDescription ) {
87
+ val subtypes = pythonTypeStorage.allTypes.filter {
88
+ PythonSubtypeChecker .checkIfRightIsSubtypeOfLeft(type, it, pythonTypeStorage)
89
+ }
90
+ subtypes.forEach { providers + = generateDefault(description, it) }
91
+ }
92
+ return providers
93
+ }
94
+
85
95
override suspend fun handle (description : PythonMethodDescription , values : List <PythonTreeModel >): PythonFeedback {
86
96
return execute(description, values)
87
97
}
0 commit comments