mutant 0.10.23 → 0.10.24

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mutant.rb +20 -4
  3. data/lib/mutant/ast/regexp.rb +37 -0
  4. data/lib/mutant/ast/regexp/transformer.rb +150 -0
  5. data/lib/mutant/ast/regexp/transformer/direct.rb +121 -0
  6. data/lib/mutant/ast/regexp/transformer/named_group.rb +50 -0
  7. data/lib/mutant/ast/regexp/transformer/options_group.rb +68 -0
  8. data/lib/mutant/ast/regexp/transformer/quantifier.rb +90 -0
  9. data/lib/mutant/ast/regexp/transformer/recursive.rb +56 -0
  10. data/lib/mutant/ast/regexp/transformer/root.rb +28 -0
  11. data/lib/mutant/ast/regexp/transformer/text.rb +58 -0
  12. data/lib/mutant/ast/types.rb +115 -2
  13. data/lib/mutant/cli/command/environment.rb +9 -3
  14. data/lib/mutant/config.rb +8 -54
  15. data/lib/mutant/config/coverage_criteria.rb +61 -0
  16. data/lib/mutant/expression.rb +0 -12
  17. data/lib/mutant/matcher.rb +2 -2
  18. data/lib/mutant/matcher/config.rb +25 -6
  19. data/lib/mutant/matcher/method.rb +2 -3
  20. data/lib/mutant/meta/example/dsl.rb +6 -1
  21. data/lib/mutant/mutator/node/kwargs.rb +2 -2
  22. data/lib/mutant/mutator/node/literal/regex.rb +26 -0
  23. data/lib/mutant/mutator/node/regexp.rb +31 -0
  24. data/lib/mutant/mutator/node/regexp/alternation_meta.rb +20 -0
  25. data/lib/mutant/mutator/node/regexp/capture_group.rb +25 -0
  26. data/lib/mutant/mutator/node/regexp/character_type.rb +31 -0
  27. data/lib/mutant/mutator/node/regexp/end_of_line_anchor.rb +20 -0
  28. data/lib/mutant/mutator/node/regexp/end_of_string_or_before_end_of_line_anchor.rb +20 -0
  29. data/lib/mutant/mutator/node/regexp/greedy_zero_or_more.rb +24 -0
  30. data/lib/mutant/subject.rb +1 -3
  31. data/lib/mutant/subject/method/instance.rb +1 -3
  32. data/lib/mutant/version.rb +1 -1
  33. data/lib/mutant/world.rb +1 -2
  34. metadata +40 -4
  35. data/lib/mutant/warnings.rb +0 -106
@@ -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 end of line anchor `$`
8
+ class EndOfLineAnchor < Node
9
+ handle(:regexp_eol_anchor)
10
+
11
+ private
12
+
13
+ def dispatch
14
+ emit(s(:regexp_eos_anchor))
15
+ end
16
+ end # EndOfLineAnchor
17
+ end # Regexp
18
+ end # Node
19
+ end # Mutator
20
+ end # Mutant
@@ -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 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
@@ -0,0 +1,24 @@
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
@@ -4,9 +4,7 @@ module Mutant
4
4
  # Subject of a mutation
5
5
  class Subject
6
6
  include AbstractType, Adamantium::Flat, Enumerable
7
- include Anima.new(:context, :node, :warnings)
8
-
9
- private :warnings
7
+ include Anima.new(:context, :node)
10
8
 
11
9
  # Mutations for this subject
12
10
  #
@@ -13,9 +13,7 @@ module Mutant
13
13
  #
14
14
  # @return [self]
15
15
  def prepare
16
- warnings.call do
17
- scope.public_send(:undef_method, name)
18
- end
16
+ scope.undef_method(name)
19
17
  self
20
18
  end
21
19
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Mutant
4
4
  # Current mutant version
5
- VERSION = '0.10.23'
5
+ VERSION = '0.10.24'
6
6
  end # Mutant
@@ -20,8 +20,7 @@ module Mutant
20
20
  :stderr,
21
21
  :stdout,
22
22
  :thread,
23
- :timer,
24
- :warnings
23
+ :timer
25
24
  )
26
25
 
27
26
  INSPECT = '#<Mutant::World>'
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.23
4
+ version: 0.10.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-30 00:00:00.000000000 Z
11
+ date: 2021-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: abstract_type
@@ -178,6 +178,26 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: 0.0.2
181
+ - !ruby/object:Gem::Dependency
182
+ name: regexp_parser
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '2.0'
188
+ - - ">="
189
+ - !ruby/object:Gem::Version
190
+ version: 2.0.3
191
+ type: :runtime
192
+ prerelease: false
193
+ version_requirements: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - "~>"
196
+ - !ruby/object:Gem::Version
197
+ version: '2.0'
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: 2.0.3
181
201
  - !ruby/object:Gem::Dependency
182
202
  name: unparser
183
203
  requirement: !ruby/object:Gem::Requirement
@@ -299,6 +319,15 @@ files:
299
319
  - lib/mutant/ast/named_children.rb
300
320
  - lib/mutant/ast/node_predicates.rb
301
321
  - lib/mutant/ast/nodes.rb
322
+ - lib/mutant/ast/regexp.rb
323
+ - lib/mutant/ast/regexp/transformer.rb
324
+ - lib/mutant/ast/regexp/transformer/direct.rb
325
+ - lib/mutant/ast/regexp/transformer/named_group.rb
326
+ - lib/mutant/ast/regexp/transformer/options_group.rb
327
+ - lib/mutant/ast/regexp/transformer/quantifier.rb
328
+ - lib/mutant/ast/regexp/transformer/recursive.rb
329
+ - lib/mutant/ast/regexp/transformer/root.rb
330
+ - lib/mutant/ast/regexp/transformer/text.rb
302
331
  - lib/mutant/ast/sexp.rb
303
332
  - lib/mutant/ast/types.rb
304
333
  - lib/mutant/bootstrap.rb
@@ -311,6 +340,7 @@ files:
311
340
  - lib/mutant/cli/command/root.rb
312
341
  - lib/mutant/cli/command/subscription.rb
313
342
  - lib/mutant/config.rb
343
+ - lib/mutant/config/coverage_criteria.rb
314
344
  - lib/mutant/context.rb
315
345
  - lib/mutant/env.rb
316
346
  - lib/mutant/expression.rb
@@ -391,6 +421,13 @@ files:
391
421
  - lib/mutant/mutator/node/op_asgn.rb
392
422
  - lib/mutant/mutator/node/or_asgn.rb
393
423
  - lib/mutant/mutator/node/procarg_zero.rb
424
+ - lib/mutant/mutator/node/regexp.rb
425
+ - lib/mutant/mutator/node/regexp/alternation_meta.rb
426
+ - lib/mutant/mutator/node/regexp/capture_group.rb
427
+ - lib/mutant/mutator/node/regexp/character_type.rb
428
+ - lib/mutant/mutator/node/regexp/end_of_line_anchor.rb
429
+ - 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
394
431
  - lib/mutant/mutator/node/regopt.rb
395
432
  - lib/mutant/mutator/node/resbody.rb
396
433
  - lib/mutant/mutator/node/rescue.rb
@@ -452,7 +489,6 @@ files:
452
489
  - lib/mutant/transform.rb
453
490
  - lib/mutant/util.rb
454
491
  - lib/mutant/version.rb
455
- - lib/mutant/warnings.rb
456
492
  - lib/mutant/world.rb
457
493
  - lib/mutant/zombifier.rb
458
494
  homepage: https://github.com/mbj/mutant
@@ -474,7 +510,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
474
510
  - !ruby/object:Gem::Version
475
511
  version: '0'
476
512
  requirements: []
477
- rubygems_version: 3.2.0.rc.1
513
+ rubygems_version: 3.2.3
478
514
  signing_key:
479
515
  specification_version: 4
480
516
  summary: ''
@@ -1,106 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mutant
4
- # Class to capture warnings generated by Kernel#warn and Ruby itself.
5
- #
6
- # @example
7
- # capture = Mutant::Warnings.new(Warning)
8
- #
9
- # # Note that this test case shows we can capture warnings generated from C
10
- # def ruby_warning
11
- # Class.new do
12
- # undef :initialize
13
- # end
14
- # end
15
- #
16
- # messages = capture.call do
17
- # ruby_warning
18
- # end
19
- #
20
- # messages # => ["some_file.rb:44: warning: undefining `initialize' may cause serious problems\n"]
21
- #
22
- # Note this API is fundamentally impure:
23
- #
24
- # * Unlike almost all of classes in the mutant code base it has internal
25
- # mutable state
26
- # * Its therefore NOT thread safe
27
- # * And worst: Each instance, even after its not referenced anymore by user
28
- # code: Leaks permanent global state as instances of this class hook
29
- # itself into the `Warning` module.
30
- #
31
- # So ideally only make *one* instance, and re-use it.
32
- #
33
- # Also note, a more canonical implementation would prepend modules and simply
34
- # call `super` in the event the capture is disabled. This sadly does not
35
- # work as it would inference with various bad players in the ruby ecosystem
36
- # that do not adhere to the semantics outlined in the documentation.
37
- #
38
- # See: https://ruby-doc.org/core-2.6.3/Warning.html
39
- #
40
- # For example in case rubygems is active it adds its own hook to warnings,
41
- # that would in case of the super implementation cause infinite recursion.
42
- #
43
- # Reproduction for this case is as simple as:
44
- #
45
- # ```
46
- # require 'rubygems'
47
- #
48
- # module Warning
49
- # def warn(*)
50
- # super
51
- # end
52
- # end
53
- # ```
54
- #
55
- # For that reason we do have to use the original method capture to dispatch
56
- # in disabled state.
57
- #
58
- class Warnings
59
- # Error raised when warning capture is used recursively
60
- class RecursiveUseError < RuntimeError; end
61
-
62
- # Initialize object
63
- #
64
- # @param [Module] warning
65
- # the module to integrate against
66
- #
67
- # @return [undefined]
68
- def initialize(warning)
69
- @disabled = true
70
- @messages = []
71
- @original = warning.public_method(:warn)
72
-
73
- capture = method(:capture)
74
- warning.module_eval do
75
- module_function define_method(:warn, &capture)
76
- end
77
- end
78
-
79
- # Run a block with warning collection enabled
80
- #
81
- # @return [Array<String>]
82
- def call
83
- assert_no_recursion
84
- @disabled = nil
85
- yield
86
- IceNine.deep_freeze(@messages.dup)
87
- ensure
88
- @disabled = true
89
- @messages.clear
90
- end
91
-
92
- private
93
-
94
- def capture(*arguments)
95
- if @disabled
96
- @original.call(*arguments)
97
- else
98
- @messages << arguments
99
- end
100
- end
101
-
102
- def assert_no_recursion
103
- fail RecursiveUseError unless @disabled
104
- end
105
- end # Warnings
106
- end # Mutant