Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf759f20

Browse files
committed
Fix summarization display name
1 parentaa239b8 commitf759f20

File tree

5 files changed

+89
-25
lines changed

5 files changed

+89
-25
lines changed

‎utbot-fuzzers/src/main/kotlin/org/utbot/fuzzing/JavaLanguage.kt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ suspend fun runJavaFuzzing(
6262
).apply {
6363
compilableName=if (!methodUnderTest.isConstructor) methodUnderTest.nameelsenull
6464
className= classUnderTest.simpleName
65+
canonicalName= classUnderTest.canonicalName
66+
isNested= classUnderTest.isNested
6567
packageName= classUnderTest.packageName
6668
parameterNameMap= { index->
6769
when {

‎utbot-fuzzers/src/main/kotlin/org/utbot/fuzzing/providers/Primitives.kt‎

Lines changed: 68 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import org.utbot.framework.plugin.api.ClassId
44
importorg.utbot.framework.plugin.api.UtPrimitiveModel
55
importorg.utbot.framework.plugin.api.util.*
66
importorg.utbot.fuzzer.FuzzedContext
7+
importorg.utbot.fuzzer.FuzzedContext.Comparison.*
78
importorg.utbot.fuzzer.FuzzedType
89
importorg.utbot.fuzzer.FuzzedValue
910
importorg.utbot.fuzzer.providers.ConstantsModelProvider.fuzzed
10-
importorg.utbot.fuzzing.FuzzedDescription
11-
importorg.utbot.fuzzing.Seed
12-
importorg.utbot.fuzzing.ValueProvider
11+
importorg.utbot.fuzzing.*
1312
importorg.utbot.fuzzing.seeds.*
1413
importjava.util.regex.Pattern
1514
importjava.util.regex.PatternSyntaxException
@@ -24,27 +23,70 @@ abstract class PrimitiveValueProvider(
2423

2524
protectedsuspendfun <T:KnownValue>SequenceScope<Seed<FuzzedType,FuzzedValue>>.yieldKnown(
2625
value:T,
27-
description:String = value.toString(),
2826
toValue:T.()->Any
2927
) {
3028
yield(Seed.Known(value) { known->
3129
UtPrimitiveModel(toValue(known)).fuzzed {
3230
summary= buildString {
33-
append("%var% =")
31+
append("%var% =${known.valueToString()}")
3432
if (known.mutatedFrom!=null) {
35-
append("mutated from")
33+
append(" (mutated from${known.mutatedFrom?.valueToString()})")
3634
}
37-
append(description)
3835
}
3936
}
4037
})
4138
}
39+
40+
privatefun <T:KnownValue> T.valueToString():String {
41+
when (this) {
42+
isBitVectorValue-> {
43+
for (defaultBoundinSigned.values()) {
44+
if (defaultBound.test(this)) {
45+
return defaultBound.name.lowercase()
46+
}
47+
}
48+
returnwhen (size) {
49+
8-> toByte().toString()
50+
16-> toShort().toString()
51+
32-> toInt().toString()
52+
64-> toLong().toString()
53+
else-> toString(10)
54+
}
55+
}
56+
isIEEE754Value-> {
57+
for (defaultBoundinDefaultFloatBound.values()) {
58+
if (defaultBound.test(this)) {
59+
return defaultBound.name.lowercase().replace("_","")
60+
}
61+
}
62+
returnwhen {
63+
is32Float()-> toFloat().toString()
64+
is64Float()-> toDouble().toString()
65+
else-> toString()
66+
}
67+
}
68+
isStringValue-> {
69+
return"'${value.substringToLength(10,"...")}'"
70+
}
71+
isRegexValue-> {
72+
return"'${value.substringToLength(10,"...")}' from$pattern"
73+
}
74+
else->return toString()
75+
}
76+
}
77+
78+
privatefun String.substringToLength(size:Int,postfix:String):String {
79+
returnwhen {
80+
length<= size->this
81+
else-> substring(0, size)+ postfix
82+
}
83+
}
4284
}
4385

4486
object BooleanValueProvider : PrimitiveValueProvider(booleanClassId, booleanWrapperClassId) {
4587
overridefungenerate(description:FuzzedDescription,type:FuzzedType)= sequence {
46-
yieldKnown(Bool.TRUE(), description="true") { toBoolean() }
47-
yieldKnown(Bool.FALSE(), description="false") { toBoolean() }
88+
yieldKnown(Bool.TRUE()) { toBoolean() }
89+
yieldKnown(Bool.FALSE()) { toBoolean() }
4890
}
4991
}
5092

@@ -80,6 +122,15 @@ object IntegerValueProvider : PrimitiveValueProvider(
80122

81123
privatefun ClassId.cast(value:BitVectorValue):Any= tryCast(value)!!
82124

125+
privateval randomStubWithNoUsage=Random(0)
126+
privateval configurationStubWithNoUsage=Configuration()
127+
128+
privatefun BitVectorValue.change(func:BitVectorValue.()->Unit):BitVectorValue {
129+
returnMutation<KnownValue> { _, _, _->
130+
BitVectorValue(this).apply { func() }
131+
}.mutate(this, randomStubWithNoUsage, configurationStubWithNoUsage)asBitVectorValue
132+
}
133+
83134
overridefungenerate(
84135
description:FuzzedDescription,
85136
type:FuzzedType
@@ -90,14 +141,14 @@ object IntegerValueProvider : PrimitiveValueProvider(
90141
val values= listOfNotNull(
91142
value,
92143
when (c) {
93-
FuzzedContext.Comparison.EQ,FuzzedContext.Comparison.NE,FuzzedContext.Comparison.LE,FuzzedContext.Comparison.GT->BitVectorValue(value).apply { inc() }
94-
FuzzedContext.Comparison.LT,FuzzedContext.Comparison.GE->BitVectorValue(value).apply { dec() }
144+
EQ,NE,LE,GT-> value.change { inc() }
145+
LT,GE-> value.change { dec() }
95146
else->null
96147
}
97148
)
98149
values.forEach {
99150
if (type.classId.tryCast(it)!=null) {
100-
yieldKnown(it, description="$it") {
151+
yieldKnown(it) {
101152
type.classId.cast(this)
102153
}
103154
}
@@ -109,7 +160,7 @@ object IntegerValueProvider : PrimitiveValueProvider(
109160
val s= type.classId.typeSize
110161
val value= bound(s)
111162
if (type.classId.tryCast(value)!=null) {
112-
yieldKnown(value, description= bound.name.lowercase().replace("_","")) {
163+
yieldKnown(value) {
113164
type.classId.cast(this)
114165
}
115166
}
@@ -143,12 +194,12 @@ object FloatValueProvider : PrimitiveValueProvider(
143194
)= sequence {
144195
description.constants.forEach { (t, v, _)->
145196
if (tin acceptableTypes) {
146-
yieldKnown(IEEE754Value.fromValue(v), description="$v") { type.classId.cast(this) }
197+
yieldKnown(IEEE754Value.fromValue(v)) { type.classId.cast(this) }
147198
}
148199
}
149200
DefaultFloatBound.values().forEach { bound->
150201
val (m, e)= type.classId.typeSize
151-
yieldKnown(bound(m ,e), description= bound.name.lowercase().replace("_","")) {
202+
yieldKnown(bound(m ,e)) {
152203
type.classId.cast(this)
153204
}
154205
}
@@ -165,7 +216,7 @@ object StringValueProvider : PrimitiveValueProvider(stringClassId) {
165216
val values= constants
166217
.mapNotNull { it.valueas?String }+
167218
sequenceOf("","abc","\n\t\r")
168-
values.forEach { yieldKnown(StringValue(it), description="predefined string") { value } }
219+
values.forEach { yieldKnown(StringValue(it)) { value } }
169220
constants
170221
.filter { it.fuzzedContext.isPatterMatchingContext() }
171222
.map { it.valueasString }
@@ -178,7 +229,7 @@ object StringValueProvider : PrimitiveValueProvider(stringClassId) {
178229
false
179230
}
180231
}.forEach {
181-
yieldKnown(RegexValue(it,Random(0)), description="regex($it)") { value }
232+
yieldKnown(RegexValue(it,Random(0))) { value }
182233
}
183234
}
184235

‎utbot-fuzzing/src/main/kotlin/org/utbot/fuzzing/seeds/BitVectorValue.kt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ enum class Signed : Bound {
232232
;
233233

234234
operatorfuninvoke(size:Int)=BitVectorValue(size,this)
235+
236+
funtest(value:BitVectorValue)= (0..value.size).all { value[it]== initializer(it, value.size) }
235237
}
236238

237239
enumclassUnsigned :Bound {

‎utbot-fuzzing/src/main/kotlin/org/utbot/fuzzing/seeds/IEEE754Value.kt‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ class IEEE754Value : KnownValue {
112112
return result*if (isPositive)1.0else-1.0
113113
}
114114

115+
funis32Float():Boolean {
116+
return vector.size==32&& mantissaSize==23&& exponentSize==8
117+
}
118+
119+
funis64Float():Boolean {
120+
return vector.size==64&& mantissaSize==52&& exponentSize==11
121+
}
122+
115123
overridefuntoString()= buildString {
116124
for (iin0 until vector.size) {
117125
if (i==1|| i==1+ exponentSize) append("")

‎utbot-fuzzing/src/main/kotlin/org/utbot/fuzzing/utils/Functions.kt‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,12 @@ internal fun <T> List<T>.transformIfNotEmpty(transform: List<T>.() -> List<T>):
8585
returnif (isNotEmpty()) transform()elsethis
8686
}
8787

88-
funmain() {
89-
val endian=Endian.BE
90-
println(255.toUByte().toBinaryString(endian))
91-
println(2.toBinaryString(endian))
92-
println(BitVectorValue.fromInt(2).toBinaryString(endian))
93-
print(8.75f.toBinaryString(endian))
94-
print(8.75.toBinaryString(endian))
95-
}
88+
// todo move to tests
89+
//fun main() {
90+
// val endian = Endian.BE
91+
// println(255.toUByte().toBinaryString(endian))
92+
// println(2.toBinaryString(endian))
93+
// println(BitVectorValue.fromInt(2).toBinaryString(endian))
94+
// print(8.75f.toBinaryString(endian))
95+
// print(8.75.toBinaryString(endian))
96+
//}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp