Skip to content

Commit

Permalink
Fix mutation to invalid hash pattern
Browse files Browse the repository at this point in the history
[fix #1417]
  • Loading branch information
mbj committed Feb 9, 2024
1 parent 42c0dad commit a756dae
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/mutant/mutator/node/literal/hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class Pair < Node
private

def dispatch
emit_key_mutations
emit_key_mutations do |mutation|
!mutation.eql?(s(:nil))
end
emit_value_mutations
end

Expand Down
14 changes: 14 additions & 0 deletions meta/case.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# frozen_string_literal: true

Mutant::Meta::Example.add :case do
source <<-RUBY
case nil
in { a: nil }
end
RUBY

mutation <<~RUBY
case nil
in {a__mutant__: nil}
end
RUBY
end

Mutant::Meta::Example.add :case do
source <<-RUBY
case
Expand Down
1 change: 0 additions & 1 deletion meta/def.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@
mutation 'def foo(**); { ** }; end'
mutation 'def foo(**); { default: nil }; end'
mutation 'def foo(**); { default__mutant__: nil, ** }; end'
mutation 'def foo(**); { nil => nil, ** }; end'
mutation 'def foo(**); {}; end'
end

Expand Down

0 comments on commit a756dae

Please sign in to comment.