Fix constant mutation to not emit nil::Const anymnore

* Add proper mutations to constant names
This commit is contained in:
Dan Kubb 2013-08-07 11:12:22 -07:00
parent 323411b8ee
commit 523807b9cb
3 changed files with 6 additions and 3 deletions

View file

@ -18,7 +18,8 @@ module Mutant
# @api private
#
def dispatch
emit_nil
emit_nil unless parent_type == :const
emit_self(nil, *children.drop(1))
children.each_with_index do |child, index|
mutate_child(index) if child.kind_of?(Parser::AST::Node)
end

View file

@ -8,6 +8,7 @@ describe Mutant::Mutator::Node::Noop, 'cbase' do
let(:mutations) do
mutants = []
mutants << 'nil'
mutants << 'A'
end
it_should_behave_like 'a mutator'

View file

@ -3,12 +3,13 @@
require 'spec_helper'
describe Mutant::Mutator::Node::Const, 'const' do
let(:source) { 'A::B' }
let(:source) { 'A::B::C' }
let(:mutations) do
mutants = []
mutants << 'nil'
mutants << 'nil::B'
mutants << 'B::C'
mutants << 'C'
end
it_should_behave_like 'a mutator'