mutant 0.10.24 → 0.10.25

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34fe96de54f1f220934b79bdf26e6103693d1a8cd4986bc05259d90117016801
4
- data.tar.gz: 1a3acf6dcc73c191f6264a5827910b76d2da54aaff79a75a903f45595bd653be
3
+ metadata.gz: f02dec057593b8e61c2b207918ed6f1b9c4aa1d41bc0b2f2390c2a1da9172b5d
4
+ data.tar.gz: 99a318ed1f02d9976037694b2dbc1de463863f747cc4b8b5e95809b307680f03
5
5
  SHA512:
6
- metadata.gz: fc6d72fcd52b9167dd3d0cd030c5f29076f61b8c296d9019802106200567e60c28e011fd68b6f1e928cca1bd5c9787291b1b35e7b77a86dc8a74b3895c323dd2
7
- data.tar.gz: 53eb52604ab5b02cb412f990efa2770495df25c56cab860447ac210f4179a17cb6cf76f0641f4e362882188ee403e6402908d09d7c3673500aa00b2722084ae2
6
+ metadata.gz: 5312bd87fc41b3442b886b40b200357c254c2d7d65081cdfaca2e2e213311539eb23b00eb5b792c9f7978c8eeed5a6cbd72b3a513598b9abc9f72a3beaa9989d
7
+ data.tar.gz: 922e0ea1878e05f014a3c832d7bfa23e0d8410cc8c8d5b9bd1bc8b81124a18ecd11403be643cd144772863950076b17ab06ce3cd809cda01a9563ec815c95e79
@@ -88,11 +88,12 @@ require 'mutant/mutator/node'
88
88
  require 'mutant/mutator/node/generic'
89
89
  require 'mutant/mutator/node/regexp'
90
90
  require 'mutant/mutator/node/regexp/alternation_meta'
91
+ require 'mutant/mutator/node/regexp/beginning_of_line_anchor'
91
92
  require 'mutant/mutator/node/regexp/capture_group'
92
93
  require 'mutant/mutator/node/regexp/character_type'
93
94
  require 'mutant/mutator/node/regexp/end_of_line_anchor'
94
95
  require 'mutant/mutator/node/regexp/end_of_string_or_before_end_of_line_anchor'
95
- require 'mutant/mutator/node/regexp/greedy_zero_or_more'
96
+ require 'mutant/mutator/node/regexp/zero_or_more'
96
97
  require 'mutant/mutator/node/literal'
97
98
  require 'mutant/mutator/node/literal/boolean'
98
99
  require 'mutant/mutator/node/literal/range'
@@ -18,7 +18,7 @@ module Mutant
18
18
 
19
19
  # Vale returned on MRI detecting void value expressions
20
20
  class VoidValue < self
21
- end # voidValue
21
+ end # VoidValue
22
22
  end # Result
23
23
 
24
24
  # Call loader
@@ -26,7 +26,9 @@ module Mutant
26
26
 
27
27
  DEFAULT = new(Hash[anima.attribute_names.map { |name| [name, []] }])
28
28
 
29
- expression = ->(input) { Mutant::Config::DEFAULT.expression_parser.call(input) }
29
+ expression = Transform::Block.capture(:expression) do |input|
30
+ Mutant::Config::DEFAULT.expression_parser.call(input)
31
+ end
30
32
 
31
33
  expression_array = Transform::Array.new(expression)
32
34
 
@@ -80,7 +80,7 @@ module Mutant
80
80
  end # Evaluator
81
81
 
82
82
  private_constant(*constants(false))
83
- end # Singleton
83
+ end # Metaclass
84
84
  end # Method
85
85
  end # Matcher
86
86
  end # Mutant
@@ -18,7 +18,7 @@ module Mutant
18
18
  end
19
19
  end
20
20
 
21
- end # Dstr
21
+ end # DynamicLiteral
22
22
  end # Node
23
23
  end # Mutator
24
24
  end # Mutant
@@ -14,17 +14,6 @@ module Mutant
14
14
  children.each_index(&method(:mutate_child))
15
15
  end
16
16
  end # RootExpression
17
-
18
- # Mutator for beginning of line anchor `^`
19
- class BeginningOfLineAnchor < Node
20
- handle(:regexp_bol_anchor)
21
-
22
- private
23
-
24
- def dispatch
25
- emit(s(:regexp_bos_anchor))
26
- end
27
- end # BeginningOfLineAnchor
28
17
  end # Regexp
29
18
  end # Node
30
19
  end # Mutator
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mutant
4
+ class Mutator
5
+ class Node
6
+ module Regexp
7
+ # Mutator for beginning of line anchor `^`
8
+ class BeginningOfLineAnchor < Node
9
+ handle(:regexp_bol_anchor)
10
+
11
+ private
12
+
13
+ def dispatch
14
+ emit(s(:regexp_bos_anchor))
15
+ end
16
+ end # BeginningOfLineAnchor
17
+ end # Regexp
18
+ end # Node
19
+ end # Mutator
20
+ end # Mutant
@@ -0,0 +1,34 @@
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 = IceNine.deep_freeze(
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
+ )
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
@@ -14,7 +14,7 @@ module Mutant
14
14
  def dispatch
15
15
  emit_body_mutations if body
16
16
  end
17
- end # Class
17
+ end # Sclass
18
18
  end # Node
19
19
  end # Mutator
20
20
  end # Mutant
@@ -17,6 +17,8 @@ module Mutant
17
17
  :< => %i[== eql? equal?],
18
18
  :<= => %i[< == eql? equal?],
19
19
  :== => %i[eql? equal?],
20
+ :=== => %i[is_a?],
21
+ :=~ => %i[match?],
20
22
  :> => %i[== eql? equal?],
21
23
  :>= => %i[> == eql? equal?],
22
24
  __send__: %i[public_send],
@@ -31,6 +33,7 @@ module Mutant
31
33
  kind_of?: %i[instance_of?],
32
34
  map: %i[each],
33
35
  method: %i[public_method],
36
+ match: %i[match?],
34
37
  reverse_each: %i[each],
35
38
  reverse_map: %i[map each],
36
39
  reverse_merge: %i[merge],
@@ -81,6 +84,7 @@ module Mutant
81
84
  end
82
85
 
83
86
  def emit_selector_specific_mutations
87
+ emit_predicate_mutations
84
88
  emit_array_mutation
85
89
  emit_static_send
86
90
  emit_const_get_mutation
@@ -90,6 +94,13 @@ module Mutant
90
94
  emit_lambda_mutation
91
95
  end
92
96
 
97
+ def emit_predicate_mutations
98
+ return unless selector.match?(/\?\z/) && !selector.equal?(:defined?)
99
+
100
+ emit(s(:true))
101
+ emit(s(:false))
102
+ end
103
+
93
104
  def emit_array_mutation
94
105
  return unless selector.equal?(:Array) && possible_kernel_method?
95
106
 
@@ -33,7 +33,7 @@ module Mutant
33
33
  __send__(report, format, __send__(value))
34
34
  end
35
35
  end
36
- end # EnvProgress
36
+ end # Env
37
37
  end # Printer
38
38
  end # CLI
39
39
  end # Reporter
@@ -73,6 +73,31 @@ module Mutant
73
73
  end
74
74
  end # Named
75
75
 
76
+ class Block < self
77
+ include Anima.new(:block, :name)
78
+
79
+ def self.capture(name, &block)
80
+ new(block: block, name: name)
81
+ end
82
+
83
+ def call(input)
84
+ block
85
+ .call(input)
86
+ .lmap do |message|
87
+ Error.new(
88
+ cause: nil,
89
+ input: input,
90
+ message: message,
91
+ transform: self
92
+ )
93
+ end
94
+ end
95
+
96
+ def slug
97
+ name
98
+ end
99
+ end
100
+
76
101
  private
77
102
 
78
103
  def error(cause: nil, input:, message: nil)
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Mutant
4
4
  # Current mutant version
5
- VERSION = '0.10.24'
5
+ VERSION = '0.10.25'
6
6
  end # Mutant
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mutant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.24
4
+ version: 0.10.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-01 00:00:00.000000000 Z
11
+ date: 2021-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: abstract_type
@@ -423,11 +423,12 @@ files:
423
423
  - lib/mutant/mutator/node/procarg_zero.rb
424
424
  - lib/mutant/mutator/node/regexp.rb
425
425
  - lib/mutant/mutator/node/regexp/alternation_meta.rb
426
+ - lib/mutant/mutator/node/regexp/beginning_of_line_anchor.rb
426
427
  - lib/mutant/mutator/node/regexp/capture_group.rb
427
428
  - lib/mutant/mutator/node/regexp/character_type.rb
428
429
  - lib/mutant/mutator/node/regexp/end_of_line_anchor.rb
429
430
  - lib/mutant/mutator/node/regexp/end_of_string_or_before_end_of_line_anchor.rb
430
- - lib/mutant/mutator/node/regexp/greedy_zero_or_more.rb
431
+ - lib/mutant/mutator/node/regexp/zero_or_more.rb
431
432
  - lib/mutant/mutator/node/regopt.rb
432
433
  - lib/mutant/mutator/node/resbody.rb
433
434
  - lib/mutant/mutator/node/rescue.rb
@@ -510,7 +511,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
510
511
  - !ruby/object:Gem::Version
511
512
  version: '0'
512
513
  requirements: []
513
- rubygems_version: 3.2.3
514
+ rubygems_version: 3.1.4
514
515
  signing_key:
515
516
  specification_version: 4
516
517
  summary: ''
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mutant
4
- class Mutator
5
- class Node
6
- module Regexp
7
- # Mutator for greedy zero-or-more quantifier, `*`
8
- class GreedyZeroOrMore < Node
9
- handle(:regexp_greedy_zero_or_more)
10
-
11
- children :min, :max, :subject
12
-
13
- private
14
-
15
- def dispatch
16
- emit(s(:regexp_greedy_one_or_more, *children))
17
- emit_subject_mutations
18
- emit(subject)
19
- end
20
- end # GreedyZeroOrMore
21
- end # Regexp
22
- end # Node
23
- end # Mutator
24
- end # Mutant