Skip to content

Commit 6cd18c8

Browse files
committed
Fix FakeNode in ComplexValueProvider
1 parent e6d27ca commit 6cd18c8

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/ComplexValueProvider.kt

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,37 @@ object ComplexValueProvider : ValueProvider<UtType, PythonFuzzedValue, PythonMet
2424
description.pythonTypeStorage.pythonInt
2525
)
2626
)
27+
val emptyValue =
28+
PythonFuzzedValue(
29+
PythonTree.PrimitiveNode(
30+
pythonComplexClassId,
31+
"complex()"
32+
),
33+
"%var% = ${type.pythonTypeRepresentation()}"
34+
)
2735
yield(Seed.Recursive(
2836
construct = Routine.Create(
2937
listOf(
3038
numberType,
3139
numberType
3240
)
3341
) { v ->
34-
val real = v[0].tree as PythonTree.PrimitiveNode
35-
val imag = v[1].tree as PythonTree.PrimitiveNode
36-
val repr = "complex(real=${real.repr}, imag=${imag.repr})"
37-
PythonFuzzedValue(
38-
PythonTree.PrimitiveNode(
39-
pythonComplexClassId,
40-
repr
41-
),
42-
"%var% = $repr"
43-
)
42+
if (v[0].tree is PythonTree.FakeNode || v[1].tree is PythonTree.FakeNode) {
43+
emptyValue
44+
} else {
45+
val real = v[0].tree as PythonTree.PrimitiveNode
46+
val imag = v[1].tree as PythonTree.PrimitiveNode
47+
val repr = "complex(real=${real.repr}, imag=${imag.repr})"
48+
PythonFuzzedValue(
49+
PythonTree.PrimitiveNode(
50+
pythonComplexClassId,
51+
repr
52+
),
53+
"%var% = $repr"
54+
)
55+
}
4456
},
45-
empty = Routine.Empty {
46-
PythonFuzzedValue(
47-
PythonTree.PrimitiveNode(
48-
pythonComplexClassId,
49-
"complex()"
50-
),
51-
"%var% = ${type.pythonTypeRepresentation()}"
52-
)
53-
}
57+
empty = Routine.Empty { emptyValue }
5458
))
5559
}
5660
}

0 commit comments

Comments
 (0)