11@file:JvmName(" FuzzingApi" )
22package org.utbot.fuzzing
33
4+ import kotlinx.coroutines.yield
45import mu.KotlinLogging
56import org.utbot.fuzzing.seeds.KnownValue
67import org.utbot.fuzzing.utils.chooseOne
@@ -259,7 +260,7 @@ suspend fun <T, R, D : Description<T>, F : Feedback<T, R>> Fuzzing<T, R, D, F>.f
259260 val seeds = Statistics <T , R , F >()
260261 run breaking@ {
261262 sequence {
262- while (true ) {
263+ while (description.parameters.isNotEmpty() ) {
263264 if (dynamicallyGenerated.isNotEmpty()) {
264265 yield (dynamicallyGenerated.removeFirst())
265266 } else {
@@ -280,15 +281,11 @@ suspend fun <T, R, D : Description<T>, F : Feedback<T, R>> Fuzzing<T, R, D, F>.f
280281 }
281282 }
282283 }.forEach execution@ { values ->
284+ yield ()
283285 check(values.parameters.size == values.result.size) { " Cannot create value for ${values.parameters} " }
284286 val valuesCache = mutableMapOf<Result <T , R >, R > ()
285287 val result = values.result.map { valuesCache.computeIfAbsent(it) { r -> create(r) } }
286- val feedback = try {
287- fuzzing.handle(description, result)
288- } catch (t: Throwable ) {
289- logger.error(t) { " Error when running fuzzing with $values " }
290- return @execution
291- }
288+ val feedback = fuzzing.handle(description, result)
292289 when (feedback.control) {
293290 Control .CONTINUE -> {
294291 seeds.put(random, configuration, feedback, values)
@@ -634,8 +631,8 @@ private class Node<TYPE, RESULT>(
634631
635632
636633private class Statistics <TYPE , RESULT , FEEDBACK : Feedback <TYPE , RESULT >> {
637- private val seeds = hashMapOf <FEEDBACK , Node <TYPE , RESULT >>()
638- private val count = hashMapOf <FEEDBACK , Long >()
634+ private val seeds = linkedMapOf <FEEDBACK , Node <TYPE , RESULT >>()
635+ private val count = linkedMapOf <FEEDBACK , Long >()
639636
640637 fun put (random : Random , configuration : Configuration , feedback : FEEDBACK , seed : Node <TYPE , RESULT >) {
641638 if (random.flipCoin(configuration.probUpdateSeedInsteadOfKeepOld)) {
0 commit comments