Add mutator for next nodes
This commit is contained in:
parent
acc9ba5a6f
commit
ec7e6c1d5f
4 changed files with 36 additions and 2 deletions
|
@ -72,6 +72,7 @@ require 'mutant/mutator/node/dsym'
|
|||
require 'mutant/mutator/node/named_value/access'
|
||||
require 'mutant/mutator/node/named_value/constant_assignment'
|
||||
require 'mutant/mutator/node/named_value/variable_assignment'
|
||||
require 'mutant/mutator/node/next'
|
||||
require 'mutant/mutator/node/noop'
|
||||
require 'mutant/mutator/node/op_asgn'
|
||||
require 'mutant/mutator/node/while'
|
||||
|
|
|
@ -10,7 +10,7 @@ module Mutant
|
|||
# These nodes still need a dedicated mutator,
|
||||
# your contribution is that close!
|
||||
handle(
|
||||
:next, :ensure,
|
||||
:ensure,
|
||||
:rescue, :redo, :defined?,
|
||||
:regopt, :resbody, :retry, :arg_expr,
|
||||
:kwrestarg, :kwoptarg, :kwarg, :undef, :module, :empty,
|
||||
|
|
30
lib/mutant/mutator/node/next.rb
Normal file
30
lib/mutant/mutator/node/next.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
# encoding: utf-8
|
||||
|
||||
module Mutant
|
||||
class Mutator
|
||||
class Node
|
||||
|
||||
# Next mutator
|
||||
class Next < Generic
|
||||
|
||||
handle(:next)
|
||||
|
||||
private
|
||||
|
||||
# Emit mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
super
|
||||
children.each_index(&method(:delete_child))
|
||||
emit(s(:break, *children))
|
||||
emit_nil
|
||||
end
|
||||
|
||||
end # Next
|
||||
end # Node
|
||||
end # Mutator
|
||||
end # Mutant
|
|
@ -2,13 +2,16 @@
|
|||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Mutator::Node::Generic, 'next' do
|
||||
describe Mutant::Mutator::Node::Next, 'next' do
|
||||
let(:source) { 'next true' }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'next false'
|
||||
mutations << 'next nil'
|
||||
mutations << 'next'
|
||||
mutations << 'nil'
|
||||
mutations << 'break true'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
|
Loading…
Add table
Reference in a new issue