diff --git a/lib/mutant/mutator/node/argument.rb b/lib/mutant/mutator/node/argument.rb index caf787d2..ef3ac35a 100644 --- a/lib/mutant/mutator/node/argument.rb +++ b/lib/mutant/mutator/node/argument.rb @@ -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 diff --git a/spec/unit/mutant/mutator/node/define/mutation_spec.rb b/spec/unit/mutant/mutator/node/define/mutation_spec.rb index 2720e3c0..37806d34 100644 --- a/spec/unit/mutant/mutator/node/define/mutation_spec.rb +++ b/spec/unit/mutant/mutator/node/define/mutation_spec.rb @@ -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' }