mutant 0.11.1 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3615060fe7453d95369d3a331f37af2ccaf30227b60ed88fe10cbbd647c1aef1
4
- data.tar.gz: 26883c9dd809504502b21f95f93853144fd0c80bf4ce09b4709c9c3eb75742fe
3
+ metadata.gz: b75a7265756d1903cb93a5937959a7fca2a38d157eedf9287d1004b7bd5a05a4
4
+ data.tar.gz: 96c7945d43c9ba8dd5c9ef362b4bccc5a536eddf91526a9cb1bce4333df542cc
5
5
  SHA512:
6
- metadata.gz: e99c8649c373b2f001c9e03440947ab456c1b776c0d8841316a9edcc4105ce22229b5227e72f6b1273f11879ca013b7df909286c42b3f9b8fc186827cda47938
7
- data.tar.gz: 3a699d84bacfc16d70912534b2e68a8645d4f737bc977e0495c98b84390328f7912379bf623c0ca6a68df8884faf766e256fb3a983c0b4ea944e23c09ba5ae98
6
+ metadata.gz: 53bf6c9d0de1fb8305fa7e7fce7e2072e381c6a088b0f6e08049222f46de4f908466d498c104f72fd19ddcf1cd7fa2f1cbc2beff099bd5529e880b3bf6a4c2ae
7
+ data.tar.gz: 3cc43c8eefce22bceb8465c4b475d4e0cc5b1e2c01a29997713e137605483d33ff792e368a37afd66316113f0495ae2ac265ec22af638cb112785da95f2261f9
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mutant
4
+ class Expression
5
+ class Descendants < self
6
+ include Anima.new(:const_name)
7
+
8
+ REGEXP = /\Adescendants:(?<const_name>.+)\z/.freeze
9
+
10
+ def syntax
11
+ "descendants:#{const_name}"
12
+ end
13
+
14
+ def matcher
15
+ Matcher::Descendants.new(const_name: const_name)
16
+ end
17
+ end # Descendants
18
+ end # Expression
19
+ end # Mutant
@@ -14,7 +14,7 @@ module Mutant
14
14
  def call(env)
15
15
  matchers.flat_map do |matcher|
16
16
  matcher.call(env)
17
- end
17
+ end.uniq
18
18
  end
19
19
 
20
20
  end # Chain
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mutant
4
+ class Matcher
5
+ # Matcher for all descendants by constant name
6
+ class Descendants < self
7
+ include Anima.new(:const_name)
8
+
9
+ def call(env)
10
+ const = env.world.try_const_get(const_name) or return EMPTY_ARRAY
11
+
12
+ Chain.new(
13
+ matched_scopes(env, const).map { |scope| Scope.new(scope.raw) }
14
+ ).call(env)
15
+ end
16
+
17
+ private
18
+
19
+ def matched_scopes(env, const)
20
+ env.matchable_scopes.select do |scope|
21
+ scope.raw.equal?(const) || const > scope.raw
22
+ end
23
+ end
24
+ end # Descendant
25
+ end # Matcher
26
+ end # Mutant
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Mutant
4
4
  # Current mutant version
5
- VERSION = '0.11.1'
5
+ VERSION = '0.11.2'
6
6
  end # Mutant
data/lib/mutant/world.rb CHANGED
@@ -50,6 +50,19 @@ module Mutant
50
50
  end
51
51
  end
52
52
 
53
+ # Try const get
54
+ #
55
+ # @param [String]
56
+ #
57
+ # @return [Class|Module|nil]
58
+ #
59
+ # rubocop:disable Lint/SuppressedException
60
+ def try_const_get(name)
61
+ kernel.const_get(name)
62
+ rescue NameError
63
+ end
64
+ # rubocop:enable Lint/SuppressedException
65
+
53
66
  # Deadline
54
67
  #
55
68
  # @param [Float, nil] allowed_time
data/lib/mutant.rb CHANGED
@@ -169,23 +169,25 @@ require 'mutant/subject/method/instance'
169
169
  require 'mutant/subject/method/singleton'
170
170
  require 'mutant/subject/method/metaclass'
171
171
  require 'mutant/matcher'
172
- require 'mutant/matcher/config'
173
172
  require 'mutant/matcher/chain'
173
+ require 'mutant/matcher/config'
174
+ require 'mutant/matcher/descendants'
175
+ require 'mutant/matcher/filter'
174
176
  require 'mutant/matcher/method'
175
- require 'mutant/matcher/method/singleton'
176
- require 'mutant/matcher/method/metaclass'
177
177
  require 'mutant/matcher/method/instance'
178
+ require 'mutant/matcher/method/metaclass'
179
+ require 'mutant/matcher/method/singleton'
178
180
  require 'mutant/matcher/methods'
179
181
  require 'mutant/matcher/namespace'
180
- require 'mutant/matcher/scope'
181
- require 'mutant/matcher/filter'
182
182
  require 'mutant/matcher/null'
183
+ require 'mutant/matcher/scope'
183
184
  require 'mutant/matcher/static'
184
185
  require 'mutant/expression'
185
- require 'mutant/expression/parser'
186
+ require 'mutant/expression/descendants'
186
187
  require 'mutant/expression/method'
187
188
  require 'mutant/expression/methods'
188
189
  require 'mutant/expression/namespace'
190
+ require 'mutant/expression/parser'
189
191
  require 'mutant/test'
190
192
  require 'mutant/timer'
191
193
  require 'mutant/integration'
@@ -264,6 +266,7 @@ module Mutant
264
266
  DEFAULT = new(
265
267
  coverage_criteria: Config::CoverageCriteria::EMPTY,
266
268
  expression_parser: Expression::Parser.new([
269
+ Expression::Descendants,
267
270
  Expression::Method,
268
271
  Expression::Methods,
269
272
  Expression::Namespace::Exact,
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.1
4
+ version: 0.11.2
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-11-08 00:00:00.000000000 Z
11
+ date: 2021-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs
@@ -78,14 +78,14 @@ dependencies:
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: 0.6.0
81
+ version: 0.6.2
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: 0.6.0
88
+ version: 0.6.2
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: parallel
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -207,6 +207,7 @@ files:
207
207
  - lib/mutant/context.rb
208
208
  - lib/mutant/env.rb
209
209
  - lib/mutant/expression.rb
210
+ - lib/mutant/expression/descendants.rb
210
211
  - lib/mutant/expression/method.rb
211
212
  - lib/mutant/expression/methods.rb
212
213
  - lib/mutant/expression/namespace.rb
@@ -226,6 +227,7 @@ files:
226
227
  - lib/mutant/matcher.rb
227
228
  - lib/mutant/matcher/chain.rb
228
229
  - lib/mutant/matcher/config.rb
230
+ - lib/mutant/matcher/descendants.rb
229
231
  - lib/mutant/matcher/filter.rb
230
232
  - lib/mutant/matcher/method.rb
231
233
  - lib/mutant/matcher/method/instance.rb