Skip to content

Commit d652527

Browse files
committed
Fix a problem with creation of some types
1 parent af4f7de commit d652527

File tree

1 file changed

+12
-16
lines changed
  • utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers

1 file changed

+12
-16
lines changed

utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,21 @@ import java.lang.reflect.Member
1111
import java.lang.reflect.Method
1212
import java.lang.reflect.Modifier
1313

14+
private fun isIgnored(type: ClassId): Boolean {
15+
return type == stringClassId
16+
|| type == dateClassId
17+
|| type == NumberValueProvider.classId
18+
|| type.isCollectionOrMap
19+
|| type.isPrimitiveWrapper
20+
|| type.isEnum
21+
|| type.isAbstract
22+
|| (type.isInner && !type.isStatic)
23+
}
24+
1425
class ObjectValueProvider(
1526
val idGenerator: IdGenerator<Int>,
1627
) : ValueProvider<FuzzedType, FuzzedValue, FuzzedDescription> {
1728

18-
private val unwantedConstructorsClasses = listOf(
19-
stringClassId,
20-
dateClassId,
21-
NumberValueProvider.classId
22-
)
23-
2429
override fun accept(type: FuzzedType) = !isIgnored(type.classId)
2530

2631
override fun generate(
@@ -88,15 +93,6 @@ class ObjectValueProvider(
8893
)
8994
}
9095

91-
private fun isIgnored(type: ClassId): Boolean {
92-
return unwantedConstructorsClasses.contains(type)
93-
|| type.isCollectionOrMap
94-
|| type.isPrimitiveWrapper
95-
|| type.isEnum
96-
|| type.isAbstract
97-
|| (type.isInner && !type.isStatic)
98-
}
99-
10096
private fun findTypesOfNonRecursiveConstructor(type: FuzzedType, packageName: String?): List<ConstructorId> {
10197
return type.classId.allConstructors
10298
.filter { isAccessible(it.constructor, packageName) }
@@ -137,7 +133,7 @@ class CreateObjectAnywayValueProvider(
137133
val useMock: Boolean = false,
138134
) : ValueProvider<FuzzedType, FuzzedValue, FuzzedDescription> {
139135

140-
override fun accept(type: FuzzedType) = type.classId.isRefType
136+
override fun accept(type: FuzzedType) = type.classId.isRefType && !isIgnored(type.classId)
141137

142138
override fun generate(description: FuzzedDescription, type: FuzzedType) = sequence<Seed<FuzzedType, FuzzedValue>> {
143139
val methodCalls = description.constants.filter {

0 commit comments

Comments
 (0)