Merge branch 'master' into restarg-mutator
Conflicts: lib/mutant/mutator/node/generic.rb
This commit is contained in:
commit
48d0bfb55e
39 changed files with 193 additions and 50 deletions
|
@ -1,3 +1,3 @@
|
|||
---
|
||||
threshold: 16
|
||||
total_score: 762
|
||||
threshold: 18
|
||||
total_score: 752
|
||||
|
|
|
@ -64,10 +64,12 @@ require 'mutant/mutator/node/arguments'
|
|||
require 'mutant/mutator/node/begin'
|
||||
require 'mutant/mutator/node/connective/binary'
|
||||
require 'mutant/mutator/node/const'
|
||||
require 'mutant/mutator/node/dstr'
|
||||
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'
|
||||
|
|
|
@ -15,7 +15,7 @@ module Mutant
|
|||
|
||||
# Set of op assign types
|
||||
OP_ASSIGN = [
|
||||
:or_asgn, :and_asgn
|
||||
:or_asgn, :and_asgn, :op_asgn
|
||||
].to_set.freeze
|
||||
|
||||
# Set of node types that are not valid when emitted standalone
|
||||
|
@ -64,6 +64,7 @@ module Mutant
|
|||
OPERATOR_METHODS =
|
||||
OPERATOR_EXPANSIONS.keys + INDEX_OPERATORS + UNARY_METHOD_OPERATORS
|
||||
|
||||
|
||||
# Hopefully all types parser does generate
|
||||
NODE_TYPES = [
|
||||
:lvasgn, :ivasgn, :cvasgn, :gvasgn,
|
||||
|
|
|
@ -10,7 +10,7 @@ module Mutant
|
|||
# if block given
|
||||
#
|
||||
# @return [Enumerator<Subject>]
|
||||
# oherwise
|
||||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
|
@ -19,12 +19,12 @@ module Mutant
|
|||
|
||||
matcher.each do |subject|
|
||||
next if filter.match?(subject)
|
||||
yield matcher
|
||||
yield subject
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
end # Filter
|
||||
end
|
||||
end # Matcher
|
||||
end # Mutant
|
||||
|
|
|
@ -181,7 +181,7 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def emit_nil
|
||||
emit(N_NIL)
|
||||
emit(N_NIL) unless agsn_left?
|
||||
end
|
||||
|
||||
# Return new self typed child
|
||||
|
@ -222,6 +222,16 @@ module Mutant
|
|||
parent && parent.node.type
|
||||
end
|
||||
|
||||
# Test if the node is the left of an or_asgn or op_asgn
|
||||
#
|
||||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def agsn_left?
|
||||
OP_ASSIGN.include?(parent_type) && parent.left.equal?(node)
|
||||
end
|
||||
|
||||
end # Node
|
||||
end # Mutator
|
||||
end # Mutant
|
||||
|
|
|
@ -26,6 +26,7 @@ module Mutant
|
|||
end
|
||||
emit_body(nil)
|
||||
emit_body(RAISE)
|
||||
emit_nil
|
||||
end
|
||||
|
||||
end # Block
|
||||
|
|
|
@ -23,6 +23,7 @@ module Mutant
|
|||
emit_condition_mutations
|
||||
emit_when_mutations
|
||||
emit_else_mutations
|
||||
emit_nil
|
||||
end
|
||||
|
||||
# Emit when mutations
|
||||
|
|
28
lib/mutant/mutator/node/dstr.rb
Normal file
28
lib/mutant/mutator/node/dstr.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
# encoding: utf-8
|
||||
|
||||
module Mutant
|
||||
class Mutator
|
||||
class Node
|
||||
|
||||
# Dstr mutator
|
||||
class Dstr < Generic
|
||||
|
||||
handle(:dstr)
|
||||
|
||||
private
|
||||
|
||||
# Emit mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
super
|
||||
emit_nil
|
||||
end
|
||||
|
||||
end # Dstr
|
||||
end # Node
|
||||
end # Mutator
|
||||
end # Mutant
|
|
@ -11,12 +11,12 @@ module Mutant
|
|||
# your contribution is that close!
|
||||
handle(
|
||||
:next, :break, :ensure,
|
||||
:dstr, :dsym, :yield, :rescue, :redo, :defined?,
|
||||
:blockarg, :op_asgn, :and_asgn,
|
||||
:dsym, :yield, :rescue, :redo, :defined?,
|
||||
:blockarg,
|
||||
:regopt, :resbody, :retry, :arg_expr,
|
||||
:kwrestarg, :kwoptarg, :kwarg, :undef, :module, :empty,
|
||||
:alias, :for, :xstr, :back_ref, :class,
|
||||
:sclass, :match_with_lvasgn, :match_current_line, :or_asgn, :kwbegin
|
||||
:sclass, :match_with_lvasgn, :match_current_line, :kwbegin
|
||||
)
|
||||
|
||||
private
|
||||
|
|
|
@ -22,6 +22,7 @@ module Mutant
|
|||
mutate_condition
|
||||
mutate_if_branch
|
||||
mutate_else_branch
|
||||
emit_nil
|
||||
end
|
||||
|
||||
# Emit conditon mutations
|
||||
|
|
|
@ -6,23 +6,6 @@ module Mutant
|
|||
# Abstract mutator for literal AST nodes
|
||||
class Literal < self
|
||||
include AbstractType
|
||||
|
||||
private
|
||||
|
||||
# Emit a new node with wrapping class for each entry in values
|
||||
#
|
||||
# @param [Array] values
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_values(values)
|
||||
values.each do |value|
|
||||
emit_self(value)
|
||||
end
|
||||
end
|
||||
|
||||
end # Literal
|
||||
end # Node
|
||||
end # Mutator
|
||||
|
|
|
@ -20,7 +20,7 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
# noop, for now
|
||||
emit_nil
|
||||
end
|
||||
|
||||
end # MultipleAssignment
|
||||
|
|
|
@ -30,6 +30,7 @@ module Mutant
|
|||
def dispatch
|
||||
mutate_name
|
||||
emit_value_mutations if value # mlhs!
|
||||
emit_nil
|
||||
end
|
||||
|
||||
# Emit name mutations
|
||||
|
|
30
lib/mutant/mutator/node/op_asgn.rb
Normal file
30
lib/mutant/mutator/node/op_asgn.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
# encoding: utf-8
|
||||
|
||||
module Mutant
|
||||
class Mutator
|
||||
class Node
|
||||
|
||||
# OpAsgn mutator
|
||||
class OpAsgn < Generic
|
||||
|
||||
handle(:op_asgn, :or_asgn, :and_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
|
|
@ -22,9 +22,8 @@ module Mutant
|
|||
if value
|
||||
emit(value)
|
||||
emit_value_mutations
|
||||
else
|
||||
emit_nil
|
||||
end
|
||||
emit_nil
|
||||
end
|
||||
|
||||
end # Return
|
||||
|
|
|
@ -71,6 +71,7 @@ module Mutant
|
|||
else
|
||||
non_index_dispatch
|
||||
end
|
||||
emit_nil
|
||||
end
|
||||
|
||||
# Perform non index dispatch
|
||||
|
|
|
@ -27,6 +27,7 @@ module Mutant
|
|||
mutate_child(index)
|
||||
delete_child(index)
|
||||
end
|
||||
emit_nil
|
||||
end
|
||||
|
||||
end # Super
|
||||
|
|
|
@ -23,6 +23,7 @@ module Mutant
|
|||
emit_condition_mutations
|
||||
emit_body_mutations
|
||||
emit_body(nil)
|
||||
emit_nil
|
||||
end
|
||||
|
||||
end # While
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Mutator::Node::Generic, 'and_asgn' do
|
||||
describe Mutant::Mutator::Node::OpAsgn, 'and_asgn' do
|
||||
let(:random_fixnum) { 5 }
|
||||
let(:random_string) { 'random' }
|
||||
|
||||
|
@ -16,6 +16,7 @@ describe Mutant::Mutator::Node::Generic, 'and_asgn' do
|
|||
mutations << 'a &&= -1'
|
||||
mutations << 'a &&= 2'
|
||||
mutations << 'a &&= 5'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
before do
|
||||
|
|
|
@ -12,7 +12,10 @@ describe Mutant::Mutator, 'block' do
|
|||
mutations << 'foo { b }'
|
||||
mutations << 'foo {}'
|
||||
mutations << 'foo { raise }'
|
||||
mutations << 'foo { a; nil }'
|
||||
mutations << 'foo { nil; b }'
|
||||
mutations << 'foo'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -35,6 +38,7 @@ describe Mutant::Mutator, 'block' do
|
|||
mutations << 'foo { |a| }'
|
||||
mutations << 'foo { |b| }'
|
||||
mutations << 'foo { || }'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -61,6 +65,7 @@ describe Mutant::Mutator, 'block' do
|
|||
mutations << 'foo { |(a, srandom), c| }'
|
||||
mutations << 'foo { |(a, b), srandom| }'
|
||||
mutations << 'foo'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
|
|
@ -8,6 +8,7 @@ describe Mutant::Mutator::Node::NamedValue::Access, 'block_pass' do
|
|||
let(:mutations) do
|
||||
mutants = []
|
||||
mutants << 'foo'
|
||||
mutants << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
|
|
@ -217,6 +217,8 @@ describe Mutant::Mutator::Node::Case do
|
|||
:else
|
||||
end
|
||||
RUBY
|
||||
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -314,6 +316,8 @@ describe Mutant::Mutator::Node::Case do
|
|||
:else
|
||||
end
|
||||
RUBY
|
||||
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
|
|
@ -3,8 +3,12 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Mutator::Node::Generic, 'defined?' do
|
||||
let(:source) { 'defined?(foo)' }
|
||||
let(:mutations) { [] }
|
||||
let(:source) { 'defined?(foo)' }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'defined?(nil)'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Mutator::Node::Generic, 'dstr' do
|
||||
describe Mutant::Mutator::Node::Dstr, 'dstr' do
|
||||
before do
|
||||
Mutant::Random.stub(:hex_string => 'random')
|
||||
end
|
||||
|
@ -15,6 +15,8 @@ describe Mutant::Mutator::Node::Generic, 'dstr' do
|
|||
mutations << '"#{nil}#{bar}baz"'
|
||||
mutations << '"foo#{bar}random"'
|
||||
mutations << '"foo#{bar}#{nil}"'
|
||||
mutations << '"foo#{nil}baz"'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
|
|
@ -15,6 +15,7 @@ describe Mutant::Mutator::Node::Generic, 'dsum' do
|
|||
mutations << ':"#{nil}#{bar}baz"'
|
||||
mutations << ':"foo#{bar}random"'
|
||||
mutations << ':"foo#{bar}#{nil}"'
|
||||
mutations << ':"foo#{nil}baz"'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
|
|
@ -36,6 +36,8 @@ describe Mutant::Mutator, 'if' do
|
|||
# mutations of else body
|
||||
mutants << 'if :condition; true; else true; end'
|
||||
mutants << 'if :condition; true; else nil; end'
|
||||
|
||||
mutants << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -51,6 +53,8 @@ describe Mutant::Mutator, 'if' do
|
|||
mutants << 'if condition; nil; end'
|
||||
mutants << 'if true; true; end'
|
||||
mutants << 'if false; true; end'
|
||||
mutants << 'if nil; true; end'
|
||||
mutants << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -69,6 +73,7 @@ describe Mutant::Mutator, 'if' do
|
|||
mutants << 'unless true; true; end'
|
||||
mutants << 'unless false; true; end'
|
||||
mutants << 'if :condition; true; end'
|
||||
mutants << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
|
|
@ -9,9 +9,9 @@ describe Mutant::Mutator::Node::Literal, 'regex' do
|
|||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'nil'
|
||||
mutations << '//' # match all
|
||||
mutations << '/a\A/' # match nothing
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -22,10 +22,12 @@ describe Mutant::Mutator::Node::Literal, 'regex' do
|
|||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'nil'
|
||||
mutations << '//' # match all
|
||||
mutations << '/#{foo}n/' # match all
|
||||
mutations << '/a\A/' # match nothing
|
||||
mutations << '/#{nil.bar}n/'
|
||||
mutations << '/#{nil}n/'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
|
|
@ -3,8 +3,12 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Mutator, 'masgn' do
|
||||
let(:source) { 'a, b = c, d' }
|
||||
let(:mutations) { [] }
|
||||
let(:source) { 'a, b = c, d' }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
|
|
@ -14,6 +14,7 @@ describe Mutant::Mutator::Node::Generic, 'match_current_line' do
|
|||
mutations << 'true if nil'
|
||||
mutations << 'true if !//'
|
||||
mutations << 'true if /a\A/'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
|
|
@ -17,6 +17,7 @@ describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
|
|||
mutants << '$a'
|
||||
mutants << '$a = ::Object.new; $a'
|
||||
mutants << '$srandom = nil; $a'
|
||||
mutants << 'nil; $a'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -32,6 +33,7 @@ describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
|
|||
mutants << '@@a'
|
||||
mutants << '@@a = ::Object.new; @@a'
|
||||
mutants << '@@srandom = nil; @@a'
|
||||
mutants << 'nil; @@a'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -45,6 +47,7 @@ describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
|
|||
mutants << '@a'
|
||||
mutants << '@a = ::Object.new; @a'
|
||||
mutants << '@srandom = nil; @a'
|
||||
mutants << 'nil; @a'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -60,6 +63,7 @@ describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
|
|||
mutants << 'a'
|
||||
mutants << 'a = ::Object.new; a'
|
||||
mutants << 'srandom = nil; a'
|
||||
mutants << 'nil; a'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
|
|
@ -11,7 +11,6 @@ describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
|
|||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
|
||||
mutations << 'SRANDOM = true'
|
||||
mutations << 'A = false'
|
||||
mutations << 'A = nil'
|
||||
|
|
|
@ -12,10 +12,10 @@ describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
|
|||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
|
||||
mutations << '$srandom = true'
|
||||
mutations << '$a = false'
|
||||
mutations << '$a = nil'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -26,10 +26,10 @@ describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
|
|||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
|
||||
mutations << '@@srandom = true'
|
||||
mutations << '@@a = false'
|
||||
mutations << '@@a = nil'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -40,10 +40,10 @@ describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
|
|||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
|
||||
mutations << '@srandom = true'
|
||||
mutations << '@a = false'
|
||||
mutations << '@a = nil'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -54,10 +54,10 @@ describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
|
|||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
|
||||
mutations << 'srandom = true'
|
||||
mutations << 'a = false'
|
||||
mutations << 'a = nil'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Mutator::Node::Generic, 'or_asgn' do
|
||||
describe Mutant::Mutator::Node::OpAsgn, 'or_asgn' do
|
||||
let(:random_fixnum) { 5 }
|
||||
let(:random_string) { 'random' }
|
||||
|
||||
|
@ -16,6 +16,7 @@ describe Mutant::Mutator::Node::Generic, 'or_asgn' do
|
|||
mutations << 'a ||= -1'
|
||||
mutations << 'a ||= 2'
|
||||
mutations << 'a ||= 5'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
before do
|
||||
|
|
|
@ -10,6 +10,8 @@ describe Mutant::Mutator::Node::Restarg, 'restarg' do
|
|||
mutants << 'foo'
|
||||
mutants << 'foo(nil)'
|
||||
mutants << 'foo(bar)'
|
||||
mutants << 'foo(*nil)'
|
||||
mutants << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
|
|
@ -7,18 +7,22 @@ describe Mutant::Mutator, 'return' do
|
|||
context 'return without value' do
|
||||
let(:source) { 'return' }
|
||||
|
||||
let(:mutations) { ['nil'] }
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
||||
context 'return with value' do
|
||||
let(:source) { 'return nil' }
|
||||
let(:source) { 'return foo' }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'foo'
|
||||
mutations << 'return nil'
|
||||
mutations << 'nil'
|
||||
mutations << 'return ::Object.new'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
|
|
@ -15,6 +15,10 @@ describe Mutant::Mutator, 'send' do
|
|||
mutations << 'foo.gsub(b)'
|
||||
mutations << 'foo.gsub'
|
||||
mutations << 'foo.sub(a, b)'
|
||||
mutations << 'foo.gsub(a, nil)'
|
||||
mutations << 'foo.gsub(nil, b)'
|
||||
mutations << 'nil.gsub(a, b)'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -29,6 +33,9 @@ describe Mutant::Mutator, 'send' do
|
|||
mutations << 'foo.public_send(bar)'
|
||||
mutations << 'bar'
|
||||
mutations << 'foo'
|
||||
mutations << 'foo.send(nil)'
|
||||
mutations << 'nil.send(bar)'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -40,7 +47,9 @@ describe Mutant::Mutator, 'send' do
|
|||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'foo ||= expression'
|
||||
mutations << 'self.foo ||= nil'
|
||||
mutations << 'nil.foo ||= expression'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -52,6 +61,7 @@ describe Mutant::Mutator, 'send' do
|
|||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'foo'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -65,6 +75,8 @@ describe Mutant::Mutator, 'send' do
|
|||
mutations << 'foo'
|
||||
mutations << 'foo(nil)'
|
||||
mutations << 'foo(bar)'
|
||||
mutations << 'foo(*nil)'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -76,6 +88,7 @@ describe Mutant::Mutator, 'send' do
|
|||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'foo'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -87,6 +100,7 @@ describe Mutant::Mutator, 'send' do
|
|||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'foo'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -96,7 +110,12 @@ describe Mutant::Mutator, 'send' do
|
|||
context 'implicit' do
|
||||
let(:source) { 'foo' }
|
||||
|
||||
it_should_behave_like 'a noop mutator'
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
||||
context 'explict receiver' do
|
||||
|
@ -107,6 +126,7 @@ describe Mutant::Mutator, 'send' do
|
|||
mutations << 'foo'
|
||||
mutations << 'self'
|
||||
mutations << 'nil.foo'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -132,6 +152,8 @@ describe Mutant::Mutator, 'send' do
|
|||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'foo'
|
||||
mutations << 'nil.bar'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -145,6 +167,8 @@ describe Mutant::Mutator, 'send' do
|
|||
mutations << 'self.class'
|
||||
mutations << 'self.foo'
|
||||
mutations << 'nil.class.foo'
|
||||
mutations << 'nil.foo'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -191,8 +215,9 @@ describe Mutant::Mutator, 'send' do
|
|||
mutations = []
|
||||
mutations << "foo.#{keyword}"
|
||||
mutations << 'foo'
|
||||
mutations << 'nil'
|
||||
mutations << "foo.#{keyword}(::Object.new)"
|
||||
mutations << "nil.#{keyword}(nil)"
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -209,6 +234,7 @@ describe Mutant::Mutator, 'send' do
|
|||
mutations << 'foo(nil)'
|
||||
mutations << 'foo(::Object.new, nil)'
|
||||
mutations << 'foo(nil, ::Object.new)'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -224,6 +250,11 @@ describe Mutant::Mutator, 'send' do
|
|||
mutations << '(left - right)'
|
||||
mutations << 'left / foo'
|
||||
mutations << 'right / foo'
|
||||
mutations << '(left - right) / nil'
|
||||
mutations << '(left - nil) / foo'
|
||||
mutations << '(nil - right) / foo'
|
||||
mutations << 'nil / foo'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -241,6 +272,7 @@ describe Mutant::Mutator, 'send' do
|
|||
mutations << "true #{operator} nil"
|
||||
mutations << 'true'
|
||||
mutations << 'false'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -252,6 +284,9 @@ describe Mutant::Mutator, 'send' do
|
|||
mutations = []
|
||||
mutations << 'left'
|
||||
mutations << 'right'
|
||||
mutations << "left #{operator} nil"
|
||||
mutations << "nil #{operator} right"
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
|
|
@ -21,6 +21,7 @@ describe Mutant::Mutator, 'super' do
|
|||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'super'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
@ -35,6 +36,9 @@ describe Mutant::Mutator, 'super' do
|
|||
mutations << 'super()'
|
||||
mutations << 'super(foo)'
|
||||
mutations << 'super(bar)'
|
||||
mutations << 'super(foo, nil)'
|
||||
mutations << 'super(nil, bar)'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
|
|
@ -14,6 +14,9 @@ describe Mutant::Mutator::Node::While do
|
|||
mutations << 'while true; end'
|
||||
mutations << 'while false; foo; bar; end'
|
||||
mutations << 'while nil; foo; bar; end'
|
||||
mutations << 'while true; foo; nil; end'
|
||||
mutations << 'while true; nil; bar; end'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
|
Loading…
Reference in a new issue