Class: Exercism::Processors::IterMutationProcessor
- Inherits:
-
Processor
- Object
- Processor
- Exercism::Processors::IterMutationProcessor
show all
- Defined in:
- lib/exercism-analysis/processors/iter_mutation_processor.rb
Defined Under Namespace
Classes: Mutation, Mutator
Constant Summary
collapse
- SIDE_EFFECTS =
%w(<< push)
Instance Method Summary
collapse
Methods inherited from Processor
#find_exp, #find_exps
Constructor Details
Returns a new instance of IterMutationProcessor.
11
12
13
|
# File 'lib/exercism-analysis/processors/iter_mutation_processor.rb', line 11
def initialize
@mutations = []
end
|
Instance Method Details
#process_def(exp) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/exercism-analysis/processors/iter_mutation_processor.rb', line 15
def process_def(exp)
assignment = find_exp(exp, :assign) {|e| e.body.type == :array }
call_to_each = find_exp(exp, :call) {|e| e.block }
if assignment && call_to_each
if mutating_exps = find_mutations_in_block(assignment, call_to_each)
mutators = mutating_exps.map do |exp|
Mutator.new(exp, condition_surrounding_mutation(exp, call_to_each.block))
end
mutation = Mutation.new(call_to_each, assignment, mutators)
@mutations << mutation
end
end
end
|
#result ⇒ Object
29
30
31
|
# File 'lib/exercism-analysis/processors/iter_mutation_processor.rb', line 29
def result
@mutations
end
|