diff --git a/Changelog.md b/Changelog.md index 6b90d635..93cfe8bb 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +# Master (unreleased) + +* Add mutation from `Hash#[]` to `Hash#key?` (#511) + # v0.8.8 2015-xx-xx * Drop support for rspec-3.2 diff --git a/lib/mutant/mutator/node/send.rb b/lib/mutant/mutator/node/send.rb index ea45d15c..2506b3ba 100644 --- a/lib/mutant/mutator/node/send.rb +++ b/lib/mutant/mutator/node/send.rb @@ -27,7 +27,7 @@ module Mutant to_a: %i[to_ary], to_h: %i[to_hash], at: %i[fetch], - :[] => %i[at fetch], + :[] => %i[at fetch key?], :== => %i[eql? equal?], :>= => %i[> == eql? equal?], :<= => %i[< == eql? equal?], diff --git a/meta/send.rb b/meta/send.rb index eac57517..4e7a37ed 100644 --- a/meta/send.rb +++ b/meta/send.rb @@ -405,6 +405,7 @@ Mutant::Meta::Example.add do mutation 'foo[]' mutation 'foo.at(1)' mutation 'foo.fetch(1)' + mutation 'foo.key?(1)' mutation 'self[1]' mutation 'foo[0]' mutation 'foo[2]' @@ -420,6 +421,7 @@ Mutant::Meta::Example.add do mutation 'self.foo' mutation 'self.foo.at()' mutation 'self.foo.fetch()' + mutation 'self.foo.key?()' mutation 'self[]' mutation 'foo[]' end @@ -433,6 +435,7 @@ Mutant::Meta::Example.add do mutation 'self[]' mutation 'self.at(foo)' mutation 'self.fetch(foo)' + mutation 'self.key?(foo)' mutation 'foo' end @@ -444,6 +447,7 @@ Mutant::Meta::Example.add do mutation 'foo[]' mutation 'foo.at(*bar)' mutation 'foo.fetch(*bar)' + mutation 'foo.key?(*bar)' mutation 'foo[nil]' mutation 'foo[self]' mutation 'foo[bar]'