Merge pull request #511 from mbj/feature/key-predicate-mutations

Add mutations from `Hash#[]` and `Hash#fetch` to `Hash#key?`
This commit is contained in:
Markus Schirp 2016-01-02 17:39:08 +00:00
commit c87715b441
3 changed files with 22 additions and 2 deletions

View file

@ -1,3 +1,9 @@
# Master (unreleased)
* Add mutation from `Hash#[]` to `Hash#key?` (#511)
* Add mutation from `Hash#fetch` to `Hash#key?` (#511)
* Add mutation from `#at` to `#key?` (#511)
# v0.8.8 2015-xx-xx
* Drop support for rspec-3.2

View file

@ -26,8 +26,9 @@ module Mutant
to_i: %i[to_int],
to_a: %i[to_ary],
to_h: %i[to_hash],
at: %i[fetch],
:[] => %i[at fetch],
at: %i[fetch key?],
fetch: %i[key?],
:[] => %i[at fetch key?],
:== => %i[eql? equal?],
:>= => %i[> == eql? equal?],
:<= => %i[< == eql? equal?],

View file

@ -359,6 +359,15 @@ Mutant::Meta::Example.add do
mutation 'foo(nil)'
end
Mutant::Meta::Example.add do
source 'self.fetch(nil)'
singleton_mutations
mutation 'self.fetch'
mutation 'fetch(nil)'
mutation 'self.key?(nil)'
end
Unparser::Constants::KEYWORDS.each do |keyword|
Mutant::Meta::Example.add do
source "foo.#{keyword}(nil)"
@ -405,6 +414,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 +430,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 +444,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 +456,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]'