Skip to content

Commit

Permalink
Remove integer literal negation mutation
Browse files Browse the repository at this point in the history
- Removes mutations of the form of `1` -> `-1`. These are unlikely to yield alive mutations and sometimes lead to frustrating, equivalent mutations.
  • Loading branch information
dgollahon committed Feb 6, 2021
1 parent 3c51af8 commit 371b86d
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 27 deletions.
9 changes: 3 additions & 6 deletions lib/mutant/mutator/node/literal/integer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class Integer < self

handle(:int)

children :value

private

def dispatch
Expand All @@ -17,12 +19,7 @@ def dispatch
end

def values
[0, 1, -value, value + 1, value - 1]
end

def value
value, = children
value
[0, 1, value + 1, value - 1]
end

end # Integer
Expand Down
1 change: 0 additions & 1 deletion meta/and_asgn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
mutation 'a__mutant__ &&= 1'
mutation 'a &&= nil'
mutation 'a &&= 0'
mutation 'a &&= -1'
mutation 'a &&= 2'
end
2 changes: 0 additions & 2 deletions meta/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
mutation 'self[1]'
mutation 'foo[0]'
mutation 'foo[2]'
mutation 'foo[-1]'
mutation 'foo[nil]'
end

Expand All @@ -43,7 +42,6 @@
mutation 'foo[nil]'
mutation 'foo[n..nil]'
mutation 'foo[n..-1]'
mutation 'foo[n..2]'
mutation 'foo[n..0]'
mutation 'foo[n..1]'
mutation 'foo[n..-3]'
Expand Down
3 changes: 0 additions & 3 deletions meta/int.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
mutation '0'
mutation '1'

# negative
mutation '-10'

# scalar boundary
mutation '9'
mutation '11'
Expand Down
1 change: 0 additions & 1 deletion meta/ivasgn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
mutation '@a__mutant__ &&= 1'
mutation '@a &&= nil'
mutation '@a &&= 0'
mutation '@a &&= -1'
mutation '@a &&= 2'
end
3 changes: 0 additions & 3 deletions meta/op_assgn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
singleton_mutations

mutation '@a += 1'
mutation '@a.b += -1'
mutation '@a.b += 0'
mutation '@a.b += 2'
mutation '@a.b += nil'
Expand All @@ -19,7 +18,6 @@

singleton_mutations

mutation 'a.b += -1'
mutation 'a.b += 0'
mutation 'a.b += 2'
mutation 'a.b += nil'
Expand All @@ -32,7 +30,6 @@
singleton_mutations

mutation 'b__mutant__ += 1'
mutation 'b += -1'
mutation 'b += 0'
mutation 'b += 2'
mutation 'b += nil'
Expand Down
3 changes: 0 additions & 3 deletions meta/or_asgn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
mutation 'a__mutant__ ||= 1'
mutation 'a ||= nil'
mutation 'a ||= 0'
mutation 'a ||= -1'
mutation 'a ||= 2'
end

Expand All @@ -17,7 +16,6 @@
singleton_mutations
mutation '@a ||= nil'
mutation '@a ||= 0'
mutation '@a ||= -1'
mutation '@a ||= 2'
end

Expand All @@ -42,6 +40,5 @@
singleton_mutations
mutation 'foo[:bar] ||= nil'
mutation 'foo[:bar] ||= 0'
mutation 'foo[:bar] ||= -1'
mutation 'foo[:bar] ||= 2'
end
6 changes: 0 additions & 6 deletions meta/range.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

singleton_mutations
mutation '1...100'
mutation '-1..100'
mutation '0..100'
mutation '2..100'
mutation 'nil..100'
Expand All @@ -14,15 +13,13 @@
mutation '1..1'
mutation '1..99'
mutation '1..101'
mutation '1..-100'
end

Mutant::Meta::Example.add :erange do
source '1...100'

singleton_mutations
mutation '1..100'
mutation '-1...100'
mutation '0...100'
mutation '2...100'
mutation 'nil...100'
Expand All @@ -31,15 +28,13 @@
mutation '1...1'
mutation '1...99'
mutation '1...101'
mutation '1...-100'
end

unless RUBY_VERSION.start_with?('2.5')
Mutant::Meta::Example.add :erange do
source '1...'

singleton_mutations
mutation '-1...'
mutation '0...'
mutation '2...'
mutation 'nil...'
Expand All @@ -49,7 +44,6 @@
source '1..'

singleton_mutations
mutation '-1..'
mutation '0..'
mutation '2..'
mutation 'nil..'
Expand Down
2 changes: 0 additions & 2 deletions meta/send.rb
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@
mutation 'foo.public_send(1, two: true, **kwargs, &block)'
mutation 'foo.public_send(:bar, nil, two: true, **kwargs, &block)'
mutation 'foo.public_send(:bar, 0, two: true, **kwargs, &block)'
mutation 'foo.public_send(:bar, -1, two: true, **kwargs, &block)'
mutation 'foo.public_send(:bar, 2, two: true, **kwargs, &block)'
mutation 'foo.public_send(:bar, two: true, **kwargs, &block)'
mutation 'foo.public_send(:bar, 1, two__mutant__: true, **kwargs, &block)'
Expand Down Expand Up @@ -738,7 +737,6 @@
mutation 'match?(/\Afoo/)'
mutation 'match?(1)'
mutation 'match?(/\Afoo/, nil)'
mutation 'match?(/\Afoo/, -1)'
mutation 'match?(/\Afoo/, 0)'
mutation 'match?(/\Afoo/, 2)'
mutation 'match?'
Expand Down

0 comments on commit 371b86d

Please sign in to comment.