diff --git a/Changelog.md b/Changelog.md index 3713a087b..5f82e32ec 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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) diff --git a/lib/mutant/meta/example/dsl.rb b/lib/mutant/meta/example/dsl.rb index 875251d0a..6cc5b1378 100644 --- a/lib/mutant/meta/example/dsl.rb +++ b/lib/mutant/meta/example/dsl.rb @@ -79,7 +79,6 @@ def mutation(input) def singleton_mutations mutation('nil') - mutation('self') end def regexp_mutations diff --git a/lib/mutant/mutator/node.rb b/lib/mutant/mutator/node.rb index e410736c9..00cd35a9f 100644 --- a/lib/mutant/mutator/node.rb +++ b/lib/mutant/mutator/node.rb @@ -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 diff --git a/lib/mutant/mutator/node/index.rb b/lib/mutant/mutator/node/index.rb index 9aefb58d4..833aaa204 100644 --- a/lib/mutant/mutator/node/index.rb +++ b/lib/mutant/mutator/node/index.rb @@ -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 diff --git a/lib/mutant/mutator/node/send.rb b/lib/mutant/mutator/node/send.rb index 386dec2f7..aa8f853ec 100644 --- a/lib/mutant/mutator/node/send.rb +++ b/lib/mutant/mutator/node/send.rb @@ -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) || diff --git a/meta/and_asgn.rb b/meta/and_asgn.rb index 852e5ef0e..221b61cde 100644 --- a/meta/and_asgn.rb +++ b/meta/and_asgn.rb @@ -10,5 +10,4 @@ mutation 'a &&= 0' mutation 'a &&= -1' mutation 'a &&= 2' - mutation 'a &&= self' end diff --git a/meta/block.rb b/meta/block.rb index ed67d067c..e32eb8e88 100644 --- a/meta/block.rb +++ b/meta/block.rb @@ -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 @@ -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) {}' @@ -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)' @@ -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 }' @@ -132,7 +125,6 @@ singleton_mutations mutation 'foo { nil }' mutation 'foo { raise }' - mutation 'foo { self }' mutation 'foo { break }' mutation 'foo { }' mutation 'foo' @@ -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 }' @@ -160,7 +150,6 @@ singleton_mutations mutation 'foo { nil }' mutation 'foo { raise }' - mutation 'foo { self }' mutation 'foo { }' mutation 'foo' end @@ -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 @@ -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 diff --git a/meta/block_pass.rb b/meta/block_pass.rb index 4d895fab7..c84a9f273 100644 --- a/meta/block_pass.rb +++ b/meta/block_pass.rb @@ -6,7 +6,6 @@ singleton_mutations mutation 'foo' mutation 'foo(&nil)' - mutation 'foo(&self)' end Mutant::Meta::Example.add :block_pass do @@ -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)' @@ -30,7 +27,6 @@ singleton_mutations mutation 'foo' mutation 'foo(&nil)' - mutation 'foo(&self)' mutation 'foo(&:to_str)' mutation 'foo(&:to_s__mutant__)' end @@ -41,6 +37,5 @@ singleton_mutations mutation 'foo' mutation 'foo(&nil)' - mutation 'foo(&self)' mutation 'foo(&:bar__mutant__)' end diff --git a/meta/case.rb b/meta/case.rb index 2f2bac828..b8dd0228d 100644 --- a/meta/case.rb +++ b/meta/case.rb @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/meta/class.rb b/meta/class.rb index 1ea5d48ba..b45a98f5c 100644 --- a/meta/class.rb +++ b/meta/class.rb @@ -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 diff --git a/meta/csend.rb b/meta/csend.rb index 5713c4628..9fb5e3103 100644 --- a/meta/csend.rb +++ b/meta/csend.rb @@ -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 diff --git a/meta/def.rb b/meta/def.rb index 4edfbab1e..6ca649e5f 100644 --- a/meta/def.rb +++ b/meta/def.rb @@ -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' @@ -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' @@ -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' diff --git a/meta/dstr.rb b/meta/dstr.rb index d4dd076fa..216a048f1 100644 --- a/meta/dstr.rb +++ b/meta/dstr.rb @@ -5,5 +5,4 @@ singleton_mutations mutation '"foo#{nil}baz"' - mutation '"foo#{self}baz"' end diff --git a/meta/dsym.rb b/meta/dsym.rb index e779d6166..447a41eb0 100644 --- a/meta/dsym.rb +++ b/meta/dsym.rb @@ -6,5 +6,4 @@ singleton_mutations mutation ':"foo#{nil}baz"' - mutation ':"foo#{self}baz"' end diff --git a/meta/index.rb b/meta/index.rb index 06bd69df3..6a8d0d54d 100644 --- a/meta/index.rb +++ b/meta/index.rb @@ -27,7 +27,6 @@ mutation 'foo[2]' mutation 'foo[-1]' mutation 'foo[nil]' - mutation 'foo[self]' end Mutant::Meta::Example.add :index do @@ -42,9 +41,7 @@ mutation 'foo.key?(n..-2)' mutation 'self[n..-2]' mutation 'foo[nil]' - mutation 'foo[self]' mutation 'foo[n..nil]' - mutation 'foo[n..self]' mutation 'foo[n..-1]' mutation 'foo[n..2]' mutation 'foo[n..0]' @@ -52,7 +49,6 @@ mutation 'foo[n..-3]' mutation 'foo[n...-2]' mutation 'foo[nil..-2]' - mutation 'foo[self..-2]' end Mutant::Meta::Example.add :index do @@ -67,15 +63,12 @@ mutation 'foo.key?(n...-1)' mutation 'self[n...-1]' mutation 'foo[nil]' - mutation 'foo[self]' mutation 'foo[n...nil]' - mutation 'foo[n...self]' mutation 'foo[n..-1]' mutation 'foo[n...0]' mutation 'foo[n...1]' mutation 'foo[n...-2]' mutation 'foo[nil...-1]' - mutation 'foo[self...-1]' end Mutant::Meta::Example.add :index do @@ -90,15 +83,12 @@ mutation 'foo.key?(n..-1)' mutation 'self[n..-1]' mutation 'foo[nil]' - mutation 'foo[self]' mutation 'foo[n..nil]' - mutation 'foo[n..self]' mutation 'foo[n..0]' mutation 'foo[n..1]' mutation 'foo[n..-2]' mutation 'foo[n...-1]' mutation 'foo[nil..-1]' - mutation 'foo[self..-1]' mutation 'foo.drop(n)' end @@ -106,7 +96,7 @@ source 'self[foo]' singleton_mutations - mutation 'self[self]' + mutation 'self' mutation 'self[nil]' mutation 'self[]' mutation 'self.at(foo)' @@ -125,9 +115,7 @@ mutation 'foo.fetch(*bar)' mutation 'foo.key?(*bar)' mutation 'foo[nil]' - mutation 'foo[self]' mutation 'foo[bar]' - mutation 'foo[*self]' mutation 'foo[*nil]' mutation 'self[*bar]' end diff --git a/meta/indexasgn.rb b/meta/indexasgn.rb index 05bcb6391..2a1b65769 100644 --- a/meta/indexasgn.rb +++ b/meta/indexasgn.rb @@ -10,10 +10,8 @@ mutation 'foo.at(bar)' mutation 'foo.fetch(bar)' mutation 'foo.key?(bar)' - mutation 'foo[bar] = self' mutation 'foo[bar] = nil' mutation 'foo[nil] = baz' - mutation 'foo[self] = baz' mutation 'foo[] = baz' mutation 'baz' mutation 'bar' @@ -25,7 +23,5 @@ singleton_mutations mutation 'self[] += bar' mutation 'self[nil] += bar' - mutation 'self[self] += bar' mutation 'self[foo] += nil' - mutation 'self[foo] += self' end diff --git a/meta/ivasgn.rb b/meta/ivasgn.rb index 9f53760ae..e24413579 100644 --- a/meta/ivasgn.rb +++ b/meta/ivasgn.rb @@ -18,5 +18,4 @@ mutation '@a &&= 0' mutation '@a &&= -1' mutation '@a &&= 2' - mutation '@a &&= self' end diff --git a/meta/kwoptarg.rb b/meta/kwoptarg.rb index dcb72a64d..7c729e6c6 100644 --- a/meta/kwoptarg.rb +++ b/meta/kwoptarg.rb @@ -7,7 +7,6 @@ mutation 'def foo(bar: baz); raise; end' mutation 'def foo(bar: baz); super; end' mutation 'def foo(bar: nil); end' - mutation 'def foo(bar: self); end' mutation 'def foo(bar:); end' mutation 'def foo(_bar: baz); end' end diff --git a/meta/lambda.rb b/meta/lambda.rb index b09c602f9..0eaf64371 100644 --- a/meta/lambda.rb +++ b/meta/lambda.rb @@ -14,7 +14,6 @@ singleton_mutations mutation '->() { }' - mutation '->() { self }' mutation '->() { nil }' mutation '->() { raise }' mutation '->() { self.bar }' diff --git a/meta/lvar.rb b/meta/lvar.rb index 2498f1de5..3932cf18b 100644 --- a/meta/lvar.rb +++ b/meta/lvar.rb @@ -6,5 +6,4 @@ source 'a' mutation 'nil' - mutation 'self' end diff --git a/meta/lvasgn.rb b/meta/lvasgn.rb index 87ce862bd..3ddaffbf0 100644 --- a/meta/lvasgn.rb +++ b/meta/lvasgn.rb @@ -14,11 +14,8 @@ singleton_mutations mutation 'a__mutant__ = *b' mutation 'a = nil' - mutation 'a = self' mutation 'a = []' mutation 'a = [nil]' - mutation 'a = [self]' - mutation 'a = [*self]' mutation 'a = [*nil]' mutation 'a = [b]' end diff --git a/meta/op_assgn.rb b/meta/op_assgn.rb index a6250dfec..d79fc726c 100644 --- a/meta/op_assgn.rb +++ b/meta/op_assgn.rb @@ -10,7 +10,6 @@ mutation '@a.b += 0' mutation '@a.b += 2' mutation '@a.b += nil' - mutation '@a.b += self' mutation 'a.b += 1' mutation 'self.b += 1' end @@ -24,7 +23,6 @@ mutation 'a.b += 0' mutation 'a.b += 2' mutation 'a.b += nil' - mutation 'a.b += self' mutation 'self.b += 1' end @@ -38,5 +36,4 @@ mutation 'b += 0' mutation 'b += 2' mutation 'b += nil' - mutation 'b += self' end diff --git a/meta/or_asgn.rb b/meta/or_asgn.rb index 02cfc43b4..bd88e72fa 100644 --- a/meta/or_asgn.rb +++ b/meta/or_asgn.rb @@ -6,7 +6,6 @@ singleton_mutations mutation 'a__mutant__ ||= 1' mutation 'a ||= nil' - mutation 'a ||= self' mutation 'a ||= 0' mutation 'a ||= -1' mutation 'a ||= 2' @@ -17,7 +16,6 @@ singleton_mutations mutation '@a ||= nil' - mutation '@a ||= self' mutation '@a ||= 0' mutation '@a ||= -1' mutation '@a ||= 2' @@ -43,7 +41,6 @@ singleton_mutations mutation 'foo[:bar] ||= nil' - mutation 'foo[:bar] ||= self' mutation 'foo[:bar] ||= 0' mutation 'foo[:bar] ||= -1' mutation 'foo[:bar] ||= 2' diff --git a/meta/range.rb b/meta/range.rb index c77d08cd3..ba08c6abb 100644 --- a/meta/range.rb +++ b/meta/range.rb @@ -9,9 +9,7 @@ mutation '0..100' mutation '2..100' mutation 'nil..100' - mutation 'self..100' mutation '1..nil' - mutation '1..self' mutation '1..0' mutation '1..1' mutation '1..99' @@ -28,9 +26,7 @@ mutation '0...100' mutation '2...100' mutation 'nil...100' - mutation 'self...100' mutation '1...nil' - mutation '1...self' mutation '1...0' mutation '1...1' mutation '1...99' @@ -47,7 +43,6 @@ mutation '0...' mutation '2...' mutation 'nil...' - mutation 'self...' end Mutant::Meta::Example.add :irange do @@ -58,6 +53,5 @@ mutation '0..' mutation '2..' mutation 'nil..' - mutation 'self..' end end diff --git a/meta/regexp.rb b/meta/regexp.rb index 617085653..285b96cd6 100644 --- a/meta/regexp.rb +++ b/meta/regexp.rb @@ -16,7 +16,6 @@ mutation '/#{foo}n/' mutation '/#{self.bar}n/' mutation '/#{nil}n/' - mutation '/#{self}n/' end Mutant::Meta::Example.add :regexp do @@ -25,7 +24,6 @@ singleton_mutations regexp_mutations - mutation '/#{self}/' mutation '/#{nil}/' end @@ -36,7 +34,6 @@ regexp_mutations mutation '/#{nil}#{nil}/' - mutation '/#{self}#{nil}/' end Mutant::Meta::Example.add :regexp do diff --git a/meta/regexp/regexp_bos_anchor.rb b/meta/regexp/regexp_bos_anchor.rb index 7f46aed01..b49b40b9c 100644 --- a/meta/regexp/regexp_bos_anchor.rb +++ b/meta/regexp/regexp_bos_anchor.rb @@ -14,5 +14,4 @@ regexp_mutations mutation '/^#{nil}/' - mutation '/^#{self}/' end diff --git a/meta/rescue.rb b/meta/rescue.rb index 941a16a0b..83bb824f7 100644 --- a/meta/rescue.rb +++ b/meta/rescue.rb @@ -5,8 +5,6 @@ singleton_mutations 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; true; end' @@ -18,7 +16,6 @@ singleton_mutations mutation 'begin; rescue SomeException; true; end' mutation 'begin; rescue SomeException => error; false; end' - mutation 'begin; rescue self => error; true; end' mutation 'begin; true; end' end @@ -51,11 +48,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' diff --git a/meta/return.rb b/meta/return.rb index e879297db..3c603222a 100644 --- a/meta/return.rb +++ b/meta/return.rb @@ -12,5 +12,4 @@ singleton_mutations mutation 'foo' mutation 'return nil' - mutation 'return self' end diff --git a/meta/sclass.rb b/meta/sclass.rb index 12c44ebb7..5b5eb68f4 100644 --- a/meta/sclass.rb +++ b/meta/sclass.rb @@ -4,7 +4,6 @@ source 'class << self; bar; end' mutation 'class << self; nil; end' - mutation 'class << self; self; end' end Mutant::Meta::Example.add :sclass do diff --git a/meta/send.rb b/meta/send.rb index ddf530e42..988b075a4 100644 --- a/meta/send.rb +++ b/meta/send.rb @@ -8,9 +8,7 @@ mutation 'a.eql?(b)' mutation 'a.equal?(b)' mutation 'nil > b' - mutation 'self > b' mutation 'a > nil' - mutation 'a > self' mutation 'a' mutation 'b' end @@ -24,7 +22,6 @@ mutation 'A' mutation ':B' mutation 'A.const_get(nil)' - mutation 'A.const_get(self)' mutation 'A.const_get(:B__mutant__)' mutation 'self.const_get(:B)' end @@ -37,7 +34,6 @@ mutation 'A' mutation 'bar' mutation 'A.const_get(nil)' - mutation 'A.const_get(self)' mutation 'self.const_get(bar)' end @@ -49,7 +45,6 @@ mutation 'method' mutation 'bar' mutation 'method(nil)' - mutation 'method(self)' end Mutant::Meta::Example.add :send do @@ -61,9 +56,7 @@ mutation 'a.eql?(b)' mutation 'a.equal?(b)' mutation 'nil >= b' - mutation 'self >= b' mutation 'a >= nil' - mutation 'a >= self' mutation 'a' mutation 'b' end @@ -77,9 +70,7 @@ mutation 'a.eql?(b)' mutation 'a.equal?(b)' mutation 'nil <= b' - mutation 'self <= b' mutation 'a <= nil' - mutation 'a <= self' mutation 'a' mutation 'b' end @@ -92,9 +83,7 @@ mutation 'a.eql?(b)' mutation 'a.equal?(b)' mutation 'nil < b' - mutation 'self < b' mutation 'a < nil' - mutation 'a < self' mutation 'a' mutation 'b' end @@ -197,9 +186,7 @@ mutation 'foo' mutation 'bar' mutation 'nil == bar' - mutation 'self == bar' mutation 'foo == nil' - mutation 'foo == self' mutation 'foo.eql?(bar)' mutation 'foo.equal?(bar)' end @@ -212,7 +199,6 @@ mutation 'bar' mutation 'foo.is_a?' mutation 'foo.is_a?(nil)' - mutation 'foo.is_a?(self)' mutation 'self.is_a?(bar)' mutation 'foo.instance_of?(bar)' mutation 'false' @@ -227,7 +213,6 @@ mutation 'bar' mutation 'foo.kind_of?' mutation 'foo.kind_of?(nil)' - mutation 'foo.kind_of?(self)' mutation 'self.kind_of?(bar)' mutation 'foo.instance_of?(bar)' mutation 'false' @@ -244,9 +229,7 @@ mutation 'foo.gsub' mutation 'foo.sub(a, b)' mutation 'foo.gsub(a, nil)' - mutation 'foo.gsub(a, self)' mutation 'foo.gsub(nil, b)' - mutation 'foo.gsub(self, b)' mutation 'self.gsub(a, b)' end @@ -260,9 +243,7 @@ mutation 'foo.values_at(a)' mutation 'foo.values_at(b)' mutation 'foo.values_at(nil, b)' - mutation 'foo.values_at(self, b)' mutation 'foo.values_at(a, nil)' - mutation 'foo.values_at(a, self)' mutation 'foo.values_at' end @@ -276,9 +257,7 @@ mutation 'foo.dig(a)' mutation 'foo.dig(b)' mutation 'foo.dig(nil, b)' - mutation 'foo.dig(self, b)' mutation 'foo.dig(a, nil)' - mutation 'foo.dig(a, self)' mutation 'foo.dig' end @@ -290,7 +269,6 @@ mutation 'foo' mutation 'self.dig(a)' mutation 'foo.dig(nil)' - mutation 'foo.dig(self)' mutation 'foo.dig' mutation 'a' end @@ -313,7 +291,6 @@ mutation 'foo' mutation 'self.__send__(bar)' mutation 'foo.__send__(nil)' - mutation 'foo.__send__(self)' end Mutant::Meta::Example.add :send do @@ -325,7 +302,6 @@ mutation 'public_send(:foo)' mutation ':foo' mutation '__send__(nil)' - mutation '__send__(self)' mutation '__send__(:foo__mutant__)' end @@ -341,7 +317,6 @@ mutation ':bar' mutation 'self.send(:bar)' mutation 'foo.send(nil)' - mutation 'foo.send(self)' mutation 'foo.send(:bar__mutant__)' end @@ -354,22 +329,19 @@ mutation 'public_send' end -Mutant::Meta::Example.add :send do # rubocop:disable Metrics/BlockLength +Mutant::Meta::Example.add :send do source 'foo.public_send(:bar, 1, two: true, **kwargs, &block)' singleton_mutations mutation 'foo.public_send(:bar, 1, two: true, **kwargs, &nil)' - mutation 'foo.public_send(:bar, 1, two: true, **kwargs, &self)' mutation 'foo.bar(1, two: true, **kwargs, &block)' mutation 'foo' mutation 'self.public_send(:bar, 1, two: true, **kwargs, &block)' mutation 'foo.public_send' mutation 'foo.public_send(nil, 1, two: true, **kwargs, &block)' - mutation 'foo.public_send(self, 1, two: true, **kwargs, &block)' mutation 'foo.public_send(:bar__mutant__, 1, two: true, **kwargs, &block)' mutation 'foo.public_send(1, two: true, **kwargs, &block)' mutation 'foo.public_send(:bar, nil, two: true, **kwargs, &block)' - mutation 'foo.public_send(:bar, self, 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)' @@ -378,7 +350,6 @@ mutation 'foo.public_send(:bar, 1, two: false, **kwargs, &block)' mutation 'foo.public_send(:bar, 1, **kwargs, &block)' mutation 'foo.public_send(:bar, 1, two: true, **nil, &block)' - mutation 'foo.public_send(:bar, 1, two: true, **self, &block)' mutation 'foo.public_send(:bar, 1, two: true, &block)' mutation 'foo.public_send(:bar, 1, &block)' mutation 'foo.public_send(:bar, 1, two: true, **kwargs)' @@ -395,15 +366,14 @@ mutation 'foo' mutation 'self.send(bar)' mutation 'foo.send(nil)' - mutation 'foo.send(self)' end Mutant::Meta::Example.add :send do source 'self.booz = baz' singleton_mutations + mutation 'self' mutation 'self.booz = nil' - mutation 'self.booz = self' mutation 'self.booz' mutation 'baz' end @@ -414,7 +384,6 @@ singleton_mutations mutation 'foo' mutation 'foo.booz = nil' - mutation 'foo.booz = self' mutation 'self.booz = baz' mutation 'foo.booz' mutation 'baz' @@ -427,9 +396,7 @@ mutation 'foo' mutation 'foo(nil)' mutation 'foo(bar)' - mutation 'foo(self)' mutation 'foo(*nil)' - mutation 'foo(*self)' end Mutant::Meta::Example.add :send do @@ -438,7 +405,6 @@ singleton_mutations mutation 'foo' mutation 'foo(&nil)' - mutation 'foo(&self)' end Mutant::Meta::Example.add :send do @@ -451,6 +417,7 @@ source 'self.foo' singleton_mutations + mutation 'self' mutation 'foo' end @@ -459,6 +426,7 @@ source "self.#{keyword}" singleton_mutations + mutation 'self' end end @@ -489,6 +457,7 @@ source 'self.foo(nil)' singleton_mutations + mutation 'self' mutation 'self.foo' mutation 'foo(nil)' end @@ -497,6 +466,7 @@ source 'self.fetch(nil)' singleton_mutations + mutation 'self' mutation 'self.fetch' mutation 'fetch(nil)' mutation 'self.key?(nil)' @@ -530,13 +500,9 @@ mutation '(left) / foo' mutation '(right) / foo' mutation '(left - right) / nil' - mutation '(left - right) / self' mutation '(left - nil) / foo' - mutation '(left - self) / foo' mutation '(nil - right) / foo' - mutation '(self - right) / foo' mutation '(nil) / foo' - mutation '(self) / foo' end Mutant::Meta::Example.add :send do @@ -546,12 +512,9 @@ mutation 'foo' mutation 'n..-1' mutation 'foo(nil)' - mutation 'foo(self)' mutation 'foo(n...-1)' mutation 'foo(nil..-1)' - mutation 'foo(self..-1)' mutation 'foo(n..nil)' - mutation 'foo(n..self)' mutation 'foo(n..0)' mutation 'foo(n..1)' mutation 'foo(n..-2)' @@ -574,11 +537,9 @@ singleton_mutations mutation 'nil != b' - mutation 'self != b' mutation 'a' mutation 'b' mutation 'a != nil' - mutation 'a != self' mutation '!a.eql?(b)' mutation '!a.equal?(b)' end @@ -588,8 +549,6 @@ singleton_mutations mutation '!foo' - mutation '!self' - mutation '!!self' mutation 'foo' end @@ -598,7 +557,6 @@ singleton_mutations mutation 'foo' - mutation '!self' end Mutant::Meta::Example.add :send do @@ -606,9 +564,7 @@ singleton_mutations mutation 'foo&.!' - mutation '!self' mutation '!foo' - mutation '!self&.!' mutation '!!foo' end @@ -647,7 +603,6 @@ singleton_mutations mutation 'a' mutation 'nil =~ //' - mutation 'self =~ //' mutation '//' mutation 'a =~ /nomatch\A/' mutation 'a.match?(//)' @@ -658,9 +613,9 @@ singleton_mutations mutation 'a' + mutation 'self.match(a)' mutation '//.match' mutation '//.match(nil)' - mutation '//.match(self)' mutation '//' mutation '/nomatch\A/.match(a)' mutation '//.match?(a)' @@ -676,7 +631,6 @@ mutation 'foo(bar { raise })' mutation 'foo(bar {})' mutation 'foo(bar)' - mutation 'foo(self)' mutation 'foo(nil)' end @@ -687,7 +641,6 @@ mutation 'a' mutation 'Array()' mutation 'Array(nil)' - mutation 'Array(self)' mutation '[a]' end @@ -700,7 +653,6 @@ mutation 'self.Array(a)' mutation 'Kernel.Array' mutation 'Kernel.Array(nil)' - mutation 'Kernel.Array(self)' mutation '[a]' end @@ -713,7 +665,6 @@ mutation 'foo' mutation 'foo.Array' mutation 'foo.Array(nil)' - mutation 'foo.Array(self)' end Mutant::Meta::Example.add :send do @@ -733,9 +684,7 @@ mutation 'a' mutation 'b' mutation 'nil === b' - mutation 'self === b' mutation 'a === nil' - mutation 'a === self' mutation 'a.is_a?(b)' end @@ -775,7 +724,6 @@ mutation 'a' mutation 'nil =~ /\Afoo/' - mutation 'self =~ /\Afoo/' mutation '/\Afoo/' mutation 'a =~ //' mutation 'a =~ /nomatch\A/' @@ -790,7 +738,6 @@ mutation 'match?(/\Afoo/)' mutation 'match?(1)' mutation 'match?(/\Afoo/, nil)' - mutation 'match?(/\Afoo/, self)' mutation 'match?(/\Afoo/, -1)' mutation 'match?(/\Afoo/, 0)' mutation 'match?(/\Afoo/, 2)' @@ -826,3 +773,9 @@ mutation 'self.match(/foo\z/)' mutation "a.end_with?('foo')" end + +Mutant::Meta::Example.add :send do + source 'nil.to_f' + + mutation 'nil' +end diff --git a/meta/super.rb b/meta/super.rb index 1f1b3ba7d..e6243f5c6 100644 --- a/meta/super.rb +++ b/meta/super.rb @@ -21,7 +21,5 @@ mutation 'super(foo)' mutation 'super(bar)' mutation 'super(foo, nil)' - mutation 'super(foo, self)' mutation 'super(nil, bar)' - mutation 'super(self, bar)' end diff --git a/meta/until.rb b/meta/until.rb index 4663afd05..5f6bc4b91 100644 --- a/meta/until.rb +++ b/meta/until.rb @@ -9,8 +9,6 @@ mutation 'until true; end' mutation 'until false; 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 diff --git a/meta/while.rb b/meta/while.rb index 3ec557b01..337b6eb52 100644 --- a/meta/while.rb +++ b/meta/while.rb @@ -4,8 +4,6 @@ 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; foo; end' mutation 'while true; end' diff --git a/spec/unit/mutant/meta/example/dsl_spec.rb b/spec/unit/mutant/meta/example/dsl_spec.rb index a5216e61b..ff9c281fe 100644 --- a/spec/unit/mutant/meta/example/dsl_spec.rb +++ b/spec/unit/mutant/meta/example/dsl_spec.rb @@ -82,10 +82,6 @@ def self.expect_error(message, &block) Mutant::Meta::Example::Expected.new( node: s(:nil), original_source: 'nil' - ), - Mutant::Meta::Example::Expected.new( - node: s(:self), - original_source: 'self' ) ] end