mutant 0.11.17 → 0.11.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mutant
4
- class Mutator
5
- class Node
6
- module Regexp
7
- # Mutator for end of line or before end of string anchor `\Z`
8
- class EndOfStringOrBeforeEndOfLineAnchor < Node
9
- handle(:regexp_eos_ob_eol_anchor)
10
-
11
- private
12
-
13
- def dispatch
14
- emit(s(:regexp_eos_anchor))
15
- end
16
- end # EndOfStringOrBeforeEndOfLineAnchor
17
- end # Regexp
18
- end # Node
19
- end # Mutator
20
- end # Mutant
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mutant
4
- class Mutator
5
- class Node
6
- module Regexp
7
- # Mutator for regexp named capture groups, such as `/(?<foo>bar)/`
8
- class NamedGroup < Node
9
- handle(:regexp_named_group)
10
-
11
- children :name
12
-
13
- private
14
-
15
- def dispatch
16
- return if remaining_children.empty?
17
-
18
- remaining_children_indices.each(&method(:mutate_child))
19
-
20
- # Allows unused captures to be kept and named if they are explicitly prefixed with an
21
- # underscore, like we allow with unused local variables.
22
- return if name_underscored?
23
-
24
- emit(s(:regexp_passive_group, *remaining_children))
25
- emit_name_underscore_mutation
26
- end
27
-
28
- def emit_name_underscore_mutation
29
- emit_type("_#{name}", *remaining_children)
30
- end
31
-
32
- def name_underscored?
33
- name.start_with?('_')
34
- end
35
- end # EndOfLineAnchor
36
- end # Regexp
37
- end # Node
38
- end # Mutator
39
- end # Mutant
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mutant
4
- class Mutator
5
- class Node
6
- module Regexp
7
- # Mutator for zero-or-more quantifier, `*`
8
- class ZeroOrMore < Node
9
- MAP = {
10
- regexp_greedy_zero_or_more: :regexp_greedy_one_or_more,
11
- regexp_reluctant_zero_or_more: :regexp_reluctant_one_or_more,
12
- regexp_possessive_zero_or_more: :regexp_possessive_one_or_more
13
- }.freeze
14
-
15
- handle(*MAP.keys)
16
-
17
- children :min, :max, :subject
18
-
19
- private
20
-
21
- # Replace:
22
- # * `/a*/` with `/a+/`
23
- # * `/a*?/` with `/a+?/`
24
- # * `/a*+/` with `/a++/`
25
- def dispatch
26
- emit(s(MAP.fetch(node.type), *children))
27
- emit_subject_mutations
28
- emit(subject)
29
- end
30
- end # ZeroOrMore
31
- end # Regexp
32
- end # Node
33
- end # Mutator
34
- end # Mutant
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mutant
4
- class Mutator
5
- class Node
6
- module Regexp
7
- # Mutator for root expression regexp wrapper
8
- class RootExpression < Node
9
- handle(:regexp_root_expression)
10
-
11
- private
12
-
13
- def dispatch
14
- children.each_index(&method(:mutate_child))
15
- end
16
- end # RootExpression
17
- end # Regexp
18
- end # Node
19
- end # Mutator
20
- end # Mutant