-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathFuzzedMethodDescription.kt
77 lines (67 loc) · 2.19 KB
/
FuzzedMethodDescription.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package org.utbot.fuzzer
import org.utbot.framework.plugin.api.ClassId
import org.utbot.framework.plugin.api.ExecutableId
/**
* Method traverser is an object,
* that helps to collect information about a method.
*
* @param name pretty name of the method
* @param returnType type of returning value
* @param parameters method parameters types
* @param concreteValues any concrete values to be processed by fuzzer
*
*/
class FuzzedMethodDescription(
val name: String,
val returnType: ClassId,
val parameters: List<ClassId>,
val concreteValues: Collection<FuzzedConcreteValue> = emptyList()
) {
/**
* Name that can be used to generate test names
*/
var compilableName: String? = null
/**
* Class Name
*/
var className: String? = null
/**
* Package Name
*/
var packageName: String? = null
/**
* Returns parameter name by its index in the signature
*/
var parameterNameMap: (Int) -> String? = { null }
/**
* For every parameter returns a list with acceptable types.
* Usually it keeps upper bound.
*
* Every parameter can have several parameter types.
* For example [Map] has two type parameters, [Collection] has only one.
*
* Fuzzer doesn't care about interconnection between these types, therefore it waits
* that function already has all necessary information to bound this values.
*/
var fuzzerType: (Int) -> FuzzedType? = { null }
/**
* Returns true if class should be mocked.
*/
var shouldMock: (ClassId) -> Boolean = { false }
/**
* Map class id to indices of this class in parameters list.
*/
val parametersMap: Map<ClassId, List<Int>> by lazy {
val result = mutableMapOf<ClassId, MutableList<Int>>()
parameters.forEachIndexed { index, classId ->
result.computeIfAbsent(classId) { mutableListOf() }.add(index)
}
result
}
constructor(executableId: ExecutableId, concreteValues: Collection<FuzzedConcreteValue> = emptyList()) : this(
executableId.classId.simpleName + "." + executableId.name,
executableId.returnType,
executableId.parameters,
concreteValues
)
}