From a92eb9b45c1a0657cc26c2ec7e6784e97582a883 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sun, 17 Jan 2021 09:53:49 +0500 Subject: [PATCH] Upgrade dependency "parser" and fix code --- Gemfile.lock | 12 ++++++------ lib/mutant/mutator/node/arguments.rb | 4 +--- lib/mutant/mutator/node/procarg_zero.rb | 25 ++----------------------- meta/block.rb | 2 -- mutant.gemspec | 4 ++-- 5 files changed, 11 insertions(+), 36 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index aa8725d7..071265af 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -12,9 +12,9 @@ PATH ice_nine (~> 0.11.1) memoizable (~> 0.4.2) morpher (~> 0.2.6) - parser (~> 2.5.1) + parser (~> 2.7.2) procto (~> 0.0.2) - regexp_parser (~> 1.7, >= 1.7.1) + regexp_parser (~> 1.8.2) unparser (~> 0.4.2) mutant-rspec (0.8.24) mutant (~> 0.8.24) @@ -97,8 +97,8 @@ GEM ice_nine (~> 0.11.0) procto (~> 0.0.2) parallel (1.12.1) - parser (2.5.3.0) - ast (~> 2.4.0) + parser (2.7.2.0) + ast (~> 2.4.1) path_expander (1.1.0) powerpack (0.1.3) procto (0.0.3) @@ -147,13 +147,13 @@ GEM simplecov-html (0.10.2) thread_safe (0.3.6) unicode-display_width (1.4.1) - unparser (0.4.2) + unparser (0.4.7) abstract_type (~> 0.0.7) adamantium (~> 0.2.0) concord (~> 0.1.5) diff-lcs (~> 1.3) equalizer (~> 0.0.9) - parser (>= 2.3.1.2, < 2.6) + parser (>= 2.6.5) procto (~> 0.0.2) virtus (1.0.5) axiom-types (~> 0.1) diff --git a/lib/mutant/mutator/node/arguments.rb b/lib/mutant/mutator/node/arguments.rb index a0b03f8f..1bffcb01 100644 --- a/lib/mutant/mutator/node/arguments.rb +++ b/lib/mutant/mutator/node/arguments.rb @@ -26,9 +26,7 @@ module Mutant emit_type Util::Array::Presence.call(children).each do |children| - if children.one? && n_mlhs?(Mutant::Util.one(children)) - emit_procarg(Mutant::Util.one(children)) - else + unless children.one? && n_mlhs?(children.first) emit_type(*children) end end diff --git a/lib/mutant/mutator/node/procarg_zero.rb b/lib/mutant/mutator/node/procarg_zero.rb index da120de5..fc9ea58f 100644 --- a/lib/mutant/mutator/node/procarg_zero.rb +++ b/lib/mutant/mutator/node/procarg_zero.rb @@ -4,13 +4,6 @@ module Mutant class Mutator class Node class ProcargZero < self - MAP = { - ::Parser::AST::Node => :emit_argument_node_mutations, - Symbol => :emit_argument_symbol_mutations - }.freeze - - private_constant(*constants(false)) - handle :procarg0 children :argument @@ -21,23 +14,9 @@ module Mutant # # @return [undefined] def dispatch - __send__(MAP.fetch(argument.class)) - end + name = Mutant::Util.one(argument.children) - # Emit argument symbol mutations - # - # @return [undefined] - def emit_argument_symbol_mutations - emit_type(:"_#{argument}") unless argument.to_s.start_with?('_') - end - - # Emit argument node mutations - # - # @return [undefined] - def emit_argument_node_mutations - emit_argument_mutations - first = Mutant::Util.one(argument.children) - emit_type(first) + emit_type(s(:arg, :"_#{name}")) unless name.to_s.start_with?('_') end end # ProcargZero end # Node diff --git a/meta/block.rb b/meta/block.rb index e2f618c9..94e1269c 100644 --- a/meta/block.rb +++ b/meta/block.rb @@ -38,7 +38,6 @@ Mutant::Meta::Example.add :block do mutation 'foo { |(a, b), c| raise }' mutation 'foo { |(a), c| }' mutation 'foo { |(b), c| }' - mutation 'foo { |(a, b)| }' mutation 'foo { |c, | }' mutation 'foo { |(_a, b), c| }' mutation 'foo { |(a, _b), c| }' @@ -85,7 +84,6 @@ Mutant::Meta::Example.add :block do singleton_mutations mutation 'foo { || }' - mutation 'foo { |a| }' mutation 'foo { |(a)| raise }' mutation 'foo { |(_a)| }' mutation 'foo' diff --git a/mutant.gemspec b/mutant.gemspec index 15ade67d..54c22a1b 100644 --- a/mutant.gemspec +++ b/mutant.gemspec @@ -31,9 +31,9 @@ Gem::Specification.new do |gem| gem.add_runtime_dependency('ice_nine', '~> 0.11.1') gem.add_runtime_dependency('memoizable', '~> 0.4.2') gem.add_runtime_dependency('morpher', '~> 0.2.6') - gem.add_runtime_dependency('parser', '~> 2.5.1') + gem.add_runtime_dependency('parser', '~> 2.7.2') gem.add_runtime_dependency('procto', '~> 0.0.2') - gem.add_runtime_dependency('regexp_parser', '~> 1.7', '>= 1.7.1') + gem.add_runtime_dependency('regexp_parser', '~> 1.8.2') gem.add_runtime_dependency('unparser', '~> 0.4.2') gem.add_development_dependency('parallel', '~> 1.3')