Add mutator for kwbegin nodes

This commit is contained in:
Dan Kubb 2013-11-03 20:51:55 -08:00
parent ec7e6c1d5f
commit 749b2b2474
5 changed files with 48 additions and 2 deletions

View file

@ -69,6 +69,7 @@ require 'mutant/mutator/node/connective/binary'
require 'mutant/mutator/node/const'
require 'mutant/mutator/node/dstr'
require 'mutant/mutator/node/dsym'
require 'mutant/mutator/node/kwbegin'
require 'mutant/mutator/node/named_value/access'
require 'mutant/mutator/node/named_value/constant_assignment'
require 'mutant/mutator/node/named_value/variable_assignment'

View file

@ -15,7 +15,7 @@ module Mutant
:regopt, :resbody, :retry, :arg_expr,
:kwrestarg, :kwoptarg, :kwarg, :undef, :module, :empty,
:alias, :for, :xstr, :back_ref, :class,
:sclass, :match_with_lvasgn, :match_current_line, :kwbegin
:sclass, :match_with_lvasgn, :match_current_line
)
private

View file

@ -0,0 +1,28 @@
# encoding: utf-8
module Mutant
class Mutator
class Node
# Kwbegin mutator
class Kwbegin < Generic
handle(:kwbegin)
private
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
super
emit_nil
end
end # Kwbegin
end # Node
end # Mutator
end # Mutant

View file

@ -3,12 +3,13 @@
require 'spec_helper'
describe Mutant::Mutator::Node::Generic, 'ensure' do
let(:source) { 'begin; rescue; ensure; true; end' }
let(:source) { 'begin; rescue; ensure; true; end' }
let(:mutations) do
mutations = []
mutations << 'begin; rescue; ensure; false; end'
mutations << 'begin; rescue; ensure; nil; end'
mutations << 'nil'
end
it_should_behave_like 'a mutator'

View file

@ -0,0 +1,16 @@
# encoding: utf-8
require 'spec_helper'
describe Mutant::Mutator::Node::Kwbegin, 'kwbegin' do
let(:source) { 'begin; true; end' }
let(:mutations) do
mutations = []
mutations << 'begin; false; end'
mutations << 'begin; nil; end'
mutations << 'nil'
end
it_should_behave_like 'a mutator'
end