Skip to content

Commit

Permalink
Mutator refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniilStepanov committed Dec 6, 2022
1 parent 98ee577 commit 5f14d4e
Showing 1 changed file with 0 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand All @@ -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
// }

}

0 comments on commit 5f14d4e

Please sign in to comment.