Add mutator for yield nodes
This commit is contained in:
parent
ad56db3943
commit
b41283d84c
4 changed files with 33 additions and 1 deletions
|
@ -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'
|
||||
|
|
|
@ -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,
|
||||
|
|
29
lib/mutant/mutator/node/yield.rb
Normal file
29
lib/mutant/mutator/node/yield.rb
Normal 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
|
|
@ -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'
|
||||
|
|
Loading…
Reference in a new issue