Change emit_nil to not emit on the left node of an assignment
* Add emit_nil to other nodes so that they can be replaced with nil, effectively removing them from the code.
This commit is contained in:
parent
58e6910573
commit
475512146f
28 changed files with 129 additions and 18 deletions
|
@ -181,7 +181,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def emit_nil
|
def emit_nil
|
||||||
emit(N_NIL)
|
emit(N_NIL) unless agsn_left?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return new self typed child
|
# Return new self typed child
|
||||||
|
@ -222,6 +222,17 @@ module Mutant
|
||||||
parent && parent.node.type
|
parent && parent.node.type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Test if the node is the left of an or_asgn or op_asgn
|
||||||
|
#
|
||||||
|
# @return [Boolean]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
def agsn_left?
|
||||||
|
[:or_asgn, :op_asgn, :and_asgn].include?(parent_type) &&
|
||||||
|
parent.left.equal?(node)
|
||||||
|
end
|
||||||
|
|
||||||
end # Node
|
end # Node
|
||||||
end # Mutator
|
end # Mutator
|
||||||
end # Mutant
|
end # Mutant
|
||||||
|
|
|
@ -26,6 +26,7 @@ module Mutant
|
||||||
end
|
end
|
||||||
emit_body(nil)
|
emit_body(nil)
|
||||||
emit_body(RAISE)
|
emit_body(RAISE)
|
||||||
|
emit_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end # Block
|
end # Block
|
||||||
|
|
|
@ -23,6 +23,7 @@ module Mutant
|
||||||
emit_condition_mutations
|
emit_condition_mutations
|
||||||
emit_when_mutations
|
emit_when_mutations
|
||||||
emit_else_mutations
|
emit_else_mutations
|
||||||
|
emit_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Emit when mutations
|
# Emit when mutations
|
||||||
|
|
|
@ -9,6 +9,19 @@ module Mutant
|
||||||
|
|
||||||
handle(:dstr)
|
handle(:dstr)
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# Emit mutations
|
||||||
|
#
|
||||||
|
# @return [undefined]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
def dispatch
|
||||||
|
super
|
||||||
|
emit_nil
|
||||||
|
end
|
||||||
|
|
||||||
end # Dstr
|
end # Dstr
|
||||||
end # Node
|
end # Node
|
||||||
end # Mutator
|
end # Mutator
|
||||||
|
|
|
@ -22,6 +22,7 @@ module Mutant
|
||||||
mutate_condition
|
mutate_condition
|
||||||
mutate_if_branch
|
mutate_if_branch
|
||||||
mutate_else_branch
|
mutate_else_branch
|
||||||
|
emit_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Emit conditon mutations
|
# Emit conditon mutations
|
||||||
|
|
|
@ -20,7 +20,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def dispatch
|
def dispatch
|
||||||
# noop, for now
|
emit_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end # MultipleAssignment
|
end # MultipleAssignment
|
||||||
|
|
|
@ -30,6 +30,7 @@ module Mutant
|
||||||
def dispatch
|
def dispatch
|
||||||
mutate_name
|
mutate_name
|
||||||
emit_value_mutations if value # mlhs!
|
emit_value_mutations if value # mlhs!
|
||||||
|
emit_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Emit name mutations
|
# Emit name mutations
|
||||||
|
|
|
@ -22,9 +22,8 @@ module Mutant
|
||||||
if value
|
if value
|
||||||
emit(value)
|
emit(value)
|
||||||
emit_value_mutations
|
emit_value_mutations
|
||||||
else
|
|
||||||
emit_nil
|
|
||||||
end
|
end
|
||||||
|
emit_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end # Return
|
end # Return
|
||||||
|
|
|
@ -71,6 +71,7 @@ module Mutant
|
||||||
else
|
else
|
||||||
non_index_dispatch
|
non_index_dispatch
|
||||||
end
|
end
|
||||||
|
emit_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Perform non index dispatch
|
# Perform non index dispatch
|
||||||
|
|
|
@ -27,6 +27,7 @@ module Mutant
|
||||||
mutate_child(index)
|
mutate_child(index)
|
||||||
delete_child(index)
|
delete_child(index)
|
||||||
end
|
end
|
||||||
|
emit_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end # Super
|
end # Super
|
||||||
|
|
|
@ -23,6 +23,7 @@ module Mutant
|
||||||
emit_condition_mutations
|
emit_condition_mutations
|
||||||
emit_body_mutations
|
emit_body_mutations
|
||||||
emit_body(nil)
|
emit_body(nil)
|
||||||
|
emit_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end # While
|
end # While
|
||||||
|
|
|
@ -12,7 +12,10 @@ describe Mutant::Mutator, 'block' do
|
||||||
mutations << 'foo { b }'
|
mutations << 'foo { b }'
|
||||||
mutations << 'foo {}'
|
mutations << 'foo {}'
|
||||||
mutations << 'foo { raise }'
|
mutations << 'foo { raise }'
|
||||||
|
mutations << 'foo { a; nil }'
|
||||||
|
mutations << 'foo { nil; b }'
|
||||||
mutations << 'foo'
|
mutations << 'foo'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -35,6 +38,7 @@ describe Mutant::Mutator, 'block' do
|
||||||
mutations << 'foo { |a| }'
|
mutations << 'foo { |a| }'
|
||||||
mutations << 'foo { |b| }'
|
mutations << 'foo { |b| }'
|
||||||
mutations << 'foo { || }'
|
mutations << 'foo { || }'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -61,6 +65,7 @@ describe Mutant::Mutator, 'block' do
|
||||||
mutations << 'foo { |(a, srandom), c| }'
|
mutations << 'foo { |(a, srandom), c| }'
|
||||||
mutations << 'foo { |(a, b), srandom| }'
|
mutations << 'foo { |(a, b), srandom| }'
|
||||||
mutations << 'foo'
|
mutations << 'foo'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
|
|
@ -8,6 +8,7 @@ describe Mutant::Mutator::Node::NamedValue::Access, 'block_pass' do
|
||||||
let(:mutations) do
|
let(:mutations) do
|
||||||
mutants = []
|
mutants = []
|
||||||
mutants << 'foo'
|
mutants << 'foo'
|
||||||
|
mutants << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
|
|
@ -217,6 +217,8 @@ describe Mutant::Mutator::Node::Case do
|
||||||
:else
|
:else
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
|
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -314,6 +316,8 @@ describe Mutant::Mutator::Node::Case do
|
||||||
:else
|
:else
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
|
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
|
|
@ -3,8 +3,12 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Mutant::Mutator::Node::Generic, 'defined?' do
|
describe Mutant::Mutator::Node::Generic, 'defined?' do
|
||||||
let(:source) { 'defined?(foo)' }
|
let(:source) { 'defined?(foo)' }
|
||||||
let(:mutations) { [] }
|
|
||||||
|
let(:mutations) do
|
||||||
|
mutations = []
|
||||||
|
mutations << 'defined?(nil)'
|
||||||
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,6 +15,8 @@ describe Mutant::Mutator::Node::Dstr, 'dstr' do
|
||||||
mutations << '"#{nil}#{bar}baz"'
|
mutations << '"#{nil}#{bar}baz"'
|
||||||
mutations << '"foo#{bar}random"'
|
mutations << '"foo#{bar}random"'
|
||||||
mutations << '"foo#{bar}#{nil}"'
|
mutations << '"foo#{bar}#{nil}"'
|
||||||
|
mutations << '"foo#{nil}baz"'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
|
|
@ -15,6 +15,7 @@ describe Mutant::Mutator::Node::Generic, 'dsum' do
|
||||||
mutations << ':"#{nil}#{bar}baz"'
|
mutations << ':"#{nil}#{bar}baz"'
|
||||||
mutations << ':"foo#{bar}random"'
|
mutations << ':"foo#{bar}random"'
|
||||||
mutations << ':"foo#{bar}#{nil}"'
|
mutations << ':"foo#{bar}#{nil}"'
|
||||||
|
mutations << ':"foo#{nil}baz"'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
|
|
@ -36,6 +36,8 @@ describe Mutant::Mutator, 'if' do
|
||||||
# mutations of else body
|
# mutations of else body
|
||||||
mutants << 'if :condition; true; else true; end'
|
mutants << 'if :condition; true; else true; end'
|
||||||
mutants << 'if :condition; true; else nil; end'
|
mutants << 'if :condition; true; else nil; end'
|
||||||
|
|
||||||
|
mutants << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -51,6 +53,8 @@ describe Mutant::Mutator, 'if' do
|
||||||
mutants << 'if condition; nil; end'
|
mutants << 'if condition; nil; end'
|
||||||
mutants << 'if true; true; end'
|
mutants << 'if true; true; end'
|
||||||
mutants << 'if false; true; end'
|
mutants << 'if false; true; end'
|
||||||
|
mutants << 'if nil; true; end'
|
||||||
|
mutants << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -69,6 +73,7 @@ describe Mutant::Mutator, 'if' do
|
||||||
mutants << 'unless true; true; end'
|
mutants << 'unless true; true; end'
|
||||||
mutants << 'unless false; true; end'
|
mutants << 'unless false; true; end'
|
||||||
mutants << 'if :condition; true; end'
|
mutants << 'if :condition; true; end'
|
||||||
|
mutants << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
|
|
@ -9,9 +9,9 @@ describe Mutant::Mutator::Node::Literal, 'regex' do
|
||||||
|
|
||||||
let(:mutations) do
|
let(:mutations) do
|
||||||
mutations = []
|
mutations = []
|
||||||
mutations << 'nil'
|
|
||||||
mutations << '//' # match all
|
mutations << '//' # match all
|
||||||
mutations << '/a\A/' # match nothing
|
mutations << '/a\A/' # match nothing
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -22,10 +22,12 @@ describe Mutant::Mutator::Node::Literal, 'regex' do
|
||||||
|
|
||||||
let(:mutations) do
|
let(:mutations) do
|
||||||
mutations = []
|
mutations = []
|
||||||
mutations << 'nil'
|
|
||||||
mutations << '//' # match all
|
mutations << '//' # match all
|
||||||
mutations << '/#{foo}n/' # match all
|
mutations << '/#{foo}n/' # match all
|
||||||
mutations << '/a\A/' # match nothing
|
mutations << '/a\A/' # match nothing
|
||||||
|
mutations << '/#{nil.bar}n/'
|
||||||
|
mutations << '/#{nil}n/'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
|
|
@ -3,8 +3,12 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Mutant::Mutator, 'masgn' do
|
describe Mutant::Mutator, 'masgn' do
|
||||||
let(:source) { 'a, b = c, d' }
|
let(:source) { 'a, b = c, d' }
|
||||||
let(:mutations) { [] }
|
|
||||||
|
let(:mutations) do
|
||||||
|
mutations = []
|
||||||
|
mutations << 'nil'
|
||||||
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,6 +14,7 @@ describe Mutant::Mutator::Node::Generic, 'match_current_line' do
|
||||||
mutations << 'true if nil'
|
mutations << 'true if nil'
|
||||||
mutations << 'true if !//'
|
mutations << 'true if !//'
|
||||||
mutations << 'true if /a\A/'
|
mutations << 'true if /a\A/'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
|
|
@ -17,6 +17,7 @@ describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
|
||||||
mutants << '$a'
|
mutants << '$a'
|
||||||
mutants << '$a = ::Object.new; $a'
|
mutants << '$a = ::Object.new; $a'
|
||||||
mutants << '$srandom = nil; $a'
|
mutants << '$srandom = nil; $a'
|
||||||
|
mutants << 'nil; $a'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -32,6 +33,7 @@ describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
|
||||||
mutants << '@@a'
|
mutants << '@@a'
|
||||||
mutants << '@@a = ::Object.new; @@a'
|
mutants << '@@a = ::Object.new; @@a'
|
||||||
mutants << '@@srandom = nil; @@a'
|
mutants << '@@srandom = nil; @@a'
|
||||||
|
mutants << 'nil; @@a'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,6 +47,7 @@ describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
|
||||||
mutants << '@a'
|
mutants << '@a'
|
||||||
mutants << '@a = ::Object.new; @a'
|
mutants << '@a = ::Object.new; @a'
|
||||||
mutants << '@srandom = nil; @a'
|
mutants << '@srandom = nil; @a'
|
||||||
|
mutants << 'nil; @a'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -60,6 +63,7 @@ describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
|
||||||
mutants << 'a'
|
mutants << 'a'
|
||||||
mutants << 'a = ::Object.new; a'
|
mutants << 'a = ::Object.new; a'
|
||||||
mutants << 'srandom = nil; a'
|
mutants << 'srandom = nil; a'
|
||||||
|
mutants << 'nil; a'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
|
|
@ -15,6 +15,7 @@ describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
|
||||||
mutations << '$srandom = true'
|
mutations << '$srandom = true'
|
||||||
mutations << '$a = false'
|
mutations << '$a = false'
|
||||||
mutations << '$a = nil'
|
mutations << '$a = nil'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -25,10 +26,10 @@ describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
|
||||||
|
|
||||||
let(:mutations) do
|
let(:mutations) do
|
||||||
mutations = []
|
mutations = []
|
||||||
|
|
||||||
mutations << '@@srandom = true'
|
mutations << '@@srandom = true'
|
||||||
mutations << '@@a = false'
|
mutations << '@@a = false'
|
||||||
mutations << '@@a = nil'
|
mutations << '@@a = nil'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -39,10 +40,10 @@ describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
|
||||||
|
|
||||||
let(:mutations) do
|
let(:mutations) do
|
||||||
mutations = []
|
mutations = []
|
||||||
|
|
||||||
mutations << '@srandom = true'
|
mutations << '@srandom = true'
|
||||||
mutations << '@a = false'
|
mutations << '@a = false'
|
||||||
mutations << '@a = nil'
|
mutations << '@a = nil'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -53,10 +54,10 @@ describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
|
||||||
|
|
||||||
let(:mutations) do
|
let(:mutations) do
|
||||||
mutations = []
|
mutations = []
|
||||||
|
|
||||||
mutations << 'srandom = true'
|
mutations << 'srandom = true'
|
||||||
mutations << 'a = false'
|
mutations << 'a = false'
|
||||||
mutations << 'a = nil'
|
mutations << 'a = nil'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
|
|
@ -10,6 +10,8 @@ describe Mutant::Mutator::Node::Generic, 'restarg' do
|
||||||
mutants << 'foo'
|
mutants << 'foo'
|
||||||
mutants << 'foo(nil)'
|
mutants << 'foo(nil)'
|
||||||
mutants << 'foo(bar)'
|
mutants << 'foo(bar)'
|
||||||
|
mutants << 'foo(*nil)'
|
||||||
|
mutants << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
|
|
@ -7,18 +7,22 @@ describe Mutant::Mutator, 'return' do
|
||||||
context 'return without value' do
|
context 'return without value' do
|
||||||
let(:source) { 'return' }
|
let(:source) { 'return' }
|
||||||
|
|
||||||
let(:mutations) { ['nil'] }
|
let(:mutations) do
|
||||||
|
mutations = []
|
||||||
|
mutations << 'nil'
|
||||||
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'return with value' do
|
context 'return with value' do
|
||||||
let(:source) { 'return nil' }
|
let(:source) { 'return foo' }
|
||||||
|
|
||||||
let(:mutations) do
|
let(:mutations) do
|
||||||
mutations = []
|
mutations = []
|
||||||
|
mutations << 'foo'
|
||||||
|
mutations << 'return nil'
|
||||||
mutations << 'nil'
|
mutations << 'nil'
|
||||||
mutations << 'return ::Object.new'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
|
|
@ -15,6 +15,10 @@ describe Mutant::Mutator, 'send' do
|
||||||
mutations << 'foo.gsub(b)'
|
mutations << 'foo.gsub(b)'
|
||||||
mutations << 'foo.gsub'
|
mutations << 'foo.gsub'
|
||||||
mutations << 'foo.sub(a, b)'
|
mutations << 'foo.sub(a, b)'
|
||||||
|
mutations << 'foo.gsub(a, nil)'
|
||||||
|
mutations << 'foo.gsub(nil, b)'
|
||||||
|
mutations << 'nil.gsub(a, b)'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -29,6 +33,9 @@ describe Mutant::Mutator, 'send' do
|
||||||
mutations << 'foo.public_send(bar)'
|
mutations << 'foo.public_send(bar)'
|
||||||
mutations << 'bar'
|
mutations << 'bar'
|
||||||
mutations << 'foo'
|
mutations << 'foo'
|
||||||
|
mutations << 'foo.send(nil)'
|
||||||
|
mutations << 'nil.send(bar)'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -40,6 +47,7 @@ describe Mutant::Mutator, 'send' do
|
||||||
let(:mutations) do
|
let(:mutations) do
|
||||||
mutations = []
|
mutations = []
|
||||||
mutations << 'foo ||= expression'
|
mutations << 'foo ||= expression'
|
||||||
|
mutations << 'self.foo ||= nil'
|
||||||
mutations << 'nil.foo ||= expression'
|
mutations << 'nil.foo ||= expression'
|
||||||
mutations << 'nil'
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
@ -53,6 +61,7 @@ describe Mutant::Mutator, 'send' do
|
||||||
let(:mutations) do
|
let(:mutations) do
|
||||||
mutations = []
|
mutations = []
|
||||||
mutations << 'foo'
|
mutations << 'foo'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -66,6 +75,8 @@ describe Mutant::Mutator, 'send' do
|
||||||
mutations << 'foo'
|
mutations << 'foo'
|
||||||
mutations << 'foo(nil)'
|
mutations << 'foo(nil)'
|
||||||
mutations << 'foo(bar)'
|
mutations << 'foo(bar)'
|
||||||
|
mutations << 'foo(*nil)'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -77,6 +88,7 @@ describe Mutant::Mutator, 'send' do
|
||||||
let(:mutations) do
|
let(:mutations) do
|
||||||
mutations = []
|
mutations = []
|
||||||
mutations << 'foo'
|
mutations << 'foo'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -88,6 +100,7 @@ describe Mutant::Mutator, 'send' do
|
||||||
let(:mutations) do
|
let(:mutations) do
|
||||||
mutations = []
|
mutations = []
|
||||||
mutations << 'foo'
|
mutations << 'foo'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -97,7 +110,12 @@ describe Mutant::Mutator, 'send' do
|
||||||
context 'implicit' do
|
context 'implicit' do
|
||||||
let(:source) { 'foo' }
|
let(:source) { 'foo' }
|
||||||
|
|
||||||
it_should_behave_like 'a noop mutator'
|
let(:mutations) do
|
||||||
|
mutations = []
|
||||||
|
mutations << 'nil'
|
||||||
|
end
|
||||||
|
|
||||||
|
it_should_behave_like 'a mutator'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'explict receiver' do
|
context 'explict receiver' do
|
||||||
|
@ -108,6 +126,7 @@ describe Mutant::Mutator, 'send' do
|
||||||
mutations << 'foo'
|
mutations << 'foo'
|
||||||
mutations << 'self'
|
mutations << 'self'
|
||||||
mutations << 'nil.foo'
|
mutations << 'nil.foo'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -133,6 +152,8 @@ describe Mutant::Mutator, 'send' do
|
||||||
let(:mutations) do
|
let(:mutations) do
|
||||||
mutations = []
|
mutations = []
|
||||||
mutations << 'foo'
|
mutations << 'foo'
|
||||||
|
mutations << 'nil.bar'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -146,6 +167,8 @@ describe Mutant::Mutator, 'send' do
|
||||||
mutations << 'self.class'
|
mutations << 'self.class'
|
||||||
mutations << 'self.foo'
|
mutations << 'self.foo'
|
||||||
mutations << 'nil.class.foo'
|
mutations << 'nil.class.foo'
|
||||||
|
mutations << 'nil.foo'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -192,8 +215,9 @@ describe Mutant::Mutator, 'send' do
|
||||||
mutations = []
|
mutations = []
|
||||||
mutations << "foo.#{keyword}"
|
mutations << "foo.#{keyword}"
|
||||||
mutations << 'foo'
|
mutations << 'foo'
|
||||||
mutations << 'nil'
|
|
||||||
mutations << "foo.#{keyword}(::Object.new)"
|
mutations << "foo.#{keyword}(::Object.new)"
|
||||||
|
mutations << "nil.#{keyword}(nil)"
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -210,6 +234,7 @@ describe Mutant::Mutator, 'send' do
|
||||||
mutations << 'foo(nil)'
|
mutations << 'foo(nil)'
|
||||||
mutations << 'foo(::Object.new, nil)'
|
mutations << 'foo(::Object.new, nil)'
|
||||||
mutations << 'foo(nil, ::Object.new)'
|
mutations << 'foo(nil, ::Object.new)'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -225,6 +250,11 @@ describe Mutant::Mutator, 'send' do
|
||||||
mutations << '(left - right)'
|
mutations << '(left - right)'
|
||||||
mutations << 'left / foo'
|
mutations << 'left / foo'
|
||||||
mutations << 'right / foo'
|
mutations << 'right / foo'
|
||||||
|
mutations << '(left - right) / nil'
|
||||||
|
mutations << '(left - nil) / foo'
|
||||||
|
mutations << '(nil - right) / foo'
|
||||||
|
mutations << 'nil / foo'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -242,6 +272,7 @@ describe Mutant::Mutator, 'send' do
|
||||||
mutations << "true #{operator} nil"
|
mutations << "true #{operator} nil"
|
||||||
mutations << 'true'
|
mutations << 'true'
|
||||||
mutations << 'false'
|
mutations << 'false'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -253,6 +284,9 @@ describe Mutant::Mutator, 'send' do
|
||||||
mutations = []
|
mutations = []
|
||||||
mutations << 'left'
|
mutations << 'left'
|
||||||
mutations << 'right'
|
mutations << 'right'
|
||||||
|
mutations << "left #{operator} nil"
|
||||||
|
mutations << "nil #{operator} right"
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
|
|
@ -21,6 +21,7 @@ describe Mutant::Mutator, 'super' do
|
||||||
let(:mutations) do
|
let(:mutations) do
|
||||||
mutations = []
|
mutations = []
|
||||||
mutations << 'super'
|
mutations << 'super'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
@ -35,6 +36,9 @@ describe Mutant::Mutator, 'super' do
|
||||||
mutations << 'super()'
|
mutations << 'super()'
|
||||||
mutations << 'super(foo)'
|
mutations << 'super(foo)'
|
||||||
mutations << 'super(bar)'
|
mutations << 'super(bar)'
|
||||||
|
mutations << 'super(foo, nil)'
|
||||||
|
mutations << 'super(nil, bar)'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
|
|
@ -14,6 +14,9 @@ describe Mutant::Mutator::Node::While do
|
||||||
mutations << 'while true; end'
|
mutations << 'while true; end'
|
||||||
mutations << 'while false; foo; bar; end'
|
mutations << 'while false; foo; bar; end'
|
||||||
mutations << 'while nil; foo; bar; end'
|
mutations << 'while nil; foo; bar; end'
|
||||||
|
mutations << 'while true; foo; nil; end'
|
||||||
|
mutations << 'while true; nil; bar; end'
|
||||||
|
mutations << 'nil'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'a mutator'
|
it_should_behave_like 'a mutator'
|
||||||
|
|
Loading…
Add table
Reference in a new issue