From b95aa9c05af48a97d5611b082acfe4d5823b631d Mon Sep 17 00:00:00 2001 From: Firas Zaidan Date: Tue, 23 Jan 2018 18:29:31 +0100 Subject: [PATCH] Whitelist regexp_parser warning and bump regexp_parser to 0.4.9 * Add regexp_xgrapheme_type --- Gemfile.lock | 8 +++--- lib/mutant/ast/regexp/transformer/direct.rb | 1 + lib/mutant/ast/types.rb | 1 + lib/mutant/mutator/node/generic.rb | 1 + .../mutator/node/regexp/character_type.rb | 3 ++- meta/regexp/character_types.rb | 3 ++- mutant.gemspec | 2 +- spec/support/warnings.yml | 2 ++ spec/unit/mutant/ast/regexp_spec.rb | 26 ++++++------------- 9 files changed, 22 insertions(+), 25 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d1373d481..ef3d933f4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,7 +15,7 @@ PATH parallel (~> 1.3) parser (>= 2.3.1.4, < 2.5) procto (~> 0.0.2) - regexp_parser (~> 0.4.4) + regexp_parser (~> 0.4.9) unparser (~> 0.2.5) mutant-rspec (0.8.14) mutant (~> 0.8.14) @@ -92,7 +92,7 @@ GEM equalizer (~> 0.0.9) ice_nine (~> 0.11.0) procto (~> 0.0.2) - parallel (1.11.2) + parallel (1.12.1) parser (2.4.0.0) ast (~> 2.2) path_expander (1.0.2) @@ -105,7 +105,7 @@ GEM codeclimate-engine-rb (~> 0.4.0) parser (>= 2.4.0.0, < 2.5) rainbow (~> 2.0) - regexp_parser (0.4.4) + regexp_parser (0.4.9) rspec (3.5.0) rspec-core (~> 3.5.0) rspec-expectations (~> 3.5.0) @@ -166,4 +166,4 @@ DEPENDENCIES mutant! BUNDLED WITH - 1.15.1 + 1.15.4 diff --git a/lib/mutant/ast/regexp/transformer/direct.rb b/lib/mutant/ast/regexp/transformer/direct.rb index 0308386be..70994cd0b 100644 --- a/lib/mutant/ast/regexp/transformer/direct.rb +++ b/lib/mutant/ast/regexp/transformer/direct.rb @@ -75,6 +75,7 @@ class ASTToExpression < Transformer::ASTToExpression [:regexp_digit_type, [:type, :digit, '\d'], ::Regexp::Expression::CharacterType::Digit], [:regexp_space_type, [:type, :space, '\s'], ::Regexp::Expression::CharacterType::Space], [:regexp_word_type, [:type, :word, '\w'], ::Regexp::Expression::CharacterType::Word], + [:regexp_xgrapheme_type, [:type, :xgrapheme, '\X'], ::Regexp::Expression::CharacterType::ExtendedGrapheme], [:regexp_hex_type, [:type, :hex, '\h'], ::Regexp::Expression::CharacterType::Hex], [:regexp_nonhex_type, [:type, :nonhex, '\H'], ::Regexp::Expression::CharacterType::NonHex], [:regexp_nondigit_type, [:type, :nondigit, '\D'], ::Regexp::Expression::CharacterType::NonDigit], diff --git a/lib/mutant/ast/types.rb b/lib/mutant/ast/types.rb index 3ab1792d3..48818017c 100644 --- a/lib/mutant/ast/types.rb +++ b/lib/mutant/ast/types.rb @@ -125,6 +125,7 @@ module Types regexp_whitespace_free_space regexp_word_boundary_anchor regexp_word_type + regexp_xgrapheme_type regexp_zero_or_more_escape regexp_zero_or_one_escape ]) diff --git a/lib/mutant/mutator/node/generic.rb b/lib/mutant/mutator/node/generic.rb index dc22efe25..90f86fb3e 100644 --- a/lib/mutant/mutator/node/generic.rb +++ b/lib/mutant/mutator/node/generic.rb @@ -54,6 +54,7 @@ class Generic < self regexp_space_type regexp_word_boundary_anchor regexp_word_type + regexp_xgrapheme_type ] # These nodes still need a dedicated mutator, diff --git a/lib/mutant/mutator/node/regexp/character_type.rb b/lib/mutant/mutator/node/regexp/character_type.rb index e8af5df84..e4c75af52 100644 --- a/lib/mutant/mutator/node/regexp/character_type.rb +++ b/lib/mutant/mutator/node/regexp/character_type.rb @@ -9,7 +9,8 @@ class CharacterType < Node regexp_hex_type: :regexp_nonhex_type, regexp_space_type: :regexp_nonspace_type, regexp_word_boundary_anchor: :regexp_nonword_boundary_anchor, - regexp_word_type: :regexp_nonword_type + regexp_word_type: :regexp_nonword_type, + regexp_xgrapheme_type: :regexp_space_type } MAP = IceNine.deep_freeze(map.merge(map.invert)) diff --git a/meta/regexp/character_types.rb b/meta/regexp/character_types.rb index 6f7d282ea..4fc5e39eb 100644 --- a/meta/regexp/character_types.rb +++ b/meta/regexp/character_types.rb @@ -3,7 +3,8 @@ [:regexp_hex_type, '/\h/'] => [:regexp_nonhex_type, '/\H/'], [:regexp_space_type, '/\s/'] => [:regexp_nonspace_type, '/\S/'], [:regexp_word_boundary_anchor, '/\b/'] => [:regexp_nonword_boundary_anchor, '/\B/'], - [:regexp_word_type, '/\w/'] => [:regexp_nonword_type, '/\W/'] + [:regexp_word_type, '/\w/'] => [:regexp_nonword_type, '/\W/'], + [:regexp_xgrapheme_type, '/\X/'] => [:regexp_space_type, '/\s/'] } mutations = mutations.merge(mutations.invert) diff --git a/mutant.gemspec b/mutant.gemspec index eecce295a..4486bc472 100644 --- a/mutant.gemspec +++ b/mutant.gemspec @@ -35,7 +35,7 @@ Gem::Specification.new do |gem| gem.add_runtime_dependency('equalizer', '~> 0.0.9') gem.add_runtime_dependency('anima', '~> 0.3.0') gem.add_runtime_dependency('concord', '~> 0.1.5') - gem.add_runtime_dependency('regexp_parser', '~> 0.4.4') + gem.add_runtime_dependency('regexp_parser', '~> 0.4.9') gem.add_development_dependency('devtools', '~> 0.1.12') gem.add_development_dependency('bundler', '~> 1.10') diff --git a/spec/support/warnings.yml b/spec/support/warnings.yml index fbe2c06a4..fbdb26525 100644 --- a/spec/support/warnings.yml +++ b/spec/support/warnings.yml @@ -3,3 +3,5 @@ - 'lib/parallel.rb:227: warning: shadowing outer local variable - args' - 'lib/parser/lexer.rb:10922: warning: assigned but unused variable - testEof' - 'lib/regexp_parser/scanner.rb:1675: warning: assigned but unused variable - testEof' +- 'lib/regexp_parser/scanner.rb:1692: warning: assigned but unused variable - testEof' +- 'lib/regexp_parser/scanner.rb:1689: warning: assigned but unused variable - testEof' diff --git a/spec/unit/mutant/ast/regexp_spec.rb b/spec/unit/mutant/ast/regexp_spec.rb index 42c0a7e0d..4815101a7 100644 --- a/spec/unit/mutant/ast/regexp_spec.rb +++ b/spec/unit/mutant/ast/regexp_spec.rb @@ -227,12 +227,7 @@ def self.expect_mapping(regexp, type, &block) )/, :regexp_comment_free_space) do s(:regexp_root_expression, s(:regexp_options_group, { - m: false, - i: false, - x: true, - d: false, - a: false, - u: false + x: true }, s(:regexp_whitespace_free_space, ' '), s(:regexp_comment_free_space, "# comment\n"))) @@ -354,6 +349,11 @@ def self.expect_mapping(regexp, type, &block) s(:regexp_nonhex_type)) end +RegexpSpec.expect_mapping(/\X/, :regexp_xgrapheme_type) do + s(:regexp_root_expression, + s(:regexp_xgrapheme_type)) +end + RegexpSpec.expect_mapping(/\}/, :regexp_interval_close_escape) do s(:regexp_root_expression, s(:regexp_interval_close_escape)) @@ -480,12 +480,7 @@ def self.expect_mapping(regexp, type, &block) s(:regexp_greedy_one_or_more, 1, -1, s(:regexp_options_group, { - m: false, - i: true, - x: false, - d: false, - a: false, - u: false + i: true }, s(:regexp_literal_literal, 'a')))) end @@ -494,12 +489,7 @@ def self.expect_mapping(regexp, type, &block) s(:regexp_root_expression, s(:regexp_options_group, { - m: false, - i: false, - x: true, - d: false, - a: false, - u: false + x: true }, s(:regexp_whitespace_free_space, " \n "))) end