Remove useless mutations and fix index reference
This commit is contained in:
parent
763d66b1e6
commit
ac179cd450
7 changed files with 48 additions and 41 deletions
|
@ -1,3 +1,8 @@
|
|||
# v0.5.20 2014-06-xx
|
||||
|
||||
* Remove a bunch of useless mutations to nil.something
|
||||
* Readd mutation of index reference arguments
|
||||
|
||||
# v0.5.20 2014-06-15
|
||||
|
||||
* Remove support for matchers prefixed with ::
|
||||
|
|
|
@ -36,8 +36,6 @@ module Mutant
|
|||
def dispatch
|
||||
emit_singletons
|
||||
case selector
|
||||
when INDEX_REFERENCE
|
||||
run(Index::Reference)
|
||||
when INDEX_ASSIGN
|
||||
run(Index::Assign)
|
||||
else
|
||||
|
@ -160,7 +158,9 @@ module Mutant
|
|||
def mutate_receiver
|
||||
return unless receiver
|
||||
emit_implicit_self
|
||||
emit_receiver_mutations
|
||||
emit_receiver_mutations do |node|
|
||||
!n_nil?(node)
|
||||
end
|
||||
end
|
||||
|
||||
# Emit implicit self mutation
|
||||
|
@ -210,4 +210,5 @@ module Mutant
|
|||
end # Send
|
||||
end # Node
|
||||
end # Mutator
|
||||
|
||||
end # Mutant
|
||||
|
|
|
@ -2,8 +2,7 @@ module Mutant
|
|||
class Mutator
|
||||
class Node
|
||||
class Send
|
||||
|
||||
# Mutator for sends that correspond to an attribute assignment
|
||||
# Mutator for attribute assignments
|
||||
class AttributeAssignment < self
|
||||
|
||||
private
|
||||
|
@ -42,7 +41,6 @@ module Mutant
|
|||
end
|
||||
|
||||
end # AttributeAssignment
|
||||
|
||||
end # Send
|
||||
end # Node
|
||||
end # Mutator
|
||||
|
|
|
@ -7,21 +7,6 @@ module Mutant
|
|||
# Base mutator for index operations
|
||||
class Index < self
|
||||
|
||||
# Mutator for index references
|
||||
class Reference < self
|
||||
|
||||
# Perform dispatch
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit(receiver)
|
||||
end
|
||||
|
||||
end # Reference
|
||||
|
||||
# Mutator for index assignments
|
||||
class Assign < self
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ Mutant::Meta::Example.add do
|
|||
mutation '@a.b += 0'
|
||||
mutation '@a.b += nil'
|
||||
mutation '@a.b += self'
|
||||
mutation 'nil.b += 1'
|
||||
mutation 'self.b += 1'
|
||||
# TODO: fix invalid AST
|
||||
# This should not get emitted as invalid AST with valid unparsed source
|
||||
|
|
|
@ -15,7 +15,6 @@ Mutant::Meta::Example.add do
|
|||
mutation '//' # match all
|
||||
mutation '/#{foo}n/'
|
||||
mutation '/a\A/' # match nothing
|
||||
mutation '/#{nil.bar}n/'
|
||||
mutation '/#{self.bar}n/'
|
||||
mutation '/#{nil}n/'
|
||||
mutation '/#{self}n/'
|
||||
|
|
56
meta/send.rb
56
meta/send.rb
|
@ -49,7 +49,6 @@ Mutant::Meta::Example.add do
|
|||
mutation 'foo.gsub(a, self)'
|
||||
mutation 'foo.gsub(nil, b)'
|
||||
mutation 'foo.gsub(self, b)'
|
||||
mutation 'nil.gsub(a, b)'
|
||||
mutation 'self.gsub(a, b)'
|
||||
end
|
||||
|
||||
|
@ -64,7 +63,6 @@ Mutant::Meta::Example.add do
|
|||
mutation 'self.send(bar)'
|
||||
mutation 'foo.send(nil)'
|
||||
mutation 'foo.send(self)'
|
||||
mutation 'nil.send(bar)'
|
||||
end
|
||||
|
||||
Mutant::Meta::Example.add do
|
||||
|
@ -76,7 +74,6 @@ Mutant::Meta::Example.add do
|
|||
mutation 'self.bar'
|
||||
mutation 'baz'
|
||||
# This one could probably be removed
|
||||
mutation 'nil.bar=baz'
|
||||
end
|
||||
|
||||
Mutant::Meta::Example.add do
|
||||
|
@ -90,7 +87,6 @@ Mutant::Meta::Example.add do
|
|||
mutation 'foo.bar'
|
||||
mutation 'baz'
|
||||
# This one could probably be removed
|
||||
mutation 'nil.bar = baz'
|
||||
end
|
||||
|
||||
Mutant::Meta::Example.add do
|
||||
|
@ -119,13 +115,6 @@ Mutant::Meta::Example.add do
|
|||
mutation 'foo'
|
||||
end
|
||||
|
||||
Mutant::Meta::Example.add do
|
||||
source 'foo[*bar]'
|
||||
|
||||
singleton_mutations
|
||||
mutation 'foo'
|
||||
end
|
||||
|
||||
Mutant::Meta::Example.add do
|
||||
source 'foo'
|
||||
|
||||
|
@ -137,7 +126,6 @@ Mutant::Meta::Example.add do
|
|||
|
||||
singleton_mutations
|
||||
mutation 'foo'
|
||||
mutation 'nil.foo'
|
||||
end
|
||||
|
||||
Unparser::Constants::KEYWORDS.each do |keyword|
|
||||
|
@ -145,7 +133,6 @@ Unparser::Constants::KEYWORDS.each do |keyword|
|
|||
source "self.#{keyword}"
|
||||
|
||||
singleton_mutations
|
||||
mutation "nil.#{keyword}"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -154,7 +141,6 @@ Mutant::Meta::Example.add do
|
|||
|
||||
singleton_mutations
|
||||
mutation 'foo'
|
||||
mutation 'nil.bar'
|
||||
mutation 'self.bar'
|
||||
end
|
||||
|
||||
|
@ -164,8 +150,6 @@ Mutant::Meta::Example.add do
|
|||
singleton_mutations
|
||||
mutation 'self.class'
|
||||
mutation 'self.foo'
|
||||
mutation 'nil.class.foo'
|
||||
mutation 'nil.foo'
|
||||
end
|
||||
|
||||
Mutant::Meta::Example.add do
|
||||
|
@ -181,7 +165,6 @@ Mutant::Meta::Example.add do
|
|||
singleton_mutations
|
||||
mutation 'self.foo'
|
||||
mutation 'foo(nil)'
|
||||
mutation 'nil.foo(nil)'
|
||||
end
|
||||
|
||||
Unparser::Constants::KEYWORDS.each do |keyword|
|
||||
|
@ -192,7 +175,6 @@ Unparser::Constants::KEYWORDS.each do |keyword|
|
|||
mutation "self.#{keyword}(nil)"
|
||||
mutation "foo.#{keyword}"
|
||||
mutation 'foo'
|
||||
mutation "nil.#{keyword}(nil)"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -222,6 +204,44 @@ Mutant::Meta::Example.add do
|
|||
mutation 'self / foo'
|
||||
end
|
||||
|
||||
Mutant::Meta::Example.add do
|
||||
source 'foo[1]'
|
||||
|
||||
singleton_mutations
|
||||
mutation '1'
|
||||
mutation 'foo'
|
||||
mutation 'foo[]'
|
||||
mutation 'self[1]'
|
||||
mutation 'foo[0]'
|
||||
mutation 'foo[2]'
|
||||
mutation 'foo[-1]'
|
||||
mutation 'foo[nil]'
|
||||
mutation 'foo[self]'
|
||||
end
|
||||
|
||||
Mutant::Meta::Example.add do
|
||||
source 'self.foo[]'
|
||||
|
||||
singleton_mutations
|
||||
mutation 'self.foo'
|
||||
mutation 'self[]'
|
||||
mutation 'foo[]'
|
||||
end
|
||||
|
||||
Mutant::Meta::Example.add do
|
||||
source 'foo[*bar]'
|
||||
|
||||
singleton_mutations
|
||||
mutation 'foo'
|
||||
mutation 'foo[]'
|
||||
mutation 'foo[nil]'
|
||||
mutation 'foo[self]'
|
||||
mutation 'foo[bar]'
|
||||
mutation 'foo[*self]'
|
||||
mutation 'foo[*nil]'
|
||||
mutation 'self[*bar]'
|
||||
end
|
||||
|
||||
(Mutant::BINARY_METHOD_OPERATORS - [:==, :eql?]).each do |operator|
|
||||
Mutant::Meta::Example.add do
|
||||
source "true #{operator} false"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue