Skip to content

Commit

Permalink
Fix regexp latin property mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
mbj committed May 3, 2021
1 parent 225bb4b commit e3edac2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# v0.10.31 2021-05-03

* [#1234](https://github.com/mbj/mutant/pull/1234)
Add mapping for latin regexp properties to fix crash on mutating
`p{Latin}` regexp nodes.

[Fix #1231]

# v0.10.30 2021-04-25

* [#1229](https://github.com/mbj/mutant/pull/1229)
Expand Down
1 change: 1 addition & 0 deletions lib/mutant/ast/regexp/transformer/direct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class ASTToExpression < Transformer::ASTToExpression
[:regexp_katakana_property, [:property, :katakana, '\p{Katakana}'], ::Regexp::Expression::UnicodeProperty::Script],
[:regexp_letter_property, [:property, :letter, '\p{L}'], ::Regexp::Expression::UnicodeProperty::Letter::Any],
[:regexp_linebreak_type, [:type, :linebreak, '\R'], ::Regexp::Expression::CharacterType::Linebreak],
[:regexp_latin_property, [:property, :latin, '\p{Latin}'], ::Regexp::Expression::UnicodeProperty::Script],
[:regexp_lower_posixclass, [:posixclass, :lower, '[:lower:]'], ::Regexp::Expression::PosixClass],
[:regexp_mark_keep, [:keep, :mark, '\K'], ::Regexp::Expression::Keep::Mark],
[:regexp_match_start_anchor, [:anchor, :match_start, '\\G'], ::Regexp::Expression::Anchor::MatchStart],
Expand Down
1 change: 1 addition & 0 deletions lib/mutant/ast/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ module Types # rubocop:disable Metrics/ModuleLength
regexp_interval_close_escape
regexp_interval_open_escape
regexp_katakana_property
regexp_latin_property
regexp_letter_property
regexp_linebreak_type
regexp_literal_escape
Expand Down
8 changes: 8 additions & 0 deletions meta/regexp/regexp_latin_property.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

Mutant::Meta::Example.add :regexp, :regexp_latin_property do
source('/p{Latin}/')

singleton_mutations
regexp_mutations
end
5 changes: 5 additions & 0 deletions spec/unit/mutant/ast/regexp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,11 @@ def self.expect_mapping(regexp, type, &block)
s(:regexp_hiragana_property))
end

RegexpSpec.expect_mapping(/\p{Latin}/, :regexp_latin_property) do
s(:regexp_root_expression,
s(:regexp_latin_property))
end

RegexpSpec.expect_mapping(/\p{Katakana}/, :regexp_katakana_property) do
s(:regexp_root_expression,
s(:regexp_katakana_property))
Expand Down

0 comments on commit e3edac2

Please sign in to comment.