Add explicit mutator for op_asgn

This commit is contained in:
Dan Kubb 2013-09-07 23:03:25 -07:00
parent 1d567f65f1
commit f714f8215f
4 changed files with 34 additions and 2 deletions

View file

@ -69,6 +69,7 @@ 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/noop'
require 'mutant/mutator/node/op_asgn'
require 'mutant/mutator/node/while'
require 'mutant/mutator/node/super'
require 'mutant/mutator/node/zsuper'

View file

@ -12,7 +12,7 @@ module Mutant
handle(
:next, :break, :ensure,
:dsym, :yield, :rescue, :redo, :defined?,
:blockarg, :op_asgn, :and_asgn,
:blockarg, :and_asgn,
:regopt, :restarg, :resbody, :retry, :arg_expr,
:kwrestarg, :kwoptarg, :kwarg, :undef, :module, :empty,
:alias, :for, :xstr, :back_ref, :class,

View file

@ -0,0 +1,30 @@
# encoding: utf-8
module Mutant
class Mutator
class Node
# OpAsgn mutator
class OpAsgn < Generic
handle(:op_asgn)
children :left, :right
private
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
super
emit_nil
end
end # OpAsgn
end # Node
end # Mutator
end # Mutant

View file

@ -5,7 +5,7 @@ require 'spec_helper'
describe Mutant::Mutator::Node::Generic, 'op_asgn' do
let(:random_fixnum) { 5 }
let(:source) { '@a.b += 1' }
let(:source) { '@a.b += 1' }
let(:mutations) do
mutations = []
@ -16,6 +16,7 @@ describe Mutant::Mutator::Node::Generic, 'op_asgn' do
mutations << '@a += 1'
mutations << '@a.b += 5'
mutations << 'nil.b += 1'
mutations << 'nil'
end
before do