Fix neutral/vs noop mutation naming
This commit is contained in:
parent
0bebec4871
commit
473aeace90
5 changed files with 30 additions and 46 deletions
|
@ -12,7 +12,7 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def mutations
|
||||
mutations = []
|
||||
mutations = [neutral_mutation]
|
||||
generate_mutations(mutations)
|
||||
mutations
|
||||
end
|
||||
|
@ -142,8 +142,8 @@ module Mutant
|
|||
#
|
||||
# @api private
|
||||
#
|
||||
def noop_mutation
|
||||
Mutation::Neutral::Noop.new(self, node)
|
||||
def neutral_mutation
|
||||
Mutation::Neutral.new(self, node)
|
||||
end
|
||||
|
||||
# Generate mutations
|
||||
|
@ -154,7 +154,11 @@ module Mutant
|
|||
#
|
||||
# @api private
|
||||
#
|
||||
abstract_method :generate_mutations
|
||||
def generate_mutations(emitter)
|
||||
Mutator.each(node) do |mutant|
|
||||
emitter << Mutation::Evil.new(self, mutant)
|
||||
end
|
||||
end
|
||||
|
||||
end # Subject
|
||||
end # Mutant
|
||||
|
|
|
@ -34,21 +34,6 @@ module Mutant
|
|||
|
||||
private
|
||||
|
||||
# Return mutations
|
||||
#
|
||||
# @param [#<<] emitter
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def generate_mutations(emitter)
|
||||
emitter << noop_mutation
|
||||
Mutator.each(node) do |mutant|
|
||||
emitter << Mutation::Evil.new(self, mutant)
|
||||
end
|
||||
end
|
||||
|
||||
# Return scope
|
||||
#
|
||||
# @return [Class, Module]
|
||||
|
|
|
@ -75,7 +75,7 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def generate_mutations(emitter)
|
||||
emitter << noop_mutation
|
||||
emitter << neutral_mutation
|
||||
Mutator.each(node) do |mutant|
|
||||
emitter << Mutation::Evil.new(self, memoizer_node(mutant))
|
||||
end
|
||||
|
@ -87,8 +87,8 @@ module Mutant
|
|||
#
|
||||
# @api private
|
||||
#
|
||||
def noop_mutation
|
||||
Mutation::Neutral::Noop.new(self, memoizer_node(node))
|
||||
def neutral_mutation
|
||||
Mutation::Neutral.new(self, memoizer_node(node))
|
||||
end
|
||||
|
||||
# Return memoizer node for mutant
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Subject, '#mutations' do
|
||||
subject { object.mutations }
|
||||
|
||||
let(:class_under_test) do
|
||||
mutation_a, mutation_b = self.mutation_a, self.mutation_b
|
||||
Class.new(described_class) do
|
||||
define_method(:generate_mutations) do |emitter|
|
||||
emitter << mutation_a
|
||||
emitter << mutation_b
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
let(:object) { class_under_test.new(config, context, node) }
|
||||
let(:config) { Mutant::Config::DEFAULT }
|
||||
let(:node) { double('Node') }
|
||||
let(:context) { double('Context') }
|
||||
let(:mutation_a) { double('Mutation A') }
|
||||
let(:mutation_b) { double('Mutation B') }
|
||||
|
||||
it { should eql([mutation_a, mutation_b]) }
|
||||
end
|
|
@ -46,4 +46,23 @@ describe Mutant::Subject do
|
|||
|
||||
it_should_behave_like 'an idempotent method'
|
||||
end
|
||||
|
||||
describe '#mutations' do
|
||||
subject { object.mutations }
|
||||
|
||||
before do
|
||||
expect(Mutant::Mutator).to receive(:each).with(node).and_yield(mutation_a).and_yield(mutation_b)
|
||||
end
|
||||
|
||||
let(:mutation_a) { double('Mutation A') }
|
||||
let(:mutation_b) { double('Mutation B') }
|
||||
|
||||
it 'generates neutral and evil mutations' do
|
||||
should eql([
|
||||
Mutant::Mutation::Neutral.new(object, node),
|
||||
Mutant::Mutation::Evil.new(object, mutation_a),
|
||||
Mutant::Mutation::Evil.new(object, mutation_b)
|
||||
])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue