@@ -12,7 +12,7 @@ fun interface ModelProvider {
1212 * @param description a fuzzed method description
1313 * @param consumer accepts index in the parameter list and [UtModel] for this parameter.
1414 */
15- fun generate (description : FuzzedMethodDescription , consumer : BiConsumer <Int , UtModel >)
15+ fun generate (description : FuzzedMethodDescription , consumer : BiConsumer <Int , FuzzedValue >)
1616
1717 /* *
1818 * Combines this model provider with `anotherModelProvider` into one instance.
@@ -52,7 +52,7 @@ fun interface ModelProvider {
5252 */
5353 fun withFallback (modelProvider : ModelProvider ) : ModelProvider {
5454 return ModelProvider { description, consumer ->
55- val providedByDelegateMethodParameters = mutableMapOf<Int , MutableList <UtModel >>()
55+ val providedByDelegateMethodParameters = mutableMapOf<Int , MutableList <FuzzedValue >>()
5656 this @ModelProvider.generate(description) { index, model ->
5757 providedByDelegateMethodParameters.computeIfAbsent(index) { mutableListOf () }.add(model)
5858 }
@@ -64,7 +64,7 @@ fun interface ModelProvider {
6464 val missingParameters =
6565 (0 until description.parameters.size).filter { ! providedByDelegateMethodParameters.containsKey(it) }
6666 if (missingParameters.isNotEmpty()) {
67- val values = mutableMapOf<Int , MutableList <UtModel >>()
67+ val values = mutableMapOf<Int , MutableList <FuzzedValue >>()
6868 modelProvider.generate(description) { i, m -> values.computeIfAbsent(i) { mutableListOf () }.add(m) }
6969 missingParameters.forEach { index ->
7070 values[index]?.let { models ->
@@ -90,7 +90,7 @@ fun interface ModelProvider {
9090 description.parametersMap.forEach { (classId, indices) ->
9191 fallbackModelSupplier(classId)?.let { model ->
9292 indices.forEach { index ->
93- consumer.accept(index, model)
93+ consumer.accept(index, model.fuzzed() )
9494 }
9595 }
9696 }
@@ -103,15 +103,15 @@ fun interface ModelProvider {
103103 return Combined (providers.toList())
104104 }
105105
106- fun BiConsumer <Int , UtModel >.consumeAll (indices : List <Int >, models : Sequence <UtModel >) {
106+ fun BiConsumer <Int , FuzzedValue >.consumeAll (indices : List <Int >, models : Sequence <FuzzedValue >) {
107107 models.forEach { model ->
108108 indices.forEach { index ->
109109 accept(index, model)
110110 }
111111 }
112112 }
113113
114- fun BiConsumer <Int , UtModel >.consumeAll (indices : List <Int >, models : List <UtModel >) {
114+ fun BiConsumer <Int , FuzzedValue >.consumeAll (indices : List <Int >, models : List <FuzzedValue >) {
115115 consumeAll(indices, models.asSequence())
116116 }
117117 }
@@ -120,12 +120,14 @@ fun interface ModelProvider {
120120 * Wrapper class that delegates implementation to the [providers].
121121 */
122122 private class Combined (val providers : List <ModelProvider >): ModelProvider {
123- override fun generate (description : FuzzedMethodDescription , consumer : BiConsumer <Int , UtModel >) {
123+ override fun generate (description : FuzzedMethodDescription , consumer : BiConsumer <Int , FuzzedValue >) {
124124 providers.forEach { provider ->
125125 provider.generate(description, consumer)
126126 }
127127 }
128128 }
129+
130+ fun UtModel.fuzzed (block : FuzzedValue .() -> Unit = {}): FuzzedValue = FuzzedValue (this , this @ModelProvider).apply (block)
129131}
130132
131133inline fun <reified T > ModelProvider.exceptIsInstance (): ModelProvider {
0 commit comments