Add mutator for yield nodes

This commit is contained in:
Dan Kubb 2013-11-03 12:37:47 -08:00
parent ad56db3943
commit b41283d84c
4 changed files with 33 additions and 1 deletions

View file

@ -74,6 +74,7 @@ require 'mutant/mutator/node/named_value/variable_assignment'
require 'mutant/mutator/node/noop' require 'mutant/mutator/node/noop'
require 'mutant/mutator/node/op_asgn' require 'mutant/mutator/node/op_asgn'
require 'mutant/mutator/node/while' require 'mutant/mutator/node/while'
require 'mutant/mutator/node/yield'
require 'mutant/mutator/node/super' require 'mutant/mutator/node/super'
require 'mutant/mutator/node/zsuper' require 'mutant/mutator/node/zsuper'
require 'mutant/mutator/node/restarg' require 'mutant/mutator/node/restarg'

View file

@ -11,7 +11,7 @@ module Mutant
# your contribution is that close! # your contribution is that close!
handle( handle(
:next, :break, :ensure, :next, :break, :ensure,
:yield, :rescue, :redo, :defined?, :rescue, :redo, :defined?,
:regopt, :resbody, :retry, :arg_expr, :regopt, :resbody, :retry, :arg_expr,
:kwrestarg, :kwoptarg, :kwarg, :undef, :module, :empty, :kwrestarg, :kwoptarg, :kwarg, :undef, :module, :empty,
:alias, :for, :xstr, :back_ref, :class, :alias, :for, :xstr, :back_ref, :class,

View file

@ -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

View file

@ -9,6 +9,8 @@ describe Mutant::Mutator::Node::Generic, 'yield' do
mutations = [] mutations = []
mutations << 'yield false' mutations << 'yield false'
mutations << 'yield nil' mutations << 'yield nil'
mutations << 'yield'
mutations << 'nil'
end end
it_should_behave_like 'a mutator' it_should_behave_like 'a mutator'