mutant 0.8.0 → 0.8.1
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 +4 -4
- data/Changelog.md +7 -0
- data/config/flay.yml +1 -1
- data/config/reek.yml +1 -0
- data/lib/mutant.rb +10 -3
- data/lib/mutant/actor.rb +2 -5
- data/lib/mutant/actor/env.rb +1 -3
- data/lib/mutant/actor/mailbox.rb +2 -4
- data/lib/mutant/actor/receiver.rb +0 -2
- data/lib/mutant/actor/sender.rb +0 -1
- data/lib/mutant/ast.rb +22 -28
- data/lib/mutant/ast/meta.rb +8 -88
- data/lib/mutant/ast/named_children.rb +1 -8
- data/lib/mutant/ast/sexp.rb +0 -2
- data/lib/mutant/cache.rb +1 -3
- data/lib/mutant/cli.rb +9 -19
- data/lib/mutant/color.rb +0 -3
- data/lib/mutant/config.rb +6 -2
- data/lib/mutant/context.rb +2 -4
- data/lib/mutant/context/scope.rb +10 -16
- data/lib/mutant/delegator.rb +0 -3
- data/lib/mutant/diff.rb +8 -17
- data/lib/mutant/env.rb +3 -5
- data/lib/mutant/env/bootstrap.rb +32 -39
- data/lib/mutant/expression.rb +14 -132
- data/lib/mutant/expression/method.rb +25 -42
- data/lib/mutant/expression/methods.rb +17 -29
- data/lib/mutant/expression/namespace.rb +33 -28
- data/lib/mutant/expression/parser.rb +71 -0
- data/lib/mutant/integration.rb +17 -16
- data/lib/mutant/isolation.rb +14 -14
- data/lib/mutant/loader.rb +2 -4
- data/lib/mutant/matcher.rb +1 -11
- data/lib/mutant/matcher/chain.rb +0 -1
- data/lib/mutant/matcher/compiler.rb +19 -52
- data/lib/mutant/matcher/config.rb +65 -5
- data/lib/mutant/matcher/filter.rb +11 -1
- data/lib/mutant/matcher/method.rb +11 -21
- data/lib/mutant/matcher/method/instance.rb +2 -16
- data/lib/mutant/matcher/method/singleton.rb +3 -20
- data/lib/mutant/matcher/methods.rb +11 -21
- data/lib/mutant/matcher/namespace.rb +0 -4
- data/lib/mutant/matcher/null.rb +0 -1
- data/lib/mutant/matcher/scope.rb +0 -12
- data/lib/mutant/meta.rb +0 -1
- data/lib/mutant/meta/example.rb +12 -26
- data/lib/mutant/meta/example/dsl.rb +1 -8
- data/lib/mutant/mutation.rb +6 -14
- data/lib/mutant/mutator.rb +2 -14
- data/lib/mutant/mutator/node.rb +6 -33
- data/lib/mutant/mutator/node/and_asgn.rb +0 -1
- data/lib/mutant/mutator/node/argument.rb +0 -5
- data/lib/mutant/mutator/node/arguments.rb +1 -7
- data/lib/mutant/mutator/node/begin.rb +0 -2
- data/lib/mutant/mutator/node/binary.rb +0 -3
- data/lib/mutant/mutator/node/block.rb +0 -2
- data/lib/mutant/mutator/node/break.rb +0 -1
- data/lib/mutant/mutator/node/case.rb +0 -3
- data/lib/mutant/mutator/node/conditional_loop.rb +0 -1
- data/lib/mutant/mutator/node/const.rb +0 -1
- data/lib/mutant/mutator/node/define.rb +0 -1
- data/lib/mutant/mutator/node/defined.rb +0 -1
- data/lib/mutant/mutator/node/dstr.rb +0 -1
- data/lib/mutant/mutator/node/dsym.rb +0 -1
- data/lib/mutant/mutator/node/generic.rb +0 -1
- data/lib/mutant/mutator/node/if.rb +0 -4
- data/lib/mutant/mutator/node/kwbegin.rb +0 -1
- data/lib/mutant/mutator/node/literal/array.rb +0 -2
- data/lib/mutant/mutator/node/literal/boolean.rb +0 -1
- data/lib/mutant/mutator/node/literal/fixnum.rb +2 -5
- data/lib/mutant/mutator/node/literal/float.rb +1 -4
- data/lib/mutant/mutator/node/literal/hash.rb +0 -3
- data/lib/mutant/mutator/node/literal/nil.rb +0 -1
- data/lib/mutant/mutator/node/literal/range.rb +1 -5
- data/lib/mutant/mutator/node/literal/regex.rb +1 -3
- data/lib/mutant/mutator/node/literal/string.rb +0 -1
- data/lib/mutant/mutator/node/literal/symbol.rb +0 -1
- data/lib/mutant/mutator/node/masgn.rb +0 -1
- data/lib/mutant/mutator/node/match_current_line.rb +0 -1
- data/lib/mutant/mutator/node/mlhs.rb +0 -1
- data/lib/mutant/mutator/node/named_value/access.rb +0 -1
- data/lib/mutant/mutator/node/named_value/constant_assignment.rb +0 -2
- data/lib/mutant/mutator/node/named_value/variable_assignment.rb +0 -2
- data/lib/mutant/mutator/node/next.rb +0 -1
- data/lib/mutant/mutator/node/noop.rb +0 -1
- data/lib/mutant/mutator/node/nthref.rb +0 -1
- data/lib/mutant/mutator/node/op_asgn.rb +0 -1
- data/lib/mutant/mutator/node/or_asgn.rb +1 -2
- data/lib/mutant/mutator/node/resbody.rb +0 -2
- data/lib/mutant/mutator/node/rescue.rb +1 -6
- data/lib/mutant/mutator/node/return.rb +0 -1
- data/lib/mutant/mutator/node/send.rb +16 -17
- data/lib/mutant/mutator/node/send/attribute_assignment.rb +0 -3
- data/lib/mutant/mutator/node/send/binary.rb +0 -1
- data/lib/mutant/mutator/node/send/index.rb +0 -3
- data/lib/mutant/mutator/node/splat.rb +0 -1
- data/lib/mutant/mutator/node/super.rb +0 -1
- data/lib/mutant/mutator/node/when.rb +2 -7
- data/lib/mutant/mutator/node/yield.rb +0 -1
- data/lib/mutant/mutator/node/zsuper.rb +0 -1
- data/lib/mutant/mutator/registry.rb +1 -4
- data/lib/mutant/mutator/util.rb +0 -2
- data/lib/mutant/mutator/util/array.rb +0 -3
- data/lib/mutant/mutator/util/symbol.rb +0 -1
- data/lib/mutant/parallel.rb +3 -9
- data/lib/mutant/parallel/master.rb +7 -17
- data/lib/mutant/parallel/source.rb +2 -7
- data/lib/mutant/parallel/worker.rb +1 -5
- data/lib/mutant/reporter.rb +0 -4
- data/lib/mutant/reporter/cli.rb +1 -8
- data/lib/mutant/reporter/cli/format.rb +7 -18
- data/lib/mutant/reporter/cli/printer.rb +2 -12
- data/lib/mutant/reporter/cli/printer/config.rb +1 -4
- data/lib/mutant/reporter/cli/printer/env_progress.rb +3 -7
- data/lib/mutant/reporter/cli/printer/env_result.rb +0 -1
- data/lib/mutant/reporter/cli/printer/mutation_progress_result.rb +0 -2
- data/lib/mutant/reporter/cli/printer/mutation_result.rb +3 -11
- data/lib/mutant/reporter/cli/printer/status.rb +1 -4
- data/lib/mutant/reporter/cli/printer/status_progressive.rb +1 -3
- data/lib/mutant/reporter/cli/printer/subject_progress.rb +0 -5
- data/lib/mutant/reporter/cli/printer/subject_result.rb +0 -1
- data/lib/mutant/reporter/cli/printer/test_result.rb +0 -1
- data/lib/mutant/reporter/cli/tput.rb +4 -1
- data/lib/mutant/reporter/trace.rb +2 -4
- data/lib/mutant/repository.rb +88 -0
- data/lib/mutant/require_highjack.rb +0 -1
- data/lib/mutant/result.rb +25 -48
- data/lib/mutant/runner.rb +7 -16
- data/lib/mutant/runner/sink.rb +3 -11
- data/lib/mutant/selector.rb +1 -2
- data/lib/mutant/selector/expression.rb +1 -2
- data/lib/mutant/subject.rb +10 -21
- data/lib/mutant/subject/method.rb +11 -12
- data/lib/mutant/subject/method/instance.rb +1 -5
- data/lib/mutant/subject/method/singleton.rb +1 -3
- data/lib/mutant/test.rb +1 -2
- data/lib/mutant/version.rb +2 -2
- data/lib/mutant/warning_filter.rb +2 -7
- data/lib/mutant/zombifier.rb +6 -10
- data/meta/send.rb +8 -0
- data/spec/spec_helper.rb +5 -1
- data/spec/support/corpus.rb +5 -9
- data/spec/support/rb_bug.rb +0 -1
- data/spec/support/rspec.rb +0 -1
- data/spec/support/ruby_vm.rb +0 -2
- data/spec/unit/mutant/ast/meta/send_spec.rb +42 -0
- data/spec/unit/mutant/ast/named_children_spec.rb +51 -0
- data/spec/unit/mutant/ast/sexp_spec.rb +36 -0
- data/spec/unit/mutant/ast_spec.rb +8 -0
- data/spec/unit/mutant/cli_spec.rb +34 -19
- data/spec/unit/mutant/context/scope_spec.rb +11 -0
- data/spec/unit/mutant/env/boostrap_spec.rb +5 -2
- data/spec/unit/mutant/env_spec.rb +14 -15
- data/spec/unit/mutant/expression/method_spec.rb +10 -14
- data/spec/unit/mutant/expression/methods_spec.rb +24 -11
- data/spec/unit/mutant/expression/namespace/flat_spec.rb +5 -6
- data/spec/unit/mutant/expression/namespace/recursive_spec.rb +16 -10
- data/spec/unit/mutant/expression/parser_spec.rb +67 -0
- data/spec/unit/mutant/expression_spec.rb +24 -57
- data/spec/unit/mutant/integration/rspec_spec.rb +7 -7
- data/spec/unit/mutant/integration_spec.rb +2 -2
- data/spec/unit/mutant/isolation_spec.rb +31 -29
- data/spec/unit/mutant/matcher/compiler/subject_prefix_spec.rb +2 -2
- data/spec/unit/mutant/matcher/compiler_spec.rb +27 -58
- data/spec/unit/mutant/matcher/config_spec.rb +45 -0
- data/spec/unit/mutant/matcher/filter_spec.rb +12 -5
- data/spec/unit/mutant/matcher/method/instance_spec.rb +0 -1
- data/spec/unit/mutant/matcher/method/singleton_spec.rb +0 -1
- data/spec/unit/mutant/matcher/namespace_spec.rb +4 -4
- data/spec/unit/mutant/parallel/worker_spec.rb +1 -1
- data/spec/unit/mutant/reporter/cli/printer/config_spec.rb +4 -4
- data/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb +7 -7
- data/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb +2 -2
- data/spec/unit/mutant/reporter/cli/printer/status_progressive_spec.rb +2 -2
- data/spec/unit/mutant/reporter/cli/printer/status_spec.rb +12 -12
- data/spec/unit/mutant/reporter/cli/printer/subject_progress_spec.rb +1 -1
- data/spec/unit/mutant/reporter/cli_spec.rb +9 -10
- data/spec/unit/mutant/repository/diff_spec.rb +80 -0
- data/spec/unit/mutant/repository/subject_filter_spec.rb +28 -0
- data/spec/unit/mutant/result/env_spec.rb +1 -1
- data/spec/unit/mutant/runner_spec.rb +0 -1
- data/spec/unit/mutant/selector/expression_spec.rb +14 -14
- data/spec/unit/mutant/subject/method/instance_spec.rb +2 -2
- data/spec/unit/mutant/subject/method/singleton_spec.rb +2 -2
- data/spec/unit/mutant/subject_spec.rb +5 -2
- metadata +20 -3
- data/spec/support/mutation_verifier.rb +0 -96
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac3f098a786f3940bb0bdc9b291994aa068fbf3d
|
4
|
+
data.tar.gz: 4acf7c5f8e0d04bbbe87ad2ebfb403650372cf4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce34952eb570ea87bb7169785b556431eb9820dea70261f0772c89e3d648cf70a4f819b9be86448f6b4c8ea88b0721c6f3aa6c3f9e3680127f80c805826c6fb2
|
7
|
+
data.tar.gz: 89eb14bfeb66f63899033195bfbec8562c821e19fea0aa51997b8e57fcb3897b7de26e0d5b642d14c7c276c50b6d28f3df0fbc23741a5944523ff6e0c5117c2e
|
data/Changelog.md
CHANGED
data/config/flay.yml
CHANGED
data/config/reek.yml
CHANGED
@@ -130,6 +130,7 @@ UtilityFunction:
|
|
130
130
|
- Mutant::Integration::Null#call
|
131
131
|
- Mutant::Integration::Rspec#parse_example
|
132
132
|
- Mutant::Meta::Example::Verification#format_mutation
|
133
|
+
- Mutant::Repository::Diff#tracks? # intentional, private
|
133
134
|
- Mutant::Reporter::CLI::Format::Progressive#new_buffer
|
134
135
|
- Mutant::Reporter::CLI::Printer::StatusProgressive#object # False positive calls super
|
135
136
|
- Mutant::Integration::Rspec#parse_expression # intentional, private
|
data/lib/mutant.rb
CHANGED
@@ -33,7 +33,6 @@ module Mutant
|
|
33
33
|
# @return [Boolean]
|
34
34
|
#
|
35
35
|
# @api private
|
36
|
-
#
|
37
36
|
def self.ci?
|
38
37
|
ENV.key?('CI')
|
39
38
|
end
|
@@ -143,6 +142,7 @@ require 'mutant/matcher/scope'
|
|
143
142
|
require 'mutant/matcher/filter'
|
144
143
|
require 'mutant/matcher/null'
|
145
144
|
require 'mutant/expression'
|
145
|
+
require 'mutant/expression/parser'
|
146
146
|
require 'mutant/expression/method'
|
147
147
|
require 'mutant/expression/methods'
|
148
148
|
require 'mutant/expression/namespace'
|
@@ -174,6 +174,7 @@ require 'mutant/reporter/cli/printer/status_progressive'
|
|
174
174
|
require 'mutant/reporter/cli/printer/test_result'
|
175
175
|
require 'mutant/reporter/cli/tput'
|
176
176
|
require 'mutant/reporter/cli/format'
|
177
|
+
require 'mutant/repository'
|
177
178
|
require 'mutant/zombifier'
|
178
179
|
|
179
180
|
module Mutant
|
@@ -184,7 +185,7 @@ module Mutant
|
|
184
185
|
DEFAULT = new(
|
185
186
|
debug: false,
|
186
187
|
fail_fast: false,
|
187
|
-
integration: Integration::Null
|
188
|
+
integration: Integration::Null,
|
188
189
|
matcher: Matcher::Config::DEFAULT,
|
189
190
|
includes: EMPTY_ARRAY,
|
190
191
|
requires: EMPTY_ARRAY,
|
@@ -192,7 +193,13 @@ module Mutant
|
|
192
193
|
reporter: Reporter::CLI.build($stdout),
|
193
194
|
zombie: false,
|
194
195
|
jobs: Mutant.ci? ? CI_DEFAULT_PROCESSOR_COUNT : ::Parallel.processor_count,
|
195
|
-
expected_coverage: Rational(1)
|
196
|
+
expected_coverage: Rational(1),
|
197
|
+
expression_parser: Expression::Parser.new([
|
198
|
+
Expression::Method,
|
199
|
+
Expression::Methods,
|
200
|
+
Expression::Namespace::Exact,
|
201
|
+
Expression::Namespace::Recursive
|
202
|
+
])
|
196
203
|
)
|
197
204
|
end # Config
|
198
205
|
end # Mutant
|
data/lib/mutant/actor.rb
CHANGED
@@ -10,12 +10,11 @@ module Mutant
|
|
10
10
|
Undefined = Class.new do
|
11
11
|
INSPECT = 'Mutant::Actor::Undefined'.freeze
|
12
12
|
|
13
|
-
#
|
13
|
+
# Object inspection
|
14
14
|
#
|
15
15
|
# @return [String]
|
16
16
|
#
|
17
17
|
# @api private
|
18
|
-
#
|
19
18
|
def inspect
|
20
19
|
INSPECT
|
21
20
|
end
|
@@ -25,7 +24,7 @@ module Mutant
|
|
25
24
|
class Message
|
26
25
|
include Concord::Public.new(:type, :payload)
|
27
26
|
|
28
|
-
#
|
27
|
+
# New message
|
29
28
|
#
|
30
29
|
# @param [Symbol] type
|
31
30
|
# @param [Object] payload
|
@@ -33,7 +32,6 @@ module Mutant
|
|
33
32
|
# @return [Message]
|
34
33
|
#
|
35
34
|
# @api private
|
36
|
-
#
|
37
35
|
def self.new(_type, _payload = Undefined)
|
38
36
|
super
|
39
37
|
end
|
@@ -51,7 +49,6 @@ module Mutant
|
|
51
49
|
# @return [Object]
|
52
50
|
#
|
53
51
|
# @api private
|
54
|
-
#
|
55
52
|
def call(type)
|
56
53
|
other.call(Message.new(type, mailbox.sender))
|
57
54
|
message = mailbox.receiver.call
|
data/lib/mutant/actor/env.rb
CHANGED
@@ -9,7 +9,6 @@ module Mutant
|
|
9
9
|
# @return [Actor::Sender]
|
10
10
|
#
|
11
11
|
# @api private
|
12
|
-
#
|
13
12
|
def spawn
|
14
13
|
mailbox = new_mailbox
|
15
14
|
|
@@ -20,12 +19,11 @@ module Mutant
|
|
20
19
|
mailbox.sender
|
21
20
|
end
|
22
21
|
|
23
|
-
#
|
22
|
+
# New unbound mailbox
|
24
23
|
#
|
25
24
|
# @return [Mailbox]
|
26
25
|
#
|
27
26
|
# @api private
|
28
|
-
#
|
29
27
|
def new_mailbox
|
30
28
|
Mailbox.new
|
31
29
|
end
|
data/lib/mutant/actor/mailbox.rb
CHANGED
@@ -4,12 +4,11 @@ module Mutant
|
|
4
4
|
class Mailbox
|
5
5
|
include Adamantium::Flat, Concord::Public.new(:receiver, :sender)
|
6
6
|
|
7
|
-
#
|
7
|
+
# New mailbox
|
8
8
|
#
|
9
9
|
# @return [Mailbox]
|
10
10
|
#
|
11
11
|
# @api private
|
12
|
-
#
|
13
12
|
def self.new
|
14
13
|
mutex = Mutex.new
|
15
14
|
condition_variable = ConditionVariable.new
|
@@ -21,14 +20,13 @@ module Mutant
|
|
21
20
|
)
|
22
21
|
end
|
23
22
|
|
24
|
-
#
|
23
|
+
# Binding for RPC to other actors
|
25
24
|
#
|
26
25
|
# @param [Actor::Sender] other
|
27
26
|
#
|
28
27
|
# @return [Binding]
|
29
28
|
#
|
30
29
|
# @api private
|
31
|
-
#
|
32
30
|
def bind(other)
|
33
31
|
Binding.new(self, other)
|
34
32
|
end
|
@@ -9,7 +9,6 @@ module Mutant
|
|
9
9
|
# @return [Object]
|
10
10
|
#
|
11
11
|
# @api private
|
12
|
-
#
|
13
12
|
def call
|
14
13
|
2.times do
|
15
14
|
message = try_blocking_receive
|
@@ -29,7 +28,6 @@ module Mutant
|
|
29
28
|
# if there is a message
|
30
29
|
#
|
31
30
|
# @api private
|
32
|
-
#
|
33
31
|
def try_blocking_receive
|
34
32
|
mutex.synchronize do
|
35
33
|
if messages.empty?
|
data/lib/mutant/actor/sender.rb
CHANGED
data/lib/mutant/ast.rb
CHANGED
@@ -2,32 +2,6 @@ module Mutant
|
|
2
2
|
# AST helpers
|
3
3
|
module AST
|
4
4
|
|
5
|
-
# Walk all ast nodes
|
6
|
-
#
|
7
|
-
# @param [Parser::AST::Node] root
|
8
|
-
# @param [Array<Parser::AST::Node>] stack
|
9
|
-
#
|
10
|
-
# @yield [Parser::AST::Node]
|
11
|
-
# all nodes recursively including root
|
12
|
-
#
|
13
|
-
# @return [self]
|
14
|
-
#
|
15
|
-
# @api private
|
16
|
-
#
|
17
|
-
def self.walk(node, stack, &block)
|
18
|
-
fail ArgumentError, 'block expected' unless block_given?
|
19
|
-
|
20
|
-
block.call(node, stack)
|
21
|
-
node.children.grep(Parser::AST::Node).each do |child|
|
22
|
-
stack.push(child)
|
23
|
-
walk(child, stack, &block)
|
24
|
-
stack.pop
|
25
|
-
end
|
26
|
-
|
27
|
-
self
|
28
|
-
end
|
29
|
-
private_class_method :walk
|
30
|
-
|
31
5
|
# Find last node satisfying predicate (as block)
|
32
6
|
#
|
33
7
|
# @return [Parser::AST::Node]
|
@@ -42,17 +16,37 @@ module Mutant
|
|
42
16
|
# otherwise
|
43
17
|
#
|
44
18
|
# @api private
|
45
|
-
#
|
46
19
|
def self.find_last_path(node, &predicate)
|
47
20
|
fail ArgumentError, 'block expected' unless block_given?
|
48
21
|
path = []
|
49
22
|
walk(node, [node]) do |candidate, stack|
|
50
|
-
if predicate.call(candidate
|
23
|
+
if predicate.call(candidate)
|
51
24
|
path = stack.dup
|
52
25
|
end
|
53
26
|
end
|
54
27
|
path
|
55
28
|
end
|
56
29
|
|
30
|
+
# Walk all ast nodes keeping track of path
|
31
|
+
#
|
32
|
+
# @param [Parser::AST::Node] root
|
33
|
+
# @param [Array<Parser::AST::Node>] stack
|
34
|
+
#
|
35
|
+
# @yield [Parser::AST::Node]
|
36
|
+
# all nodes visited recursively including root
|
37
|
+
#
|
38
|
+
# @return [undefined]
|
39
|
+
#
|
40
|
+
# @api private
|
41
|
+
def self.walk(node, stack, &block)
|
42
|
+
block.call(node, stack)
|
43
|
+
node.children.grep(Parser::AST::Node) do |child|
|
44
|
+
stack.push(child)
|
45
|
+
walk(child, stack, &block)
|
46
|
+
stack.pop
|
47
|
+
end
|
48
|
+
end
|
49
|
+
private_class_method :walk
|
50
|
+
|
57
51
|
end # AST
|
58
52
|
end # Mutant
|
data/lib/mutant/ast/meta.rb
CHANGED
@@ -3,65 +3,27 @@ module Mutant
|
|
3
3
|
# Node meta information mixin
|
4
4
|
module Meta
|
5
5
|
|
6
|
-
REGISTRY = {}
|
7
|
-
|
8
|
-
# Return meta for node
|
9
|
-
#
|
10
|
-
# @param [Parser::AST::Node] node
|
11
|
-
#
|
12
|
-
# @return [Meta]
|
13
|
-
#
|
14
|
-
# @api private
|
15
|
-
#
|
16
|
-
def self.for(node)
|
17
|
-
REGISTRY.fetch(node.type, Generic).new(node)
|
18
|
-
end
|
19
|
-
|
20
|
-
# Mixin to define meta nodes
|
21
|
-
class Node < Module
|
22
|
-
include Concord.new(:type)
|
23
|
-
|
24
|
-
CONCORD = Concord.new(:node)
|
25
|
-
|
26
|
-
# Hook called when module gets included
|
27
|
-
#
|
28
|
-
# @param [Class, Module] host
|
29
|
-
#
|
30
|
-
# @return [undefined]
|
31
|
-
#
|
32
|
-
# @api private
|
33
|
-
#
|
34
|
-
def included(host)
|
35
|
-
REGISTRY[type] = host
|
36
|
-
host.class_eval do
|
37
|
-
include CONCORD, NamedChildren
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
end # Node
|
42
|
-
|
43
6
|
# Metadata for resbody nods
|
44
7
|
class Resbody
|
45
|
-
include
|
8
|
+
include NamedChildren, Concord.new(:node)
|
46
9
|
|
47
10
|
children :captures, :assignment, :body
|
48
11
|
end # Resbody
|
49
12
|
|
50
13
|
# Metadata for send nodes
|
51
14
|
class Send
|
52
|
-
include
|
15
|
+
include NamedChildren, Concord.new(:node)
|
53
16
|
|
54
17
|
children :receiver, :selector
|
55
18
|
|
56
19
|
INDEX_ASSIGNMENT_SELECTOR = :[]=
|
57
20
|
ATTRIBUTE_ASSIGNMENT_SELECTOR_SUFFIX = '='.freeze
|
58
21
|
|
59
|
-
#
|
22
|
+
# Arguments of mutated node
|
60
23
|
#
|
61
24
|
# @return [Enumerable<Parser::AST::Node>]
|
62
25
|
#
|
63
26
|
# @api private
|
64
|
-
#
|
65
27
|
alias_method :arguments, :remaining_children
|
66
28
|
|
67
29
|
# Test if AST node is a valid assignment target
|
@@ -69,7 +31,6 @@ module Mutant
|
|
69
31
|
# @return [Boolean]
|
70
32
|
#
|
71
33
|
# @api private
|
72
|
-
#
|
73
34
|
def assignment?
|
74
35
|
index_assignment? || attribute_assignment?
|
75
36
|
end
|
@@ -79,9 +40,9 @@ module Mutant
|
|
79
40
|
# @return [Boolean]
|
80
41
|
#
|
81
42
|
# @api private
|
82
|
-
#
|
83
43
|
def attribute_assignment?
|
84
|
-
|
44
|
+
!Types::METHOD_OPERATORS.include?(selector) &&
|
45
|
+
selector.to_s.end_with?(ATTRIBUTE_ASSIGNMENT_SELECTOR_SUFFIX)
|
85
46
|
end
|
86
47
|
|
87
48
|
# Test if AST node is an index assign
|
@@ -89,9 +50,8 @@ module Mutant
|
|
89
50
|
# @return [Boolean]
|
90
51
|
#
|
91
52
|
# @api private
|
92
|
-
#
|
93
53
|
def index_assignment?
|
94
|
-
|
54
|
+
selector.equal?(INDEX_ASSIGNMENT_SELECTOR)
|
95
55
|
end
|
96
56
|
|
97
57
|
# Test for binary operator implemented as method
|
@@ -99,51 +59,11 @@ module Mutant
|
|
99
59
|
# @return [Boolean]
|
100
60
|
#
|
101
61
|
# @api private
|
102
|
-
#
|
103
62
|
def binary_method_operator?
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
private
|
108
|
-
|
109
|
-
# Test for index assignment operator
|
110
|
-
#
|
111
|
-
# @return [Boolean]
|
112
|
-
#
|
113
|
-
# @api private
|
114
|
-
#
|
115
|
-
def index_assignment_selector?
|
116
|
-
selector.equal?(INDEX_ASSIGNMENT_SELECTOR)
|
117
|
-
end
|
118
|
-
|
119
|
-
# Test for attribute assignment selector
|
120
|
-
#
|
121
|
-
# @return [Boolean]
|
122
|
-
#
|
123
|
-
# @api private
|
124
|
-
#
|
125
|
-
def attribute_assignment_selector?
|
126
|
-
!Types::METHOD_OPERATORS.include?(selector) && selector.to_s.end_with?(ATTRIBUTE_ASSIGNMENT_SELECTOR_SUFFIX)
|
63
|
+
Types::BINARY_METHOD_OPERATORS.include?(selector)
|
127
64
|
end
|
128
65
|
|
129
66
|
end # Send
|
130
|
-
|
131
|
-
# Generic node metadata
|
132
|
-
class Generic
|
133
|
-
include Adamantium, Concord.new(:node)
|
134
|
-
|
135
|
-
# Test if AST node is a valid assign target
|
136
|
-
#
|
137
|
-
# @return [Boolean]
|
138
|
-
#
|
139
|
-
# @api private
|
140
|
-
#
|
141
|
-
def assignment?
|
142
|
-
Types::ASSIGNABLE_VARIABLES.include?(node.type)
|
143
|
-
end
|
144
|
-
|
145
|
-
end # Generic
|
146
|
-
|
147
|
-
end #
|
67
|
+
end # Meta
|
148
68
|
end # AST
|
149
69
|
end # Mutant
|
@@ -11,10 +11,7 @@ module Mutant
|
|
11
11
|
# @return [undefined]
|
12
12
|
#
|
13
13
|
# @api private
|
14
|
-
#
|
15
14
|
def self.included(host)
|
16
|
-
super
|
17
|
-
|
18
15
|
host.class_eval do
|
19
16
|
include InstanceMethods
|
20
17
|
extend ClassMethods
|
@@ -26,12 +23,11 @@ module Mutant
|
|
26
23
|
|
27
24
|
private
|
28
25
|
|
29
|
-
#
|
26
|
+
# Mutated nodes children
|
30
27
|
#
|
31
28
|
# @return [Array<Parser::AST::Node]
|
32
29
|
#
|
33
30
|
# @api private
|
34
|
-
#
|
35
31
|
def children
|
36
32
|
node.children
|
37
33
|
end
|
@@ -51,7 +47,6 @@ module Mutant
|
|
51
47
|
# @return [undefined]
|
52
48
|
#
|
53
49
|
# @api private
|
54
|
-
#
|
55
50
|
def define_named_child(name, index)
|
56
51
|
define_method(name) do
|
57
52
|
children.at(index)
|
@@ -65,7 +60,6 @@ module Mutant
|
|
65
60
|
# @return [undefined]
|
66
61
|
#
|
67
62
|
# @api private
|
68
|
-
#
|
69
63
|
def define_remaining_children(names)
|
70
64
|
define_method(:remaining_children_with_index) do
|
71
65
|
children.each_with_index.drop(names.length)
|
@@ -85,7 +79,6 @@ module Mutant
|
|
85
79
|
# @return [undefined]
|
86
80
|
#
|
87
81
|
# @api private
|
88
|
-
#
|
89
82
|
def children(*names)
|
90
83
|
names.each_with_index do |name, index|
|
91
84
|
define_named_child(name, index)
|