def list_operators(): print('Standard mutation operators:') for operator in utils.sort_operators(operators.standard_operators): print(' - {:3} - {}'.format(operator.name(), operator.long_name())) print('Experimental mutation operators:') for operator in utils.sort_operators(operators.experimental_operators): print(' - {:3} - {}'.format(operator.name(), operator.long_name()))
def generate_all_mutations(self, coverage_injector, module, target_ast, to_mutate): mutations = [] for op in utils.sort_operators(self.operators): for mutation, _ in op().mutate(target_ast, to_mutate, None, coverage_injector, module, None, self.type_check): mutations.append(mutation) return mutations
def test_sort_operators(self): class A(operators.MutationOperator): pass class Z(operators.MutationOperator): pass sorted_operators = utils.sort_operators([Z, A]) self.assertEqual(sorted_operators[0], A) self.assertEqual(sorted_operators[1], Z)
def mutate(self, target_ast, to_mutate=None, coverage_injector=None, module=None): for op in utils.sort_operators(self.operators): for mutation, mutant in op().mutate(target_ast, to_mutate, self.sampler, coverage_injector, module=module): yield [mutation], mutant
def mutate(self, target_ast, to_mutate=None, coverage_injector=None, module=None): annotationsMarker = annotations.get_annotation_marker(self.type_check) annotationsMarker.mark_ast_tree(target_ast) for op in utils.sort_operators(self.operators): for mutation, mutant in op().mutate(target_ast, to_mutate, self.sampler, coverage_injector, module, None, self.type_check): yield [mutation], mutant
def generate_all_mutations(self, coverage_injector, module, target_ast, to_mutate): mutations = [] for op in utils.sort_operators(self.operators): for mutation, _ in op().mutate(target_ast, to_mutate, None, coverage_injector, module=module): mutations.append(mutation) return mutations