diff --git a/lib/mutant.rb b/lib/mutant.rb index 33e02110..c4388c0e 100644 --- a/lib/mutant.rb +++ b/lib/mutant.rb @@ -74,6 +74,7 @@ require 'mutant/mutator/node/named_value/variable_assignment' require 'mutant/mutator/node/noop' require 'mutant/mutator/node/op_asgn' require 'mutant/mutator/node/while' +require 'mutant/mutator/node/yield' require 'mutant/mutator/node/super' require 'mutant/mutator/node/zsuper' require 'mutant/mutator/node/restarg' diff --git a/lib/mutant/mutator/node/generic.rb b/lib/mutant/mutator/node/generic.rb index b8c9c26c..4119f76e 100644 --- a/lib/mutant/mutator/node/generic.rb +++ b/lib/mutant/mutator/node/generic.rb @@ -11,7 +11,7 @@ module Mutant # your contribution is that close! handle( :next, :break, :ensure, - :yield, :rescue, :redo, :defined?, + :rescue, :redo, :defined?, :regopt, :resbody, :retry, :arg_expr, :kwrestarg, :kwoptarg, :kwarg, :undef, :module, :empty, :alias, :for, :xstr, :back_ref, :class, diff --git a/lib/mutant/mutator/node/yield.rb b/lib/mutant/mutator/node/yield.rb new file mode 100644 index 00000000..87f6b925 --- /dev/null +++ b/lib/mutant/mutator/node/yield.rb @@ -0,0 +1,29 @@ +# encoding: utf-8 + +module Mutant + class Mutator + class Node + + # Yield mutator + class Yield < Generic + + handle(:yield) + + private + + # Emit mutations + # + # @return [undefined] + # + # @api private + # + def dispatch + super + children.each_index(&method(:delete_child)) + emit_nil + end + + end # Yield + end # Node + end # Mutator +end # Mutant diff --git a/spec/unit/mutant/mutator/node/yield/mutation_spec.rb b/spec/unit/mutant/mutator/node/yield/mutation_spec.rb index 47f096a6..0046b607 100644 --- a/spec/unit/mutant/mutator/node/yield/mutation_spec.rb +++ b/spec/unit/mutant/mutator/node/yield/mutation_spec.rb @@ -9,6 +9,8 @@ describe Mutant::Mutator::Node::Generic, 'yield' do mutations = [] mutations << 'yield false' mutations << 'yield nil' + mutations << 'yield' + mutations << 'nil' end it_should_behave_like 'a mutator'