Add spec to ensure all nodes are handled

This commit is contained in:
Markus Schirp 2013-06-21 18:10:06 +02:00
parent 288724436a
commit 2813c081dc
3 changed files with 21 additions and 7 deletions

View file

@ -55,8 +55,7 @@ module Mutant
:return, :splat, :not, :defined?, :op_asgn, :self,
:true, :false, :nil, :dstr, :dsym, :regexp,
:regopt, :int, :str, :float, :sym, :pair, :hash, :array,
:xstr, :dyn_str_body, :dyn_regexp_body, :dyn_xstr_body,
:def, :defs, :case, :when, :ivar, :lvar, :cvar, :gvar,
:xstr, :def, :defs, :case, :when, :ivar, :lvar, :cvar, :gvar,
:back_ref, :const, :nth_ref, :class, :sclass, :yield,
:match_with_lvasgn, :match_current_line, :irange, :erange
].to_set.freeze

View file

@ -5,12 +5,18 @@ module Mutant
class Noop < self
# Literal references to self do not need to be mutated?
handle(:self)
# These nodes still need a mutator, your contribution is that close!
handle(
:self, :zsuper, :not, :or, :and, :defined,
:next, :break, :match, :gvar, :cvar, :ensure, :rescue,
:dstr, :dsym, :yield, :begin, :rescue, :gvasgn,
:lvar, :splat, :const, :blockarg, :block_pass,
:ivar, :restarg
:zsuper, :not, :or, :and, :defined,
:next, :break, :match, :gvar, :cvar, :ensure,
:dstr, :dsym, :yield, :rescue, :redo, :defined?,
:lvar, :splat, :const, :blockarg, :block_pass, :op_asgn, :regopt,
:ivar, :restarg, :casgn, :masgn, :resbody, :retry, :arg_expr,
:kwrestarg, :kwoptarg, :kwarg, :undef, :module, :cbase, :empty,
:alias, :for, :xstr, :back_ref, :nth_ref, :class, :sclass, :match_with_lvasgn,
:match_current_line
)
private

View file

@ -0,0 +1,9 @@
require 'spec_helper'
describe Mutant do
specify 'mutant should not crash for any node parser can generate' do
Mutant::NODE_TYPES.each do |type|
Mutant::Mutator::Node::Registry.lookup(Mutant::NodeHelpers.s(type))
end
end
end