From 5f14d4e46a6034febf070557455dd1929cb16e42 Mon Sep 17 00:00:00 2001 From: DaniilStepanov Date: Tue, 6 Dec 2022 16:31:30 +0300 Subject: [PATCH] Mutator refactorings --- .../engine/greyboxfuzzer/mutator/Mutator.kt | 59 ------------------- 1 file changed, 59 deletions(-) diff --git a/utbot-framework/src/main/kotlin/org/utbot/engine/greyboxfuzzer/mutator/Mutator.kt b/utbot-framework/src/main/kotlin/org/utbot/engine/greyboxfuzzer/mutator/Mutator.kt index 7f890cc3c2..ad30363051 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/engine/greyboxfuzzer/mutator/Mutator.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/engine/greyboxfuzzer/mutator/Mutator.kt @@ -142,15 +142,6 @@ object Mutator { ): FParameter { val originalParameter = fParameter.parameter val originalUtModel = fParameter.utModel -// if (Random.getTrue(100)) { -// return regenerateRandomParameter(fParameter) -// } -// val randomMethod = initialInstance.classId.allMethods -// .filter { !it.name.startsWith("get") && !it.name.startsWith("to")} -// .filter { it.classId.name != "java.lang.Object" } -// .filter { it.parameters.all { !it.name.startsWith("java.util.function") } } -// .toList() -// .randomOrNull() ?: return null val randomMethod = fParameter.classId.allMethods.toList().randomOrNull() ?: return fParameter val parametersForMethodInvocation = randomMethod.method.parameters.mapIndexed { index, parameter -> @@ -171,54 +162,4 @@ object Mutator { (originalUtModel as? UtAssembleModel)?.addModification(listOf(callModel)) return FParameter(originalParameter, null, fParameter.utModel, fParameter.generator, fParameter.fields) } - - -// private fun mutateInput(oldData: Any, sourceOfRandomness: SourceOfRandomness): Any { -// val castedData = oldData as LongArray -// print("BEFORE = ") -// castedData.forEach { print("$it ") } -// println() -// // Clone this input to create initial version of new child -// //val newInput = LinearInput(this) -// val bos = ByteArrayOutputStream(); -// val oos = ObjectOutputStream(bos); -// oos.writeObject(oldData); -// oos.flush(); -// val data = bos.toByteArray() -// val random = java.util.Random()//sourceOfRandomness.toJDKRandom() -// -// // Stack a bunch of mutations -// val numMutations = 3//ZestGuidance.Input.sampleGeometric(random, MEAN_MUTATION_COUNT) -// println("mutations = $numMutations") -// //newInput.desc += ",havoc:$numMutations" -// val setToZero = random.nextDouble() < 0.1 // one out of 10 times -// for (mutation in 1..numMutations) { -// -// // Select a random offset and size -// val offset = random.nextInt(data.size) -// val mutationSize = ZestGuidance.Input.sampleGeometric(random, MEAN_MUTATION_SIZE) -// -// // desc += String.format(":%d@%d", mutationSize, idx); -// -// // Mutate a contiguous set of bytes from offset -// for (i in offset until offset + mutationSize) { -// // Don't go past end of list -// if (i >= data.size) { -// break -// } -// -// // Otherwise, apply a random mutation -// val mutatedValue = if (setToZero) 0 else random.nextInt(256) -// data[i] = mutatedValue.toByte() -// } -// } -// val `in` = ByteArrayInputStream(data) -// val `is` = ObjectInputStream(`in`) -// val afterMutationData = `is`.readObject() as LongArray -// print("AFTER = ") -// afterMutationData.forEach { print("$it ") } -// println() -// return data -// } - } \ No newline at end of file