Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace nullFuzzedValue with primitive-aware defaultFuzzedValue #2449

Merged
merged 2 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2,6 +2,7 @@ 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
Expand All @@ -11,4 +12,10 @@ fun nullRoutine(classId: ClassId): Routine.Empty<FuzzedType, FuzzedValue> =
Routine.Empty { nullFuzzedValue(classId) }

fun nullFuzzedValue(classId: ClassId): FuzzedValue =
UtNullModel(classId).fuzzed { summary = "%var% = null" }
UtNullModel(classId).fuzzed { summary = "%var% = null" }

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

fun defaultFuzzedValue(classId: ClassId): FuzzedValue =
classId.defaultValueModel().fuzzed { summary = "%var% = $model" }