Port super mutator to parser
This commit is contained in:
parent
8993fbf02a
commit
c230ca74b9
2 changed files with 9 additions and 49 deletions
|
@ -7,6 +7,9 @@ module Mutant
|
|||
|
||||
handle(:super)
|
||||
|
||||
Z_SUPER = NodeHelpers.s(:zsuper)
|
||||
EMPTY_SUPER = NodeHelpers.s(:super)
|
||||
|
||||
private
|
||||
|
||||
# Emit mutations
|
||||
|
@ -16,22 +19,12 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_node(:zsuper)
|
||||
emit_without_block
|
||||
emit_attribute_mutations(:block) if node.block
|
||||
emit_attribute_mutations(:arguments)
|
||||
end
|
||||
|
||||
# Emit without block mutation
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_without_block
|
||||
dup = dup_node
|
||||
dup.block = nil
|
||||
emit(dup)
|
||||
emit(Z_SUPER)
|
||||
emit(EMPTY_SUPER)
|
||||
children.each_index do |index|
|
||||
mutate_child(index)
|
||||
delete_child(index)
|
||||
end
|
||||
end
|
||||
|
||||
end # Super
|
||||
|
|
|
@ -19,21 +19,6 @@ describe Mutant::Mutator, 'super' do
|
|||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
||||
context 'with explicit empty arguments and block' do
|
||||
let(:source) { 'super() { foo; bar }' }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'super() { foo }'
|
||||
mutations << 'super() { bar }'
|
||||
mutations << 'super() { }'
|
||||
mutations << 'super()'
|
||||
mutations << 'super'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
||||
context 'super with arguments' do
|
||||
let(:source) { 'super(foo, bar)' }
|
||||
|
||||
|
@ -47,22 +32,4 @@ describe Mutant::Mutator, 'super' do
|
|||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
||||
context 'super with arguments and block' do
|
||||
let(:source) { 'super(foo, bar) { foo; bar }' }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'super(foo, bar) { foo; }'
|
||||
mutations << 'super(foo, bar) { bar; }'
|
||||
mutations << 'super(foo, bar) { nil }'
|
||||
mutations << 'super(foo, bar)'
|
||||
mutations << 'super'
|
||||
mutations << 'super(foo) { foo; bar }'
|
||||
mutations << 'super(bar) { foo; bar }'
|
||||
mutations << 'super() { foo; bar }'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue