mutant 0.11.32 → 0.11.34
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mutant/bootstrap.rb +1 -1
- data/lib/mutant/expression/descendants.rb +2 -1
- data/lib/mutant/expression/method.rb +3 -1
- data/lib/mutant/expression/methods.rb +3 -1
- data/lib/mutant/expression/namespace.rb +4 -2
- data/lib/mutant/expression/source.rb +46 -0
- data/lib/mutant/matcher.rb +6 -4
- data/lib/mutant/mutator/node/const_pattern.rb +18 -0
- data/lib/mutant/parser.rb +1 -1
- data/lib/mutant/version.rb +1 -1
- data/lib/mutant.rb +4 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e98171c271934f978770ae00e52d0e3e801a4197fa4b5efb0a43f966ff5af54c
|
4
|
+
data.tar.gz: 0d2d7823052db9d2a46efcc0fdd11808d95510dd58a77933288c063f7195851f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba1991d33cb05098cb78bc5325d05c8b4dbe974752a276a5daf43139c1e1202bb5ce5505b2ce1072d8d86ca4ca6ca22a828d971589b1c22b13fd012703cf7ebf
|
7
|
+
data.tar.gz: 8e3f0a5ce588b5b49c08233bceb8c855c6b32ce7cbb4fb1a1056e981775e9007c7188b09e73438fb56d7faff64c6f13b280dbed580273b329b3981693123b3dd
|
data/lib/mutant/bootstrap.rb
CHANGED
@@ -38,7 +38,7 @@ module Mutant
|
|
38
38
|
.with(matchable_scopes: matchable_scopes(env))
|
39
39
|
|
40
40
|
matched_subjects = env.record(:subject_match) do
|
41
|
-
Matcher.
|
41
|
+
Matcher.expand(env: env).call(env)
|
42
42
|
end
|
43
43
|
|
44
44
|
selected_subjects = subject_select(env, matched_subjects)
|
@@ -39,7 +39,9 @@ module Mutant
|
|
39
39
|
# Matcher for expression
|
40
40
|
#
|
41
41
|
# @return [Matcher]
|
42
|
-
|
42
|
+
#
|
43
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
44
|
+
def matcher(env:)
|
43
45
|
matcher_candidates = MATCHERS.fetch(scope_symbol)
|
44
46
|
.map { |submatcher| submatcher.new(scope: scope) }
|
45
47
|
|
@@ -34,7 +34,9 @@ module Mutant
|
|
34
34
|
# Matcher on expression
|
35
35
|
#
|
36
36
|
# @return [Matcher::Method]
|
37
|
-
|
37
|
+
#
|
38
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
39
|
+
def matcher(env:)
|
38
40
|
matcher_candidates = MATCHERS.fetch(scope_symbol)
|
39
41
|
.map { |submatcher| submatcher.new(scope: scope) }
|
40
42
|
|
@@ -34,7 +34,9 @@ module Mutant
|
|
34
34
|
# Matcher for expression
|
35
35
|
#
|
36
36
|
# @return [Matcher]
|
37
|
-
|
37
|
+
#
|
38
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
39
|
+
def matcher(env:)
|
38
40
|
Matcher::Namespace.new(expression: self)
|
39
41
|
end
|
40
42
|
|
@@ -65,7 +67,7 @@ module Mutant
|
|
65
67
|
# Matcher matcher on expression
|
66
68
|
#
|
67
69
|
# @return [Matcher]
|
68
|
-
def matcher
|
70
|
+
def matcher(env:)
|
69
71
|
raw_scope = find_raw_scope
|
70
72
|
|
71
73
|
if raw_scope
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mutant
|
4
|
+
class Expression
|
5
|
+
class Source < self
|
6
|
+
include Anima.new(:glob_expression)
|
7
|
+
|
8
|
+
REGEXP = /\Asource:(?<glob_expression>.+)\z/
|
9
|
+
|
10
|
+
def syntax
|
11
|
+
"source:#{glob_expression}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def matcher(env:)
|
15
|
+
Matcher::Chain.new(matchers: find_matchers(env: env))
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def find_matchers(env:)
|
21
|
+
scope_names(env: env).uniq.map do |scope_name|
|
22
|
+
Namespace::Recursive.new(scope_name: scope_name).matcher(env: nil)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def scope_names(env:)
|
27
|
+
env.world.pathname.glob(glob_expression).flat_map do |path|
|
28
|
+
toplevel_consts(env.parser.call(path).node).map(&Unparser.public_method(:unparse))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def toplevel_consts(node)
|
33
|
+
children = node.children
|
34
|
+
|
35
|
+
case node.type
|
36
|
+
when :class, :module
|
37
|
+
[children.fetch(0)]
|
38
|
+
when :begin
|
39
|
+
children.flat_map(&method(__method__))
|
40
|
+
else
|
41
|
+
EMPTY_ARRAY
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end # Source
|
45
|
+
end # Expression
|
46
|
+
end # Mutant
|
data/lib/mutant/matcher.rb
CHANGED
@@ -15,13 +15,15 @@ module Mutant
|
|
15
15
|
|
16
16
|
# Turn config into matcher
|
17
17
|
#
|
18
|
-
# @param [
|
18
|
+
# @param [Env] env
|
19
19
|
#
|
20
20
|
# @return [Matcher]
|
21
|
-
def self.
|
21
|
+
def self.expand(env:)
|
22
|
+
matcher_config = env.config.matcher
|
23
|
+
|
22
24
|
Filter.new(
|
23
|
-
matcher: Chain.new(matchers:
|
24
|
-
predicate: method(:allowed_subject?).curry.call(
|
25
|
+
matcher: Chain.new(matchers: matcher_config.subjects.map { |subject| subject.matcher(env: env) }),
|
26
|
+
predicate: method(:allowed_subject?).curry.call(matcher_config)
|
25
27
|
)
|
26
28
|
end
|
27
29
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mutant
|
4
|
+
class Mutator
|
5
|
+
class Node
|
6
|
+
class ConstPattern < self
|
7
|
+
handle(:const_pattern)
|
8
|
+
|
9
|
+
children(:target, :pattern)
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def dispatch; end
|
14
|
+
|
15
|
+
end # ConstPAttern
|
16
|
+
end # Node
|
17
|
+
end # Mutator
|
18
|
+
end # Mutant
|
data/lib/mutant/parser.rb
CHANGED
data/lib/mutant/version.rb
CHANGED
data/lib/mutant.rb
CHANGED
@@ -174,6 +174,7 @@ module Mutant
|
|
174
174
|
require 'mutant/mutator/node/procarg_zero'
|
175
175
|
require 'mutant/mutator/node/kwargs'
|
176
176
|
require 'mutant/mutator/node/numblock'
|
177
|
+
require 'mutant/mutator/node/const_pattern'
|
177
178
|
require 'mutant/mutator/regexp'
|
178
179
|
require 'mutant/loader'
|
179
180
|
require 'mutant/context'
|
@@ -204,6 +205,7 @@ module Mutant
|
|
204
205
|
require 'mutant/expression/methods'
|
205
206
|
require 'mutant/expression/namespace'
|
206
207
|
require 'mutant/expression/parser'
|
208
|
+
require 'mutant/expression/source'
|
207
209
|
require 'mutant/test'
|
208
210
|
require 'mutant/test/runner'
|
209
211
|
require 'mutant/test/runner/sink'
|
@@ -347,7 +349,8 @@ module Mutant
|
|
347
349
|
Expression::Method,
|
348
350
|
Expression::Methods,
|
349
351
|
Expression::Namespace::Exact,
|
350
|
-
Expression::Namespace::Recursive
|
352
|
+
Expression::Namespace::Recursive,
|
353
|
+
Expression::Source
|
351
354
|
]
|
352
355
|
),
|
353
356
|
environment_variables: EMPTY_HASH,
|
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.11.
|
4
|
+
version: 0.11.34
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Schirp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diff-lcs
|
@@ -189,6 +189,7 @@ files:
|
|
189
189
|
- lib/mutant/expression/methods.rb
|
190
190
|
- lib/mutant/expression/namespace.rb
|
191
191
|
- lib/mutant/expression/parser.rb
|
192
|
+
- lib/mutant/expression/source.rb
|
192
193
|
- lib/mutant/hooks.rb
|
193
194
|
- lib/mutant/integration.rb
|
194
195
|
- lib/mutant/integration/null.rb
|
@@ -239,6 +240,7 @@ files:
|
|
239
240
|
- lib/mutant/mutator/node/class.rb
|
240
241
|
- lib/mutant/mutator/node/conditional_loop.rb
|
241
242
|
- lib/mutant/mutator/node/const.rb
|
243
|
+
- lib/mutant/mutator/node/const_pattern.rb
|
242
244
|
- lib/mutant/mutator/node/define.rb
|
243
245
|
- lib/mutant/mutator/node/defined.rb
|
244
246
|
- lib/mutant/mutator/node/dynamic_literal.rb
|
@@ -364,7 +366,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
364
366
|
- !ruby/object:Gem::Version
|
365
367
|
version: '0'
|
366
368
|
requirements: []
|
367
|
-
rubygems_version: 3.
|
369
|
+
rubygems_version: 3.3.25
|
368
370
|
signing_key:
|
369
371
|
specification_version: 4
|
370
372
|
summary: ''
|