Skip to content

Commit

Permalink
Merge pull request #1210 from mbj/remove-mutation-to-self
Browse files Browse the repository at this point in the history
Remove generic mutation to `self`
  • Loading branch information
dgollahon authored Jan 16, 2021
2 parents 75f2b8a + 39573e8 commit 2893344
Show file tree
Hide file tree
Showing 34 changed files with 27 additions and 213 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Unreleased

* [#1210](https://github.com/mbj/mutant/pull/1210)
* Remove generic mutation to `self`

# v0.10.26 2021-01-16

* [#1201](https://github.com/mbj/mutant/pull/1201)
Expand Down
1 change: 0 additions & 1 deletion lib/mutant/meta/example/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def mutation(input)

def singleton_mutations
mutation('nil')
mutation('self')
end

def regexp_mutations
Expand Down
5 changes: 0 additions & 5 deletions lib/mutant/mutator/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ def emit_propagation(node)

def emit_singletons
emit_nil
emit_self
end

def emit_self
emit(N_SELF)
end

def emit_nil
Expand Down
1 change: 1 addition & 0 deletions lib/mutant/mutator/node/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Index < self
def dispatch
emit_singletons
emit_receiver_mutations { |node| !n_nil?(node) }
emit_type(N_SELF, *children.drop(1))
emit(receiver)
emit_send_forms
emit_drop_mutation
Expand Down
7 changes: 7 additions & 0 deletions lib/mutant/mutator/node/send.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,18 @@ def emit_argument_propagation
def mutate_receiver
return unless receiver
emit_implicit_self
emit_explicit_self
emit_receiver_mutations do |node|
!n_nil?(node)
end
end

def emit_explicit_self
return if UNARY_METHOD_OPERATORS.include?(selector)

emit_receiver(N_SELF) unless n_nil?(receiver)
end

def emit_implicit_self
emit_receiver(nil) if n_self?(receiver) && !(
KEYWORDS.include?(selector) ||
Expand Down
1 change: 0 additions & 1 deletion meta/and_asgn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@
mutation 'a &&= 0'
mutation 'a &&= -1'
mutation 'a &&= 2'
mutation 'a &&= self'
end
13 changes: 0 additions & 13 deletions meta/block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
mutation 'foo {}'
mutation 'foo { raise }'
mutation 'foo { a; nil }'
mutation 'foo { a; self }'
mutation 'foo { nil; b }'
mutation 'foo { self; b }'
mutation 'foo'
mutation 'a; b'
end
Expand Down Expand Up @@ -51,8 +49,6 @@
singleton_mutations
mutation 'foo(a, nil) {}'
mutation 'foo(nil, b) {}'
mutation 'foo(self, b) {}'
mutation 'foo(a, self) {}'
mutation 'foo(a, b)'
mutation 'foo(a, b) { raise }'
mutation 'foo(a) {}'
Expand Down Expand Up @@ -87,7 +83,6 @@
mutation 'foo { bar }'
mutation 'foo { nil }'
mutation 'foo {}'
mutation 'foo { self }'
mutation 'foo { raise }'
mutation 'foo.bar(nil)'
mutation 'bar(nil)'
Expand Down Expand Up @@ -115,10 +110,8 @@
singleton_mutations
mutation 'foo'
mutation 'foo { }'
mutation 'foo { self }'
mutation 'foo { nil }'
mutation 'foo { raise }'
mutation 'foo { self if true }'
mutation 'foo { nil if true }'
mutation 'foo { break if true }'
mutation 'foo { next if !true }'
Expand All @@ -132,7 +125,6 @@
singleton_mutations
mutation 'foo { nil }'
mutation 'foo { raise }'
mutation 'foo { self }'
mutation 'foo { break }'
mutation 'foo { }'
mutation 'foo'
Expand All @@ -144,10 +136,8 @@
singleton_mutations
mutation 'foo'
mutation 'foo { }'
mutation 'foo { self }'
mutation 'foo { nil }'
mutation 'foo { raise }'
mutation 'foo { self if true }'
mutation 'foo { nil if true }'
mutation 'foo { break if !true }'
mutation 'foo { break if false }'
Expand All @@ -160,7 +150,6 @@
singleton_mutations
mutation 'foo { nil }'
mutation 'foo { raise }'
mutation 'foo { self }'
mutation 'foo { }'
mutation 'foo'
end
Expand All @@ -175,7 +164,6 @@
mutation 'foo(&:bar).baz'
mutation 'self.baz {}'
mutation 'foo(&nil).baz {}'
mutation 'foo(&self).baz {}'
mutation 'foo(&:bar__mutant__).baz {}'
end

Expand All @@ -190,7 +178,6 @@
mutation 'self.baz { }'
mutation 'foo(nil, &:bar).baz'

mutation 'foo(nil, &self).baz {}'
mutation 'foo(nil, &nil).baz {}'
mutation 'foo(nil, &:bar__mutant__).baz {}'
end
Expand Down
5 changes: 0 additions & 5 deletions meta/block_pass.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
singleton_mutations
mutation 'foo'
mutation 'foo(&nil)'
mutation 'foo(&self)'
end

Mutant::Meta::Example.add :block_pass do
Expand All @@ -15,10 +14,8 @@
singleton_mutations
mutation 'foo'
mutation 'foo(&nil)'
mutation 'foo(&self)'
mutation 'foo(&method)'
mutation 'foo(&method(nil))'
mutation 'foo(&method(self))'
mutation 'foo(&method(:bar__mutant__))'
mutation 'foo(&public_method(:bar))'
mutation 'foo(&:bar)'
Expand All @@ -30,7 +27,6 @@
singleton_mutations
mutation 'foo'
mutation 'foo(&nil)'
mutation 'foo(&self)'
mutation 'foo(&:to_str)'
mutation 'foo(&:to_s__mutant__)'
end
Expand All @@ -41,6 +37,5 @@
singleton_mutations
mutation 'foo'
mutation 'foo(&nil)'
mutation 'foo(&self)'
mutation 'foo(&:bar__mutant__)'
end
60 changes: 0 additions & 60 deletions meta/case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,6 @@
end
RUBY

mutation <<-RUBY
case self
when A
when B, C
C
else
D
end
RUBY

mutation <<-RUBY
case condition
when A
Expand All @@ -80,16 +70,6 @@
end
RUBY

mutation <<-RUBY
case condition
when self
when B, C
C
else
D
end
RUBY

mutation <<-RUBY
case condition
when B, C
Expand All @@ -109,16 +89,6 @@
end
RUBY

mutation <<-RUBY
case condition
when A
when B, C
self
else
D
end
RUBY

mutation <<-RUBY
case condition
when A
Expand All @@ -139,16 +109,6 @@
end
RUBY

mutation <<-RUBY
case condition
when A
when self, C
C
else
D
end
RUBY

mutation <<-RUBY
case condition
when A
Expand All @@ -169,16 +129,6 @@
end
RUBY

mutation <<-RUBY
case condition
when A
when B, self
C
else
D
end
RUBY

mutation <<-RUBY
case condition
when A
Expand All @@ -197,16 +147,6 @@
end
RUBY

mutation <<-RUBY
case condition
when A
when B, C
C
else
self
end
RUBY

mutation <<-RUBY
case condition
when A
Expand Down
1 change: 0 additions & 1 deletion meta/class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
source 'class Foo; bar; end'

mutation 'class Foo; nil; end'
mutation 'class Foo; self; end'
end

Mutant::Meta::Example.add :class do
Expand Down
1 change: 0 additions & 1 deletion meta/csend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
mutation 'a&.public_send'
mutation 'a&.public_send(:b__mutant__)'
mutation 'a&.public_send(nil)'
mutation 'a&.public_send(self)'
mutation 'self&.public_send(:b)'
mutation 'a&.b'
end
6 changes: 0 additions & 6 deletions meta/def.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

mutation 'def foo; raise; end'
mutation 'def foo; nil; rescue; end'
mutation 'def foo; self; rescue; end'
mutation 'def foo; end'
mutation 'def foo; super; end'

Expand All @@ -25,11 +24,8 @@

# Mutate all bodies
mutation 'def a; nil; rescue; bar; else; baz; end'
mutation 'def a; self; rescue; bar; else; baz; end'
mutation 'def a; foo; rescue; nil; else; baz; end'
mutation 'def a; foo; rescue; self; else; baz; end'
mutation 'def a; foo; rescue; bar; else; nil; end'
mutation 'def a; foo; rescue; bar; else; self; end'

# Promote and concat rescue resbody bodies
mutation 'def a; foo; bar; end'
Expand Down Expand Up @@ -128,10 +124,8 @@
mutation 'def foo(_a = 0, b = 0); end'
mutation 'def foo(a = 0, b = 1); end'
mutation 'def foo(a = 0, b = -1); end'
mutation 'def foo(a = 0, b = self); end'
mutation 'def foo(a = 0, b = nil); end'
mutation 'def foo(a = -1, b = 0); end'
mutation 'def foo(a = self, b = 0); end'
mutation 'def foo(a = nil, b = 0); end'
mutation 'def foo(a = 1, b = 0); end'
mutation 'def foo(a = 0); end'
Expand Down
1 change: 0 additions & 1 deletion meta/dstr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@

singleton_mutations
mutation '"foo#{nil}baz"'
mutation '"foo#{self}baz"'
end
1 change: 0 additions & 1 deletion meta/dsym.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
singleton_mutations

mutation ':"foo#{nil}baz"'
mutation ':"foo#{self}baz"'
end
Loading

0 comments on commit 2893344

Please sign in to comment.