Skip to content

Commit

Permalink
Replace nullFuzzedValue with primitive-aware defaultFuzzedValue
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaMuravjov committed Jul 25, 2023
1 parent b67debe commit ebe06b4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class EmptyCollectionValueProvider(
summary = "%var% = ${executableId.classId.simpleName}#${executableId.name}"
}
} else {
nullFuzzedValue(classId)
defaultFuzzedValue(classId)
}
},
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class FieldValueProvider(
val thisInstanceValue = values.single()
val thisInstanceModel = when (val model = thisInstanceValue.model) {
is UtReferenceModel -> model
is UtNullModel -> return@Create nullFuzzedValue(type.classId)
is UtNullModel -> return@Create defaultFuzzedValue(type.classId)
else -> {
logger.warn { "This instance model can be only UtReferenceModel or UtNullModel, but $model is met" }
return@Create nullFuzzedValue(type.classId)
return@Create defaultFuzzedValue(type.classId)
}
}
UtAssembleModel(
Expand All @@ -62,7 +62,7 @@ class FieldValueProvider(
}
},
modify = emptySequence(),
empty = nullRoutine(type.classId)
empty = defaultValueRoutine(type.classId)
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class ObjectValueProvider(
}
}
},
empty = nullRoutine(classId)
empty = defaultValueRoutine(classId)
)
}
}
Expand All @@ -127,7 +127,7 @@ object NullValueProvider : ValueProvider<FuzzedType, FuzzedValue, FuzzedDescript
type: FuzzedType
) = sequence<Seed<FuzzedType, FuzzedValue>> {
if (description.scope?.getProperty(NULLABLE_PROP) == true) {
yield(Seed.Simple(nullFuzzedValue(classClassId)))
yield(Seed.Simple(defaultFuzzedValue(classClassId)))
}
}
}
Expand Down Expand Up @@ -180,7 +180,7 @@ class AbstractsObjectValueProvider(
construct = Routine.Create(listOf(toFuzzerType(concrete.id.jClass, description.typeCache))) {
it.first()
},
empty = nullRoutine(type.classId)
empty = defaultValueRoutine(type.classId)
))
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.utbot.fuzzing.providers

import org.utbot.framework.plugin.api.ClassId
import org.utbot.framework.plugin.api.UtNullModel
import org.utbot.framework.plugin.api.util.defaultValueModel
import org.utbot.fuzzer.FuzzedType
import org.utbot.fuzzer.FuzzedValue
import org.utbot.fuzzer.fuzzed
import org.utbot.fuzzing.Routine

fun nullRoutine(classId: ClassId): Routine.Empty<FuzzedType, FuzzedValue> =
Routine.Empty { nullFuzzedValue(classId) }
fun defaultValueRoutine(classId: ClassId): Routine.Empty<FuzzedType, FuzzedValue> =
Routine.Empty { defaultFuzzedValue(classId) }

fun nullFuzzedValue(classId: ClassId): FuzzedValue =
UtNullModel(classId).fuzzed { summary = "%var% = null" }
fun defaultFuzzedValue(classId: ClassId): FuzzedValue =
classId.defaultValueModel().fuzzed { summary = "%var% = $model" }
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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.providers.defaultValueRoutine
import org.utbot.fuzzing.toFuzzerType

class SavedEntityValueProvider(
Expand Down Expand Up @@ -42,7 +42,7 @@ class SavedEntityValueProvider(
}
},
modify = emptySequence(),
empty = nullRoutine(type.classId)
empty = defaultValueRoutine(type.classId)
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.utbot.fuzzer.IdGenerator
import org.utbot.fuzzer.fuzzed
import org.utbot.fuzzing.*
import org.utbot.fuzzing.providers.SPRING_BEAN_PROP
import org.utbot.fuzzing.providers.nullRoutine
import org.utbot.fuzzing.providers.defaultValueRoutine

class SpringBeanValueProvider(
private val idGenerator: IdGenerator<Int>,
Expand Down Expand Up @@ -60,7 +60,7 @@ class SpringBeanValueProvider(
})
}
},
empty = nullRoutine(type.classId)
empty = defaultValueRoutine(type.classId)
)
)
}
Expand Down

0 comments on commit ebe06b4

Please sign in to comment.