Do not emit name mutation for underscored optional arguments
Closes #98
This commit is contained in:
parent
2bb5d92eca
commit
a0a7eb3885
2 changed files with 16 additions and 1 deletions
|
@ -21,7 +21,6 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
return if skip?
|
||||
emit_name_mutation
|
||||
end
|
||||
|
||||
|
@ -32,6 +31,7 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def emit_name_mutation
|
||||
return if skip?
|
||||
Mutator::Util::Symbol.each(name, self) do |name|
|
||||
emit_name(name)
|
||||
end
|
||||
|
|
|
@ -79,6 +79,21 @@ describe Mutant::Mutator, 'def' do
|
|||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
||||
context 'with optional argument beginning in an underscore' do
|
||||
let(:source) { 'def foo(_unused = true); end' }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'def foo(_unused = nil); end'
|
||||
mutations << 'def foo(_unused = false); end'
|
||||
mutations << 'def foo(_unused = true); raise; end'
|
||||
mutations << 'def foo(_unused); end'
|
||||
mutations << 'def foo; end'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
||||
context 'default argument' do
|
||||
let(:source) { 'def foo(a = true); end' }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue