Add expression => self mutation

Also reorganizes parts of meta to align filenames to node name better.

Closes #191
This commit is contained in:
Markus Schirp 2014-06-05 16:37:31 +00:00
parent 89e8eb5679
commit 017ccc1044
84 changed files with 517 additions and 440 deletions

View file

@ -159,6 +159,8 @@ require 'mutant/mutator/node/named_value/variable_assignment'
require 'mutant/mutator/node/loop_control' require 'mutant/mutator/node/loop_control'
require 'mutant/mutator/node/noop' require 'mutant/mutator/node/noop'
require 'mutant/mutator/node/or_asgn' require 'mutant/mutator/node/or_asgn'
require 'mutant/mutator/node/and_asgn'
require 'mutant/mutator/node/defined'
require 'mutant/mutator/node/op_asgn' require 'mutant/mutator/node/op_asgn'
require 'mutant/mutator/node/conditional_loop' require 'mutant/mutator/node/conditional_loop'
require 'mutant/mutator/node/yield' require 'mutant/mutator/node/yield'

View file

@ -74,6 +74,17 @@ module Mutant
self self
end end
# Add singleotn mutations
#
# @return [undefined]
#
# @api private
#
def singleton_mutations
mutation 'nil'
mutation 'self'
end
# Helper method to coerce input to node # Helper method to coerce input to node
# #
# @param [String,Parser::AST::Node] input # @param [String,Parser::AST::Node] input

View file

@ -23,8 +23,8 @@ module Mutant
children.at(index) children.at(index)
end end
define_method("emit_#{name}_mutations") do define_method("emit_#{name}_mutations") do |&block|
mutate_child(index) mutate_child(index, &block)
end end
define_method("emit_#{name}") do |node| define_method("emit_#{name}") do |node|
@ -118,12 +118,15 @@ module Mutant
# #
# @api private # @api private
# #
def mutate_child(index, mutator = Mutator) def mutate_child(index, mutator = Mutator, &block)
block ||= lambda { |_node| true }
child = children.at(index) child = children.at(index)
mutator.each(child, self) do |mutation| mutator.each(child, self) do |mutation|
if block.call(mutation)
emit_child_update(index, mutation) emit_child_update(index, mutation)
end end
end end
end
# Emit delete child mutation # Emit delete child mutation
# #
@ -166,7 +169,28 @@ module Mutant
emit(new_self(*children)) emit(new_self(*children))
end end
# Emit a new AST node with NilLiteral class # Emit singleton literals
#
# @return [undefined]
#
# @api private
#
def emit_singletons
emit_nil
emit_self
end
# Emit a literal self
#
# @return [undefined]
#
# @api private
#
def emit_self
emit(N_SELF)
end
# Emit a literal nil
# #
# @return [undefined] # @return [undefined]
# #

View file

@ -0,0 +1,34 @@
# encoding: utf-8
module Mutant
class Mutator
class Node
# OpAsgn mutator
class AndAsgn < self
handle(:and_asgn)
children :left, :right
private
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_singletons
emit_left_mutations do |mutation|
!mutation.type.equal?(:self)
end
emit_right_mutations
end
end # OrAsgn
end # Node
end # Mutator
end # Mutant

View file

@ -24,7 +24,7 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_nil emit_singletons
emit(left) emit(left)
emit(right) emit(right)
mutate_operator mutate_operator

View file

@ -19,6 +19,7 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_singletons
emit(send) emit(send)
emit_arguments_mutations emit_arguments_mutations
if body if body
@ -26,7 +27,6 @@ module Mutant
end end
emit_body(nil) emit_body(nil)
emit_body(RAISE) emit_body(RAISE)
emit_nil
end end
end # Block end # Block

View file

@ -20,10 +20,10 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_singletons
emit_condition_mutations if condition emit_condition_mutations if condition
emit_when_mutations emit_when_mutations
emit_else_mutations emit_else_mutations
emit_nil
end end
# Emit when mutations # Emit when mutations

View file

@ -20,11 +20,11 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_singletons
emit_condition_mutations emit_condition_mutations
emit_body_mutations if body emit_body_mutations if body
emit_body(nil) emit_body(nil)
emit_body(RAISE) emit_body(RAISE)
emit_nil
end end
end # While end # While

View file

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

View file

@ -0,0 +1,30 @@
# encoding: utf-8
module Mutant
class Mutator
class Node
# Namespace for define mutations
class Defined < self
handle(:defined?)
children :expression
private
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_expression_mutations do |node|
!node.type.equal?(:self)
end
end
end # Defined
end # Node
end # Mutator
end # Mutant

View file

@ -19,7 +19,7 @@ module Mutant
# #
def dispatch def dispatch
super super
emit_nil emit_singletons
end end
end # Dstr end # Dstr

View file

@ -19,7 +19,7 @@ module Mutant
# #
def dispatch def dispatch
super super
emit_nil emit_singletons
end end
end # Dsym end # Dsym

View file

@ -10,7 +10,7 @@ module Mutant
# These nodes still need a dedicated mutator, # These nodes still need a dedicated mutator,
# your contribution is that close! # your contribution is that close!
handle( handle(
:ensure, :redo, :defined?, :regopt, :retry, :arg_expr, :ensure, :redo, :regopt, :retry, :arg_expr,
:kwrestarg, :kwoptarg, :kwarg, :undef, :module, :empty, :kwrestarg, :kwoptarg, :kwarg, :undef, :module, :empty,
:alias, :for, :xstr, :back_ref, :class, :alias, :for, :xstr, :back_ref, :class,
:sclass, :match_with_lvasgn, :while_post, :sclass, :match_with_lvasgn, :while_post,

View file

@ -19,10 +19,10 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_singletons
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
@ -32,7 +32,9 @@ module Mutant
# @api private # @api private
# #
def mutate_condition def mutate_condition
emit_condition_mutations emit_condition_mutations do |condition|
!condition.type.eql?(:self)
end
emit_type(n_not(condition), if_branch, else_branch) unless condition.type == :match_current_line emit_type(n_not(condition), if_branch, else_branch) unless condition.type == :match_current_line
emit_type(N_TRUE, if_branch, else_branch) emit_type(N_TRUE, if_branch, else_branch)
emit_type(N_FALSE, if_branch, else_branch) emit_type(N_FALSE, if_branch, else_branch)

View file

@ -19,7 +19,7 @@ module Mutant
# #
def dispatch def dispatch
super super
emit_nil emit_singletons
end end
end # Kwbegin end # Kwbegin

View file

@ -18,7 +18,7 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_nil emit_singletons
emit_type emit_type
mutate_body mutate_body
if children.one? if children.one?

View file

@ -18,7 +18,7 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_nil emit_singletons
emit_values(values) emit_values(values)
end end

View file

@ -18,7 +18,7 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_nil emit_singletons
emit_values(values) emit_values(values)
emit_special_cases emit_special_cases
end end

View file

@ -18,7 +18,7 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_nil emit_singletons
emit_type emit_type
mutate_body mutate_body
end end

View file

@ -26,7 +26,7 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_nil emit_singletons
emit_inverse emit_inverse
emit_lower_bound_mutations emit_lower_bound_mutations
emit_upper_bound_mutations emit_upper_bound_mutations

View file

@ -31,7 +31,7 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_nil unless parent_type == :match_current_line emit_singletons unless parent_type == :match_current_line
children.each_with_index do |child, index| children.each_with_index do |child, index|
mutate_child(index) unless child.type == :str mutate_child(index) unless child.type == :str
end end

View file

@ -18,7 +18,7 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_nil emit_singletons
end end
end # String end # String

View file

@ -22,7 +22,7 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_nil emit_singletons
Mutator::Util::Symbol.each(value, self) do |value| Mutator::Util::Symbol.each(value, self) do |value|
emit_type(value) emit_type(value)
end end

View file

@ -24,9 +24,9 @@ module Mutant
# #
def dispatch def dispatch
super super
emit_singletons
children.each_index(&method(:delete_child)) children.each_index(&method(:delete_child))
emit(s(INVERSE.fetch(node.type), *children)) emit(s(INVERSE.fetch(node.type), *children))
emit_nil
end end
end # Next end # Next

View file

@ -20,7 +20,7 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_nil emit_singletons
end end
end # MultipleAssignment end # MultipleAssignment

View file

@ -17,7 +17,7 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_nil emit_singletons
emit_regexp_mutations emit_regexp_mutations
end end

View file

@ -19,7 +19,7 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_nil emit_singletons
end end
end # Access end # Access

View file

@ -32,9 +32,9 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_singletons
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

View file

@ -5,9 +5,11 @@ module Mutant
class Node class Node
# OpAsgn mutator # OpAsgn mutator
class OpAsgn < Generic class OpAsgn < self
handle(:op_asgn, :and_asgn) handle(:op_asgn)
children :left, :operation, :right
private private
@ -18,8 +20,11 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
super emit_singletons
emit_nil emit_left_mutations do |mutation|
!mutation.type.equal?(:self)
end
emit_right_mutations
end end
end # OpAsgn end # OpAsgn

View file

@ -20,8 +20,12 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_nil emit_singletons
emit_left_mutations unless left.type.equal?(:ivasgn) unless left.type.equal?(:ivasgn)
emit_left_mutations do |mutation|
!mutation.type.equal?(:self)
end
end
emit_right_mutations emit_right_mutations
end end

View file

@ -19,11 +19,11 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_singletons
if value if value
emit(value) emit(value)
emit_value_mutations emit_value_mutations
end end
emit_nil
end end
end # Return end # Return

View file

@ -34,7 +34,7 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_nil emit_singletons
case selector case selector
when INDEX_REFERENCE when INDEX_REFERENCE
run(Index::Reference) run(Index::Reference)

View file

@ -19,7 +19,7 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_nil emit_singletons
emit_expression_mutations emit_expression_mutations
emit(expression) emit(expression)
end end

View file

@ -21,13 +21,13 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_singletons
emit(Z_SUPER) emit(Z_SUPER)
emit(EMPTY_SUPER) emit(EMPTY_SUPER)
children.each_index do |index| children.each_index do |index|
mutate_child(index) mutate_child(index)
delete_child(index) delete_child(index)
end end
emit_nil
end end
end # Super end # Super

View file

@ -19,8 +19,8 @@ module Mutant
# #
def dispatch def dispatch
super super
emit_singletons
children.each_index(&method(:delete_child)) children.each_index(&method(:delete_child))
emit_nil
end end
end # Yield end # Yield

View file

@ -18,7 +18,7 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_nil emit_singletons
end end
end # ZSuper end # ZSuper

View file

@ -30,6 +30,7 @@ module Mutant
N_FALSE = s(:false) N_FALSE = s(:false)
N_NIL = s(:nil) N_NIL = s(:nil)
N_EMPTY = s(:empty) N_EMPTY = s(:empty)
N_SELF = s(:self)
# Build a negated boolean node # Build a negated boolean node
# #

View file

@ -3,7 +3,7 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'true and false' source 'true and false'
mutation 'nil' singleton_mutations
mutation 'true' mutation 'true'
mutation 'false' mutation 'false'
mutation 'true or false' mutation 'true or false'

View file

@ -3,10 +3,12 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'a &&= 1' source 'a &&= 1'
singleton_mutations
mutation 'a__mutant__ &&= 1' mutation 'a__mutant__ &&= 1'
mutation 'a &&= nil' mutation 'a &&= nil'
mutation 'a &&= 0' mutation 'a &&= 0'
mutation 'a &&= -1' mutation 'a &&= -1'
mutation 'a &&= 2' mutation 'a &&= 2'
mutation 'nil' mutation 'a &&= self'
end end

View file

@ -3,7 +3,7 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '[true]' source '[true]'
mutation 'nil' singleton_mutations
mutation 'true' mutation 'true'
mutation '[false]' mutation '[false]'
mutation '[nil]' mutation '[nil]'
@ -13,7 +13,7 @@ end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '[true, false]' source '[true, false]'
mutation 'nil' singleton_mutations
# Mutation of each element in array # Mutation of each element in array
mutation '[nil, false]' mutation '[nil, false]'

View file

@ -3,19 +3,22 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo() { a; b }' source 'foo() { a; b }'
singleton_mutations
mutation 'foo { a }' mutation 'foo { a }'
mutation 'foo { b }' mutation 'foo { b }'
mutation 'foo {}' mutation 'foo {}'
mutation 'foo { raise }' mutation 'foo { raise }'
mutation 'foo { a; nil }' mutation 'foo { a; nil }'
mutation 'foo { a; self }'
mutation 'foo { nil; b }' mutation 'foo { nil; b }'
mutation 'foo { self; b }'
mutation 'foo' mutation 'foo'
mutation 'nil'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo { |a, b| }' source 'foo { |a, b| }'
singleton_mutations
mutation 'foo' mutation 'foo'
mutation 'foo { |a, b| raise }' mutation 'foo { |a, b| raise }'
mutation 'foo { |a, b__mutant__| }' mutation 'foo { |a, b__mutant__| }'
@ -23,13 +26,12 @@ Mutant::Meta::Example.add do
mutation 'foo { |a| }' mutation 'foo { |a| }'
mutation 'foo { |b| }' mutation 'foo { |b| }'
mutation 'foo { || }' mutation 'foo { || }'
mutation 'nil'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo { |(a, b), c| }' source 'foo { |(a, b), c| }'
mutation 'nil' singleton_mutations
mutation 'foo { || }' mutation 'foo { || }'
mutation 'foo { |a, b, c| }' mutation 'foo { |a, b, c| }'
mutation 'foo { |(a, b), c| raise }' mutation 'foo { |(a, b), c| raise }'
@ -46,10 +48,10 @@ end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo { |(a)| }' source 'foo { |(a)| }'
singleton_mutations
mutation 'foo { || }' mutation 'foo { || }'
mutation 'foo { |a| }' mutation 'foo { |a| }'
mutation 'foo { |(a)| raise }' mutation 'foo { |(a)| raise }'
mutation 'foo { |(a__mutant__)| }' mutation 'foo { |(a__mutant__)| }'
mutation 'foo' mutation 'foo'
mutation 'nil'
end end

View file

@ -3,6 +3,6 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo(&bar)' source 'foo(&bar)'
singleton_mutations
mutation 'foo' mutation 'foo'
mutation 'nil'
end end

View file

@ -3,8 +3,8 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo { |&bar| }' source 'foo { |&bar| }'
singleton_mutations
mutation 'foo { |&bar| raise }' mutation 'foo { |&bar| raise }'
mutation 'foo {}' mutation 'foo {}'
mutation 'foo' mutation 'foo'
mutation 'nil'
end end

View file

@ -3,9 +3,9 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'break true' source 'break true'
singleton_mutations
mutation 'break false' mutation 'break false'
mutation 'break nil' mutation 'break nil'
mutation 'break' mutation 'break'
mutation 'nil'
mutation 'next true' mutation 'next true'
end end

View file

@ -8,7 +8,7 @@ Mutant::Meta::Example.add do
end end
RUBY RUBY
mutation 'nil' singleton_mutations
mutation <<-RUBY mutation <<-RUBY
case case
@ -33,271 +33,192 @@ end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source <<-RUBY source <<-RUBY
case :condition case condition
when :foo when A
when :bar, :baz when B, C
:barbaz C
else else
:else D
end end
RUBY RUBY
# Presence of branches singleton_mutations
mutation <<-RUBY
case :condition
when :bar, :baz
:barbaz
else
:else
end
RUBY
mutation <<-RUBY
case :condition
when :foo
else
:else
end
RUBY
mutation <<-RUBY
case :condition
when :foo
when :bar, :baz
:barbaz
end
RUBY
# Mutations of condition
mutation <<-RUBY mutation <<-RUBY
case nil case nil
when :foo when A
when :bar, :baz when B, C
:barbaz C
else else
:else D
end
RUBY
mutation <<-RUBY
case :condition__mutant__
when :foo
when :bar, :baz
:barbaz
else
:else
end end
RUBY RUBY
# Mutations of branch bodies
mutation <<-RUBY mutation <<-RUBY
case :condition case self
when :foo when A
when B, C
C
else
D
end
RUBY
mutation <<-RUBY
case condition
when A
raise raise
when :bar, :baz when B, C
:barbaz C
else else
:else D
end
RUBY
mutation <<-RUBY
case :condition
when :foo
when :bar, :baz
:barbaz__mutant__
else
:else
end
RUBY
mutation <<-RUBY
case :condition
when :foo
when :bar, :baz
nil
else
:else
end
RUBY
mutation <<-RUBY
case :condition
when :foo
when :bar, :baz
:barbaz
else
:else__mutant__
end
RUBY
mutation <<-RUBY
case :condition
when :foo
when :bar, :baz
:barbaz
else
nil
end end
RUBY RUBY
# Mutations of when conditions
mutation <<-RUBY mutation <<-RUBY
case :condition case condition
when :foo__mutant__
when :bar, :baz
:barbaz
else
:else
end
RUBY
mutation <<-RUBY
case :condition
when nil when nil
when :bar, :baz when B, C
:barbaz C
else else
:else D
end
RUBY
mutation <<-RUBY
case :condition
when :foo
when :bar__mutant__, :baz
:barbaz
else
:else
end
RUBY
mutation <<-RUBY
case :condition
when :foo
when nil, :baz
:barbaz
else
:else
end
RUBY
mutation <<-RUBY
case :condition
when :foo
when :bar, nil
:barbaz
else
:else
end
RUBY
mutation <<-RUBY
case :condition
when :foo
when :bar, :baz__mutant__
:barbaz
else
:else
end
RUBY
mutation <<-RUBY
case :condition
when :foo
when :baz
:barbaz
else
:else
end
RUBY
mutation <<-RUBY
case :condition
when :foo
when :bar
:barbaz
else
:else
end end
RUBY RUBY
mutation 'nil' mutation <<-RUBY
end case condition
when self
Mutant::Meta::Example.add do when B, C
source <<-RUBY C
case :condition
when :foo
:foo
else else
:else D
end end
RUBY RUBY
# Presence of branches
mutation <<-RUBY mutation <<-RUBY
case :condition case condition
when :foo when B, C
:foo C
end
RUBY
# Mutations of condition
mutation <<-RUBY
case nil
when :foo
:foo
else else
:else D
end
RUBY
mutation <<-RUBY
case :condition__mutant__
when :foo
:foo
else
:else
end end
RUBY RUBY
# Mutations of branch bodies
mutation <<-RUBY mutation <<-RUBY
case :condition case condition
when :foo when A
when B, C
nil nil
else else
:else D
end end
RUBY RUBY
mutation <<-RUBY mutation <<-RUBY
case :condition case condition
when :foo when A
:foo__mutant__ when B, C
self
else else
:else D
end end
RUBY RUBY
mutation <<-RUBY mutation <<-RUBY
case :condition case condition
when :foo when A
:foo when C
C
else else
:else__mutant__ D
end end
RUBY RUBY
mutation <<-RUBY mutation <<-RUBY
case :condition case condition
when :foo when A
:foo when nil, C
C
else
D
end
RUBY
mutation <<-RUBY
case condition
when A
when self, C
C
else
D
end
RUBY
mutation <<-RUBY
case condition
when A
when B
C
else
D
end
RUBY
mutation <<-RUBY
case condition
when A
when B, nil
C
else
D
end
RUBY
mutation <<-RUBY
case condition
when A
when B, self
C
else
D
end
RUBY
mutation <<-RUBY
case condition
when A
else
D
end
RUBY
mutation <<-RUBY
case condition
when A
when B, C
C
else else
nil nil
end end
RUBY RUBY
# Mutations of when conditions
mutation <<-RUBY mutation <<-RUBY
case :condition case condition
when :foo__mutant__ when A
:foo when B, C
C
else else
:else self
end
RUBY
mutation <<-RUBY
case :condition
when nil
:foo
else
:else
end end
RUBY RUBY
mutation 'nil' mutation <<-RUBY
case condition
when A
when B, C
C
end end
RUBY
end

View file

@ -3,6 +3,6 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '::A' source '::A'
mutation 'nil' singleton_mutations
mutation 'A' mutation 'A'
end end

View file

@ -3,7 +3,7 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'A::B::C' source 'A::B::C'
mutation 'nil' singleton_mutations
mutation 'B::C' mutation 'B::C'
mutation 'C' mutation 'C'
end end

View file

@ -3,5 +3,5 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '@@a' source '@@a'
mutation 'nil' singleton_mutations
end end

View file

@ -3,8 +3,8 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '@@a = true' source '@@a = true'
singleton_mutations
mutation '@@a__mutant__ = true' mutation '@@a__mutant__ = true'
mutation '@@a = false' mutation '@@a = false'
mutation '@@a = nil' mutation '@@a = nil'
mutation 'nil'
end end

View file

@ -7,10 +7,11 @@ Mutant::Meta::Example.add do
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source "def foo\nfoo\nrescue\nend" source 'def foo; foo; rescue; end'
mutation 'def foo; raise; end' mutation 'def foo; raise; end'
mutation 'def foo; nil; rescue; end' mutation 'def foo; nil; rescue; end'
mutation 'def foo; self; rescue; end'
mutation 'def foo; end' mutation 'def foo; end'
end end

View file

@ -3,8 +3,11 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '"foo#{bar}baz"' source '"foo#{bar}baz"'
mutation 'nil' singleton_mutations
mutation '"#{nil}#{bar}baz"' mutation '"#{nil}#{bar}baz"'
mutation '"#{self}#{bar}baz"'
mutation '"foo#{bar}#{nil}"' mutation '"foo#{bar}#{nil}"'
mutation '"foo#{bar}#{self}"'
mutation '"foo#{nil}baz"' mutation '"foo#{nil}baz"'
mutation '"foo#{self}baz"'
end end

View file

@ -1,11 +1,13 @@
# encoding: utf-8 # encoding: utf-8
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source ':"foo#{bar}baz"' source ':"foo#{bar}baz"'
singleton_mutations
mutation ':"#{nil}#{bar}baz"' mutation ':"#{nil}#{bar}baz"'
mutation ':"#{self}#{bar}baz"'
mutation ':"foo#{bar}#{nil}"' mutation ':"foo#{bar}#{nil}"'
mutation ':"foo#{bar}#{self}"'
mutation ':"foo#{nil}baz"' mutation ':"foo#{nil}baz"'
mutation 'nil' mutation ':"foo#{self}baz"'
end end

View file

@ -3,7 +3,7 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'begin; rescue; ensure; true; end' source 'begin; rescue; ensure; true; end'
singleton_mutations
mutation 'begin; rescue; ensure; false; end' mutation 'begin; rescue; ensure; false; end'
mutation 'begin; rescue; ensure; nil; end' mutation 'begin; rescue; ensure; nil; end'
mutation 'nil'
end end

8
meta/false.rb Normal file
View file

@ -0,0 +1,8 @@
# encoding: utf-8
Mutant::Meta::Example.add do
source 'false'
mutation 'nil'
mutation 'true'
end

View file

@ -3,8 +3,7 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '10.0' source '10.0'
# generic singleton_mutations
mutation 'nil'
# edge cases # edge cases
mutation '0.0' mutation '0.0'
@ -20,7 +19,7 @@ end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '0.0' source '0.0'
mutation 'nil' singleton_mutations
mutation '1.0' mutation '1.0'
mutation '(0.0 / 0.0)' mutation '(0.0 / 0.0)'
mutation '(1.0 / 0.0)' mutation '(1.0 / 0.0)'
@ -30,7 +29,7 @@ end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '-0.0' source '-0.0'
mutation 'nil' singleton_mutations
mutation '1.0' mutation '1.0'
mutation '(0.0 / 0.0)' mutation '(0.0 / 0.0)'
mutation '(1.0 / 0.0)' mutation '(1.0 / 0.0)'

View file

@ -3,5 +3,5 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '$a' source '$a'
mutation 'nil' singleton_mutations
end end

View file

@ -3,8 +3,8 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '$a = true' source '$a = true'
singleton_mutations
mutation '$a__mutant__ = true' mutation '$a__mutant__ = true'
mutation '$a = false' mutation '$a = false'
mutation '$a = nil' mutation '$a = nil'
mutation 'nil'
end end

View file

@ -3,8 +3,7 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '{true => true, false => false}' source '{true => true, false => false}'
# Literal replaced with nil singleton_mutations
mutation 'nil'
# Mutation of each key and value in hash # Mutation of each key and value in hash
mutation '{ false => true , false => false }' mutation '{ false => true , false => false }'

View file

@ -1,57 +1,55 @@
# encoding: utf-8 # encoding: utf-8
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'if :condition; true; else false; end' source 'if condition; true; else false; end'
singleton_mutations
# mutation of condition # mutation of condition
mutation 'if :condition__mutant__; true; else false; end' mutation 'if !condition; true; else false; end'
mutation 'if !:condition; true; else false; end'
mutation 'if nil; true; else false; end' mutation 'if nil; true; else false; end'
mutation 'if true; true; else false; end' mutation 'if true; true; else false; end'
mutation 'if false; true; else false; end' mutation 'if false; true; else false; end'
# Deleted else branch # Deleted else branch
mutation 'if :condition; true end' mutation 'if condition; true end'
# Deleted if branch resuting in unless rendering # Deleted if branch resuting in unless rendering
mutation 'unless :condition; false; end' mutation 'unless condition; false; end'
# Deleted if branch with promoting else branch to if branch # Deleted if branch with promoting else branch to if branch
mutation 'if :condition; false end' mutation 'if condition; false end'
# mutation of if body # mutation of if body
mutation 'if :condition; false; else false; end' mutation 'if condition; false; else false; end'
mutation 'if :condition; nil; else false; end' mutation 'if condition; nil; else false; end'
# mutation of else body # mutation of else body
mutation 'if :condition; true; else true; end' mutation 'if condition; true; else true; end'
mutation 'if :condition; true; else nil; end' mutation 'if condition; true; else nil; end'
mutation 'nil'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'if condition; true; end' source 'if condition; true; end'
singleton_mutations
mutation 'if !condition; true; end' mutation 'if !condition; true; end'
mutation 'if condition; false; end' mutation 'if condition; false; end'
mutation 'if condition; nil; end' mutation 'if condition; nil; end'
mutation 'if true; true; end' mutation 'if true; true; end'
mutation 'if false; true; end' mutation 'if false; true; end'
mutation 'if nil; true; end' mutation 'if nil; true; end'
mutation 'nil'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'unless :condition; true; end' source 'unless condition; true; end'
mutation 'unless !:condition; true; end' singleton_mutations
mutation 'unless :condition__mutant__; true; end' mutation 'unless !condition; true; end'
mutation 'unless nil; true; end' mutation 'unless nil; true; end'
mutation 'unless :condition; false; end'
mutation 'unless :condition; nil; end'
mutation 'unless true; true; end' mutation 'unless true; true; end'
mutation 'unless false; true; end' mutation 'unless false; true; end'
mutation 'if :condition; true; end' mutation 'unless condition; false; end'
mutation 'nil' mutation 'unless condition; nil; end'
mutation 'if condition; true; end'
end end

View file

@ -3,8 +3,7 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '10' source '10'
# generic singleton_mutations
mutation 'nil'
# edge cases # edge cases
mutation '0' mutation '0'

View file

@ -3,8 +3,8 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '@a = true' source '@a = true'
singleton_mutations
mutation '@a__mutant__ = true' mutation '@a__mutant__ = true'
mutation '@a = false' mutation '@a = false'
mutation '@a = nil' mutation '@a = nil'
mutation 'nil'
end end

View file

@ -3,7 +3,7 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'begin; true; end' source 'begin; true; end'
singleton_mutations
mutation 'begin; false; end' mutation 'begin; false; end'
mutation 'begin; nil; end' mutation 'begin; nil; end'
mutation 'nil'
end end

View file

@ -4,11 +4,13 @@ Mutant::Meta::Example.add do
source 'a = nil; a' source 'a = nil; a'
mutation 'a = nil; nil' mutation 'a = nil; nil'
mutation 'a = nil; self'
mutation 'a = nil' mutation 'a = nil'
# TODO: fix invalid AST # TODO: fix invalid AST
# These ASTs are not valid and should NOT be emitted # These ASTs are not valid and should NOT be emitted
# Mutations of lvarasgn need to be special cased to avoid this. # Mutations of lvarasgn need to be special cased to avoid this.
mutation s(:begin, s(:lvasgn, :a__mutant__, s(:nil)), s(:lvar, :a)) mutation s(:begin, s(:lvasgn, :a__mutant__, s(:nil)), s(:lvar, :a))
mutation s(:begin, s(:nil), s(:lvar, :a)) mutation s(:begin, s(:nil), s(:lvar, :a))
mutation s(:begin, s(:self), s(:lvar, :a))
mutation s(:lvar, :a) mutation s(:lvar, :a)
end end

View file

@ -3,8 +3,8 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'a = true' source 'a = true'
singleton_mutations
mutation 'a__mutant__ = true' mutation 'a__mutant__ = true'
mutation 'a = false' mutation 'a = false'
mutation 'a = nil' mutation 'a = nil'
mutation 'nil'
end end

View file

@ -3,5 +3,5 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'a, b = c, d' source 'a, b = c, d'
mutation 'nil' singleton_mutations
end end

View file

@ -3,6 +3,7 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'true if /foo/' source 'true if /foo/'
singleton_mutations
mutation 'false if /foo/' mutation 'false if /foo/'
mutation 'true if //' mutation 'true if //'
mutation 'nil if /foo/' mutation 'nil if /foo/'
@ -10,5 +11,4 @@ Mutant::Meta::Example.add do
mutation 'true if false' mutation 'true if false'
mutation 'true if nil' mutation 'true if nil'
mutation 'true if /a\A/' mutation 'true if /a\A/'
mutation 'nil'
end end

View file

@ -3,9 +3,9 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'next true' source 'next true'
singleton_mutations
mutation 'next false' mutation 'next false'
mutation 'next nil' mutation 'next nil'
mutation 'next' mutation 'next'
mutation 'nil'
mutation 'break true' mutation 'break true'
end end

View file

@ -3,12 +3,14 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '@a.b += 1' source '@a.b += 1'
singleton_mutations
mutation '@a.b += -1' mutation '@a.b += -1'
mutation '@a.b += 2' mutation '@a.b += 2'
mutation '@a.b += 0' mutation '@a.b += 0'
mutation '@a.b += nil' mutation '@a.b += nil'
mutation '@a.b += self'
mutation 'nil.b += 1' mutation 'nil.b += 1'
mutation 'nil' mutation 'self.b += 1'
# TODO: fix invalid AST # TODO: fix invalid AST
# This should not get emitted as invalid AST with valid unparsed source # This should not get emitted as invalid AST with valid unparsed source
mutation s(:op_asgn, s(:ivar, :@a), :+, s(:int, 1)) mutation s(:op_asgn, s(:ivar, :@a), :+, s(:int, 1))

View file

@ -3,7 +3,7 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'true or false' source 'true or false'
mutation 'nil' singleton_mutations
mutation 'true' mutation 'true'
mutation 'false' mutation 'false'
mutation 'true and false' mutation 'true and false'

View file

@ -3,20 +3,22 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'a ||= 1' source 'a ||= 1'
singleton_mutations
mutation 'a__mutant__ ||= 1' mutation 'a__mutant__ ||= 1'
mutation 'a ||= nil' mutation 'a ||= nil'
mutation 'a ||= self'
mutation 'a ||= 0' mutation 'a ||= 0'
mutation 'a ||= -1' mutation 'a ||= -1'
mutation 'a ||= 2' mutation 'a ||= 2'
mutation 'nil'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '@a ||= 1' source '@a ||= 1'
singleton_mutations
mutation '@a ||= nil' mutation '@a ||= nil'
mutation '@a ||= self'
mutation '@a ||= 0' mutation '@a ||= 0'
mutation '@a ||= -1' mutation '@a ||= -1'
mutation '@a ||= 2' mutation '@a ||= 2'
mutation 'nil'
end end

View file

@ -3,7 +3,7 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '1..100' source '1..100'
mutation 'nil' singleton_mutations
mutation '1...100' mutation '1...100'
mutation '(0.0 / 0.0)..100' mutation '(0.0 / 0.0)..100'
mutation '1..(1.0 / 0.0)' mutation '1..(1.0 / 0.0)'
@ -12,7 +12,9 @@ Mutant::Meta::Example.add do
mutation '0..100' mutation '0..100'
mutation '2..100' mutation '2..100'
mutation 'nil..100' mutation 'nil..100'
mutation 'self..100'
mutation '1..nil' mutation '1..nil'
mutation '1..self'
mutation '1..0' mutation '1..0'
mutation '1..1' mutation '1..1'
mutation '1..99' mutation '1..99'
@ -23,7 +25,7 @@ end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '1...100' source '1...100'
mutation 'nil' singleton_mutations
mutation '1..100' mutation '1..100'
mutation '(0.0 / 0.0)...100' mutation '(0.0 / 0.0)...100'
mutation '1...(1.0 / 0.0)' mutation '1...(1.0 / 0.0)'
@ -32,7 +34,9 @@ Mutant::Meta::Example.add do
mutation '0...100' mutation '0...100'
mutation '2...100' mutation '2...100'
mutation 'nil...100' mutation 'nil...100'
mutation 'self...100'
mutation '1...nil' mutation '1...nil'
mutation '1...self'
mutation '1...0' mutation '1...0'
mutation '1...1' mutation '1...1'
mutation '1...99' mutation '1...99'

View file

@ -3,18 +3,20 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '/foo/' source '/foo/'
singleton_mutations
mutation '//' # match all mutation '//' # match all
mutation '/a\A/' # match nothing mutation '/a\A/' # match nothing
mutation 'nil'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '/#{foo.bar}n/' source '/#{foo.bar}n/'
singleton_mutations
mutation '//' # match all mutation '//' # match all
mutation '/#{foo}n/' mutation '/#{foo}n/'
mutation '/a\A/' # match nothing mutation '/a\A/' # match nothing
mutation '/#{nil.bar}n/' mutation '/#{nil.bar}n/'
mutation '/#{self.bar}n/'
mutation '/#{nil}n/' mutation '/#{nil}n/'
mutation 'nil' mutation '/#{self}n/'
end end

View file

@ -3,8 +3,10 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'begin; rescue ExceptionA, ExceptionB => error; true; end' source 'begin; rescue ExceptionA, ExceptionB => error; true; end'
mutation 'nil' singleton_mutations
mutation 'begin; rescue ExceptionA, ExceptionB; true; end' mutation 'begin; rescue ExceptionA, ExceptionB; true; end'
mutation 'begin; rescue self, ExceptionB => error; true; end'
mutation 'begin; rescue ExceptionA, self => error; true; end'
mutation 'begin; rescue ExceptionA, ExceptionB => error; false; end' mutation 'begin; rescue ExceptionA, ExceptionB => error; false; end'
mutation 'begin; rescue ExceptionA, ExceptionB => error; nil; end' mutation 'begin; rescue ExceptionA, ExceptionB => error; nil; end'
mutation 'begin; rescue ExceptionA => error; true; end' mutation 'begin; rescue ExceptionA => error; true; end'
@ -14,16 +16,17 @@ end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'begin; rescue SomeException => error; true; end' source 'begin; rescue SomeException => error; true; end'
mutation 'nil' singleton_mutations
mutation 'begin; rescue SomeException; true; end' mutation 'begin; rescue SomeException; true; end'
mutation 'begin; rescue SomeException => error; false; end' mutation 'begin; rescue SomeException => error; false; end'
mutation 'begin; rescue SomeException => error; nil; end' mutation 'begin; rescue SomeException => error; nil; end'
mutation 'begin; rescue self => error; true; end'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'begin; rescue => error; true end' source 'begin; rescue => error; true end'
mutation 'nil' singleton_mutations
mutation 'begin; rescue => error; false; end' mutation 'begin; rescue => error; false; end'
mutation 'begin; rescue => error; nil; end' mutation 'begin; rescue => error; nil; end'
mutation 'begin; rescue; true; end' mutation 'begin; rescue; true; end'
@ -32,7 +35,7 @@ end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'begin; rescue; true end' source 'begin; rescue; true end'
mutation 'nil' singleton_mutations
mutation 'begin; rescue; false; end' mutation 'begin; rescue; false; end'
mutation 'begin; rescue; nil; end' mutation 'begin; rescue; nil; end'
end end

View file

@ -3,9 +3,11 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo(*bar)' source 'foo(*bar)'
singleton_mutations
mutation 'foo' mutation 'foo'
mutation 'foo(nil)' mutation 'foo(nil)'
mutation 'foo(self)'
mutation 'foo(*self)'
mutation 'foo(bar)' mutation 'foo(bar)'
mutation 'foo(*nil)' mutation 'foo(*nil)'
mutation 'nil'
end end

View file

@ -3,13 +3,14 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'return' source 'return'
mutation 'nil' singleton_mutations
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'return foo' source 'return foo'
singleton_mutations
mutation 'foo' mutation 'foo'
mutation 'return nil' mutation 'return nil'
mutation 'nil' mutation 'return self'
end end

View file

@ -3,14 +3,14 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'reverse_each' source 'reverse_each'
mutation 'nil' singleton_mutations
mutation 'each' mutation 'each'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'reverse_map' source 'reverse_map'
mutation 'nil' singleton_mutations
mutation 'map' mutation 'map'
mutation 'each' mutation 'each'
end end
@ -18,18 +18,20 @@ end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'map' source 'map'
mutation 'nil' singleton_mutations
mutation 'each' mutation 'each'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo == bar' source 'foo == bar'
singleton_mutations
mutation 'foo' mutation 'foo'
mutation 'bar' mutation 'bar'
mutation 'nil == bar' mutation 'nil == bar'
mutation 'self == bar'
mutation 'foo == nil' mutation 'foo == nil'
mutation 'nil' mutation 'foo == self'
mutation 'foo.eql?(bar)' mutation 'foo.eql?(bar)'
mutation 'foo.equal?(bar)' mutation 'foo.equal?(bar)'
end end
@ -37,43 +39,40 @@ end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo.gsub(a, b)' source 'foo.gsub(a, b)'
singleton_mutations
mutation 'foo' mutation 'foo'
mutation 'foo.gsub(a)' mutation 'foo.gsub(a)'
mutation 'foo.gsub(b)' mutation 'foo.gsub(b)'
mutation 'foo.gsub' mutation 'foo.gsub'
mutation 'foo.sub(a, b)' mutation 'foo.sub(a, b)'
mutation 'foo.gsub(a, nil)' mutation 'foo.gsub(a, nil)'
mutation 'foo.gsub(a, self)'
mutation 'foo.gsub(nil, b)' mutation 'foo.gsub(nil, b)'
mutation 'foo.gsub(self, b)'
mutation 'nil.gsub(a, b)' mutation 'nil.gsub(a, b)'
mutation 'nil' mutation 'self.gsub(a, b)'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo.send(bar)' source 'foo.send(bar)'
singleton_mutations
mutation 'foo.send' mutation 'foo.send'
mutation 'foo.public_send(bar)' mutation 'foo.public_send(bar)'
mutation 'bar' mutation 'bar'
mutation 'foo' mutation 'foo'
mutation 'self.send(bar)'
mutation 'foo.send(nil)' mutation 'foo.send(nil)'
mutation 'foo.send(self)'
mutation 'nil.send(bar)' mutation 'nil.send(bar)'
mutation 'nil'
end
Mutant::Meta::Example.add do
source 'self.foo ||= expression'
mutation 'self.foo ||= nil'
mutation 'nil.foo ||= expression'
mutation 'nil'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'self.bar = baz' source 'self.bar = baz'
mutation 'nil' singleton_mutations
mutation 'self.bar = nil' mutation 'self.bar = nil'
mutation 'self' mutation 'self.bar = self'
mutation 'self.bar' mutation 'self.bar'
mutation 'baz' mutation 'baz'
# This one could probably be removed # This one could probably be removed
@ -83,9 +82,11 @@ end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo.bar = baz' source 'foo.bar = baz'
singleton_mutations
mutation 'foo' mutation 'foo'
mutation 'nil'
mutation 'foo.bar = nil' mutation 'foo.bar = nil'
mutation 'foo.bar = self'
mutation 'self.bar = baz'
mutation 'foo.bar' mutation 'foo.bar'
mutation 'baz' mutation 'baz'
# This one could probably be removed # This one could probably be removed
@ -95,91 +96,91 @@ end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo[bar]=baz' source 'foo[bar]=baz'
singleton_mutations
mutation 'foo' mutation 'foo'
mutation 'nil'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo(*bar)' source 'foo(*bar)'
singleton_mutations
mutation 'foo' mutation 'foo'
mutation 'foo(nil)' mutation 'foo(nil)'
mutation 'foo(bar)' mutation 'foo(bar)'
mutation 'foo(self)'
mutation 'foo(*nil)' mutation 'foo(*nil)'
mutation 'nil' mutation 'foo(*self)'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo(&bar)' source 'foo(&bar)'
singleton_mutations
mutation 'foo' mutation 'foo'
mutation 'nil'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo[*bar]' source 'foo[*bar]'
singleton_mutations
mutation 'foo' mutation 'foo'
mutation 'nil'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo' source 'foo'
mutation 'nil' singleton_mutations
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'self.foo' source 'self.foo'
singleton_mutations
mutation 'foo' mutation 'foo'
mutation 'self'
mutation 'nil.foo' mutation 'nil.foo'
mutation 'nil'
end end
Unparser::Constants::KEYWORDS.each do |keyword| Unparser::Constants::KEYWORDS.each do |keyword|
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source "self.#{keyword}" source "self.#{keyword}"
singleton_mutations
mutation "nil.#{keyword}" mutation "nil.#{keyword}"
mutation 'nil'
mutation 'self'
end end
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo.bar' source 'foo.bar'
singleton_mutations
mutation 'foo' mutation 'foo'
mutation 'nil.bar' mutation 'nil.bar'
mutation 'nil' mutation 'self.bar'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'self.class.foo' source 'self.class.foo'
singleton_mutations
mutation 'self.class' mutation 'self.class'
mutation 'self.foo' mutation 'self.foo'
mutation 'nil.class.foo' mutation 'nil.class.foo'
mutation 'nil.foo' mutation 'nil.foo'
mutation 'nil'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo(nil)' source 'foo(nil)'
singleton_mutations
mutation 'foo' mutation 'foo'
mutation 'nil'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'self.foo(nil)' source 'self.foo(nil)'
mutation 'self' singleton_mutations
mutation 'self.foo' mutation 'self.foo'
mutation 'foo(nil)' mutation 'foo(nil)'
mutation 'nil'
mutation 'nil.foo(nil)' mutation 'nil.foo(nil)'
end end
@ -187,54 +188,50 @@ Unparser::Constants::KEYWORDS.each do |keyword|
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source "foo.#{keyword}(nil)" source "foo.#{keyword}(nil)"
singleton_mutations
mutation "self.#{keyword}(nil)"
mutation "foo.#{keyword}" mutation "foo.#{keyword}"
mutation 'foo' mutation 'foo'
mutation "nil.#{keyword}(nil)" mutation "nil.#{keyword}(nil)"
mutation 'nil'
end end
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'foo(nil, nil)' source 'foo(nil, nil)'
singleton_mutations
mutation 'foo()' mutation 'foo()'
mutation 'foo(nil)' mutation 'foo(nil)'
mutation 'nil'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '(left - right) / foo' source '(left - right) / foo'
singleton_mutations
mutation 'foo' mutation 'foo'
mutation '(left - right)' mutation '(left - right)'
mutation 'left / foo' mutation 'left / foo'
mutation 'right / foo' mutation 'right / foo'
mutation '(left - right) / nil' mutation '(left - right) / nil'
mutation '(left - right) / self'
mutation '(left - nil) / foo' mutation '(left - nil) / foo'
mutation '(left - self) / foo'
mutation '(nil - right) / foo' mutation '(nil - right) / foo'
mutation '(self - right) / foo'
mutation 'nil / foo' mutation 'nil / foo'
mutation 'nil' mutation 'self / foo'
end end
(Mutant::BINARY_METHOD_OPERATORS - [:==, :eql?]).each do |operator| (Mutant::BINARY_METHOD_OPERATORS - [:==, :eql?]).each do |operator|
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source "true #{operator} false" source "true #{operator} false"
singleton_mutations
mutation 'true'
mutation 'false'
mutation "false #{operator} false" mutation "false #{operator} false"
mutation "nil #{operator} false" mutation "nil #{operator} false"
mutation "true #{operator} true" mutation "true #{operator} true"
mutation "true #{operator} nil" mutation "true #{operator} nil"
mutation 'true'
mutation 'false'
mutation 'nil'
end
Mutant::Meta::Example.add do
source "left #{operator} right"
mutation 'left'
mutation 'right'
mutation "left #{operator} nil"
mutation "nil #{operator} right"
mutation 'nil'
end end
end end

View file

@ -3,5 +3,5 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source '"foo"' source '"foo"'
mutation 'nil' singleton_mutations
end end

View file

@ -3,24 +3,27 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'super' source 'super'
mutation 'nil' singleton_mutations
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'super()' source 'super()'
singleton_mutations
# this is zsuper a totally differend node thant super()
mutation 'super' mutation 'super'
mutation 'nil'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'super(foo, bar)' source 'super(foo, bar)'
singleton_mutations
mutation 'super' mutation 'super'
mutation 'super()' mutation 'super()'
mutation 'super(foo)' mutation 'super(foo)'
mutation 'super(bar)' mutation 'super(bar)'
mutation 'super(foo, nil)' mutation 'super(foo, nil)'
mutation 'super(foo, self)'
mutation 'super(nil, bar)' mutation 'super(nil, bar)'
mutation 'nil' mutation 'super(self, bar)'
end end

View file

@ -3,6 +3,6 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source ':foo' source ':foo'
mutation 'nil' singleton_mutations
mutation ':foo__mutant__' mutation ':foo__mutant__'
end end

8
meta/true.rb Normal file
View file

@ -0,0 +1,8 @@
# encoding: utf-8
Mutant::Meta::Example.add do
source 'true'
mutation 'nil'
mutation 'false'
end

View file

@ -1,15 +0,0 @@
# encoding: utf-8
Mutant::Meta::Example.add do
source 'until true; foo; bar; end'
mutation 'until true; bar; end'
mutation 'until true; foo; end'
mutation 'until true; end'
mutation 'until false; foo; bar; end'
mutation 'until nil; foo; bar; end'
mutation 'until true; foo; nil; end'
mutation 'until true; nil; bar; end'
mutation 'until true; raise; end'
mutation 'nil'
end

17
meta/until.rb Normal file
View file

@ -0,0 +1,17 @@
# encoding: utf-8
Mutant::Meta::Example.add do
source 'until true; foo; bar; end'
singleton_mutations
mutation 'until true; bar; end'
mutation 'until true; foo; end'
mutation 'until true; end'
mutation 'until false; foo; bar; end'
mutation 'until nil; foo; bar; end'
mutation 'until true; foo; nil; end'
mutation 'until true; foo; self; end'
mutation 'until true; nil; bar; end'
mutation 'until true; self; bar; end'
mutation 'until true; raise; end'
end

View file

@ -3,6 +3,9 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'while true; foo; bar; end' source 'while true; foo; bar; end'
singleton_mutations
mutation 'while true; self; bar; end'
mutation 'while true; foo; self; end'
mutation 'while true; bar; end' mutation 'while true; bar; end'
mutation 'while true; foo; end' mutation 'while true; foo; end'
mutation 'while true; end' mutation 'while true; end'
@ -11,14 +14,13 @@ Mutant::Meta::Example.add do
mutation 'while true; foo; nil; end' mutation 'while true; foo; nil; end'
mutation 'while true; nil; bar; end' mutation 'while true; nil; bar; end'
mutation 'while true; raise; end' mutation 'while true; raise; end'
mutation 'nil'
end end
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'while true; end' source 'while true; end'
singleton_mutations
mutation 'while true; raise; end' mutation 'while true; raise; end'
mutation 'while false; end' mutation 'while false; end'
mutation 'while nil; end' mutation 'while nil; end'
mutation 'nil'
end end

View file

@ -3,8 +3,8 @@
Mutant::Meta::Example.add do Mutant::Meta::Example.add do
source 'yield true' source 'yield true'
singleton_mutations
mutation 'yield false' mutation 'yield false'
mutation 'yield nil' mutation 'yield nil'
mutation 'yield' mutation 'yield'
mutation 'nil'
end end