mutant 0.8.8 → 0.8.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +9 -0
- data/README.md +1 -1
- data/Rakefile +12 -8
- data/bin/mutant +5 -1
- data/config/flay.yml +1 -1
- data/lib/mutant.rb +18 -17
- data/lib/mutant/actor.rb +1 -7
- data/lib/mutant/actor/env.rb +0 -4
- data/lib/mutant/actor/mailbox.rb +0 -4
- data/lib/mutant/actor/receiver.rb +0 -4
- data/lib/mutant/actor/sender.rb +0 -2
- data/lib/mutant/ast.rb +1 -5
- data/lib/mutant/ast/meta/const.rb +0 -2
- data/lib/mutant/ast/meta/optarg.rb +0 -2
- data/lib/mutant/ast/meta/send.rb +0 -12
- data/lib/mutant/ast/named_children.rb +0 -10
- data/lib/mutant/ast/sexp.rb +1 -5
- data/lib/mutant/cli.rb +19 -38
- data/lib/mutant/color.rb +1 -7
- data/lib/mutant/config.rb +11 -7
- data/lib/mutant/context.rb +0 -4
- data/lib/mutant/context/scope.rb +0 -18
- data/lib/mutant/delegator.rb +0 -6
- data/lib/mutant/diff.rb +0 -18
- data/lib/mutant/env.rb +8 -24
- data/lib/mutant/env/bootstrap.rb +18 -41
- data/lib/mutant/expression.rb +0 -8
- data/lib/mutant/expression/method.rb +6 -7
- data/lib/mutant/expression/methods.rb +5 -9
- data/lib/mutant/expression/namespace.rb +0 -13
- data/lib/mutant/expression/parser.rb +0 -6
- data/lib/mutant/integration.rb +2 -20
- data/lib/mutant/isolation.rb +0 -4
- data/lib/mutant/loader.rb +20 -35
- data/lib/mutant/matcher.rb +1 -1
- data/lib/mutant/matcher/chain.rb +1 -3
- data/lib/mutant/matcher/compiler.rb +0 -8
- data/lib/mutant/matcher/config.rb +2 -10
- data/lib/mutant/matcher/filter.rb +1 -3
- data/lib/mutant/matcher/method.rb +4 -26
- data/lib/mutant/matcher/method/instance.rb +1 -7
- data/lib/mutant/matcher/method/singleton.rb +0 -12
- data/lib/mutant/matcher/methods.rb +1 -19
- data/lib/mutant/matcher/namespace.rb +1 -7
- data/lib/mutant/matcher/null.rb +1 -3
- data/lib/mutant/matcher/scope.rb +1 -5
- data/lib/mutant/matcher/static.rb +0 -2
- data/lib/mutant/meta.rb +0 -2
- data/lib/mutant/meta/example.rb +0 -28
- data/lib/mutant/meta/example/dsl.rb +2 -16
- data/lib/mutant/mutation.rb +9 -18
- data/lib/mutant/mutator.rb +0 -24
- data/lib/mutant/mutator/node.rb +1 -33
- data/lib/mutant/mutator/node/and_asgn.rb +0 -2
- data/lib/mutant/mutator/node/argument.rb +0 -10
- data/lib/mutant/mutator/node/arguments.rb +0 -12
- data/lib/mutant/mutator/node/begin.rb +0 -4
- data/lib/mutant/mutator/node/binary.rb +2 -11
- data/lib/mutant/mutator/node/block.rb +0 -6
- data/lib/mutant/mutator/node/break.rb +0 -2
- data/lib/mutant/mutator/node/case.rb +0 -6
- data/lib/mutant/mutator/node/conditional_loop.rb +0 -2
- data/lib/mutant/mutator/node/const.rb +1 -3
- data/lib/mutant/mutator/node/define.rb +4 -11
- data/lib/mutant/mutator/node/defined.rb +0 -2
- data/lib/mutant/mutator/node/dstr.rb +0 -2
- data/lib/mutant/mutator/node/dsym.rb +0 -2
- data/lib/mutant/mutator/node/generic.rb +1 -3
- data/lib/mutant/mutator/node/if.rb +0 -8
- data/lib/mutant/mutator/node/kwbegin.rb +0 -2
- data/lib/mutant/mutator/node/literal/array.rb +0 -4
- data/lib/mutant/mutator/node/literal/boolean.rb +0 -2
- data/lib/mutant/mutator/node/literal/fixnum.rb +0 -6
- data/lib/mutant/mutator/node/literal/float.rb +0 -6
- data/lib/mutant/mutator/node/literal/hash.rb +0 -6
- data/lib/mutant/mutator/node/literal/nil.rb +0 -2
- data/lib/mutant/mutator/node/literal/range.rb +0 -8
- data/lib/mutant/mutator/node/literal/regex.rb +0 -4
- data/lib/mutant/mutator/node/literal/string.rb +0 -2
- data/lib/mutant/mutator/node/literal/symbol.rb +0 -2
- data/lib/mutant/mutator/node/masgn.rb +0 -2
- data/lib/mutant/mutator/node/match_current_line.rb +0 -2
- data/lib/mutant/mutator/node/mlhs.rb +0 -2
- data/lib/mutant/mutator/node/named_value/access.rb +0 -8
- data/lib/mutant/mutator/node/named_value/constant_assignment.rb +1 -7
- data/lib/mutant/mutator/node/named_value/variable_assignment.rb +0 -4
- data/lib/mutant/mutator/node/next.rb +0 -2
- data/lib/mutant/mutator/node/noop.rb +0 -2
- data/lib/mutant/mutator/node/nthref.rb +0 -2
- data/lib/mutant/mutator/node/op_asgn.rb +0 -2
- data/lib/mutant/mutator/node/or_asgn.rb +0 -2
- data/lib/mutant/mutator/node/resbody.rb +0 -4
- data/lib/mutant/mutator/node/rescue.rb +0 -10
- data/lib/mutant/mutator/node/return.rb +0 -2
- data/lib/mutant/mutator/node/send.rb +4 -32
- data/lib/mutant/mutator/node/send/attribute_assignment.rb +0 -6
- data/lib/mutant/mutator/node/send/binary.rb +0 -6
- data/lib/mutant/mutator/node/send/index.rb +0 -6
- data/lib/mutant/mutator/node/splat.rb +0 -2
- data/lib/mutant/mutator/node/super.rb +0 -2
- data/lib/mutant/mutator/node/when.rb +0 -10
- data/lib/mutant/mutator/node/yield.rb +0 -2
- data/lib/mutant/mutator/node/zsuper.rb +0 -2
- data/lib/mutant/mutator/registry.rb +0 -6
- data/lib/mutant/mutator/util.rb +0 -4
- data/lib/mutant/mutator/util/array.rb +0 -6
- data/lib/mutant/mutator/util/symbol.rb +0 -2
- data/lib/mutant/parallel.rb +21 -17
- data/lib/mutant/parallel/master.rb +0 -28
- data/lib/mutant/parallel/source.rb +0 -10
- data/lib/mutant/parallel/worker.rb +15 -10
- data/lib/mutant/parser.rb +23 -0
- data/lib/mutant/reporter.rb +5 -8
- data/lib/mutant/reporter/cli.rb +1 -15
- data/lib/mutant/reporter/cli/format.rb +3 -25
- data/lib/mutant/reporter/cli/printer.rb +0 -18
- data/lib/mutant/reporter/cli/printer/config.rb +0 -2
- data/lib/mutant/reporter/cli/printer/env_progress.rb +0 -2
- data/lib/mutant/reporter/cli/printer/env_result.rb +0 -2
- data/lib/mutant/reporter/cli/printer/mutation_progress_result.rb +0 -4
- data/lib/mutant/reporter/cli/printer/mutation_result.rb +0 -16
- data/lib/mutant/reporter/cli/printer/status.rb +0 -6
- data/lib/mutant/reporter/cli/printer/status_progressive.rb +0 -4
- data/lib/mutant/reporter/cli/printer/subject_progress.rb +0 -8
- data/lib/mutant/reporter/cli/printer/subject_result.rb +0 -2
- data/lib/mutant/reporter/cli/printer/test_result.rb +0 -2
- data/lib/mutant/reporter/cli/tput.rb +0 -4
- data/lib/mutant/repository.rb +4 -22
- data/lib/mutant/require_highjack.rb +0 -2
- data/lib/mutant/result.rb +23 -43
- data/lib/mutant/runner.rb +7 -20
- data/lib/mutant/runner/sink.rb +43 -86
- data/lib/mutant/selector.rb +0 -2
- data/lib/mutant/selector/expression.rb +0 -2
- data/lib/mutant/subject.rb +0 -22
- data/lib/mutant/subject/method.rb +2 -10
- data/lib/mutant/subject/method/instance.rb +0 -6
- data/lib/mutant/subject/method/singleton.rb +0 -2
- data/lib/mutant/test.rb +4 -3
- data/lib/mutant/version.rb +1 -1
- data/lib/mutant/warning_filter.rb +0 -10
- data/lib/mutant/zombifier.rb +5 -20
- data/meta/or_asgn.rb +6 -0
- data/meta/send.rb +29 -0
- data/mutant-rspec.gemspec +1 -1
- data/spec/integration/mutant/rspec_spec.rb +1 -1
- data/spec/integrations.yml +2 -3
- data/spec/shared/method_matcher_behavior.rb +7 -7
- data/spec/spec_helper.rb +2 -9
- data/spec/support/corpus.rb +37 -30
- data/spec/support/rb_bug.rb +1 -2
- data/spec/support/ruby_vm.rb +6 -3
- data/spec/support/shared_context.rb +19 -20
- data/spec/unit/mutant/actor/binding_spec.rb +6 -6
- data/spec/unit/mutant/actor/env_spec.rb +2 -2
- data/spec/unit/mutant/actor/mailbox_spec.rb +6 -6
- data/spec/unit/mutant/actor/message_spec.rb +2 -2
- data/spec/unit/mutant/actor/receiver_spec.rb +4 -4
- data/spec/unit/mutant/actor/sender_spec.rb +6 -6
- data/spec/unit/mutant/ast_spec.rb +9 -0
- data/spec/unit/mutant/cli_spec.rb +16 -10
- data/spec/unit/mutant/context/scope/root_spec.rb +1 -1
- data/spec/unit/mutant/context/scope/unqualified_name_spec.rb +1 -1
- data/spec/unit/mutant/context/scope_spec.rb +3 -3
- data/spec/unit/mutant/context_spec.rb +0 -22
- data/spec/unit/mutant/env/boostrap_spec.rb +34 -41
- data/spec/unit/mutant/env_spec.rb +74 -32
- data/spec/unit/mutant/integration/rspec_spec.rb +23 -17
- data/spec/unit/mutant/integration_spec.rb +4 -4
- data/spec/unit/mutant/isolation_spec.rb +4 -4
- data/spec/unit/mutant/loader_spec.rb +42 -0
- data/spec/unit/mutant/matcher/compiler_spec.rb +3 -3
- data/spec/unit/mutant/matcher/config_spec.rb +1 -1
- data/spec/unit/mutant/matcher/method/instance_spec.rb +8 -1
- data/spec/unit/mutant/matcher/method/singleton_spec.rb +8 -1
- data/spec/unit/mutant/matcher/namespace_spec.rb +7 -8
- data/spec/unit/mutant/matcher/null_spec.rb +3 -2
- data/spec/unit/mutant/mutation_spec.rb +11 -5
- data/spec/unit/mutant/mutator/registry_spec.rb +1 -1
- data/spec/unit/mutant/parallel/master_spec.rb +9 -9
- data/spec/unit/mutant/parallel/source/array_spec.rb +3 -3
- data/spec/unit/mutant/parallel/worker_spec.rb +5 -5
- data/spec/unit/mutant/parallel_spec.rb +4 -4
- data/spec/unit/mutant/parser_spec.rb +24 -0
- data/spec/unit/mutant/reporter/cli/printer_spec.rb +3 -3
- data/spec/unit/mutant/reporter/cli/tput_spec.rb +2 -2
- data/spec/unit/mutant/reporter/cli_spec.rb +7 -7
- data/spec/unit/mutant/reporter/null_spec.rb +5 -4
- data/spec/unit/mutant/repository/diff_spec.rb +30 -18
- data/spec/unit/mutant/repository/subject_filter_spec.rb +5 -5
- data/spec/unit/mutant/require_highjack_spec.rb +1 -1
- data/spec/unit/mutant/result/env_spec.rb +9 -9
- data/spec/unit/mutant/result/subject_spec.rb +5 -5
- data/spec/unit/mutant/runner/driver_spec.rb +4 -4
- data/spec/unit/mutant/runner/{sink/mutation_spec.rb → sink_spec.rb} +16 -4
- data/spec/unit/mutant/runner_spec.rb +31 -31
- data/spec/unit/mutant/selector/expression_spec.rb +8 -8
- data/spec/unit/mutant/subject/method/instance_spec.rb +9 -3
- data/spec/unit/mutant/subject/method/singleton_spec.rb +1 -1
- data/spec/unit/mutant/subject_spec.rb +1 -5
- data/spec/unit/mutant_spec.rb +3 -3
- metadata +9 -15
- data/config/mutant.yml +0 -14
- data/lib/mutant/cache.rb +0 -29
- data/lib/mutant/reporter/trace.rb +0 -36
- data/spec/support/rspec.rb +0 -21
- data/spec/unit/mutant/cache_spec.rb +0 -22
- data/spec/unit/mutant/loader/eval_spec.rb +0 -44
- data/spec/unit/mutant/reporter/trace_spec.rb +0 -21
- data/test_app/Gemfile.rspec3.2 +0 -7
@@ -18,11 +18,9 @@ module Mutant
|
|
18
18
|
|
19
19
|
# Matched subjects
|
20
20
|
#
|
21
|
-
# @param [Env] env
|
21
|
+
# @param [Env::Bootstrap] env
|
22
22
|
#
|
23
23
|
# @return [Enumerable<Subject>]
|
24
|
-
#
|
25
|
-
# @api private
|
26
24
|
def call(env)
|
27
25
|
evaluator.call(scope, target_method, env)
|
28
26
|
end
|
@@ -30,7 +28,7 @@ module Mutant
|
|
30
28
|
# Abstract method match evaluator
|
31
29
|
#
|
32
30
|
# Present to avoid passing the env argument around in case the
|
33
|
-
# logic would be
|
31
|
+
# logic would be implemented directly on the Matcher::Method
|
34
32
|
# instance
|
35
33
|
class Evaluator
|
36
34
|
include AbstractType,
|
@@ -42,8 +40,6 @@ module Mutant
|
|
42
40
|
# Matched subjects
|
43
41
|
#
|
44
42
|
# @return [Enumerable<Subject>]
|
45
|
-
#
|
46
|
-
# @api private
|
47
43
|
def call
|
48
44
|
return EMPTY_ARRAY if skip?
|
49
45
|
|
@@ -55,8 +51,6 @@ module Mutant
|
|
55
51
|
# Test if method should be skipped
|
56
52
|
#
|
57
53
|
# @return [Truthy]
|
58
|
-
#
|
59
|
-
# @api private
|
60
54
|
def skip?
|
61
55
|
location = source_location
|
62
56
|
if location.nil? || BLACKLIST.match(location.first)
|
@@ -69,8 +63,6 @@ module Mutant
|
|
69
63
|
# Target method name
|
70
64
|
#
|
71
65
|
# @return [String]
|
72
|
-
#
|
73
|
-
# @api private
|
74
66
|
def method_name
|
75
67
|
target_method.name
|
76
68
|
end
|
@@ -78,8 +70,6 @@ module Mutant
|
|
78
70
|
# Target context
|
79
71
|
#
|
80
72
|
# @return [Context::Scope]
|
81
|
-
#
|
82
|
-
# @api private
|
83
73
|
def context
|
84
74
|
Context::Scope.new(scope, source_path)
|
85
75
|
end
|
@@ -87,27 +77,21 @@ module Mutant
|
|
87
77
|
# Root source node
|
88
78
|
#
|
89
79
|
# @return [Parser::AST::Node]
|
90
|
-
#
|
91
|
-
# @api private
|
92
80
|
def ast
|
93
|
-
env.
|
81
|
+
env.parser.call(source_path)
|
94
82
|
end
|
95
83
|
|
96
84
|
# Path to source
|
97
85
|
#
|
98
86
|
# @return [Pathname]
|
99
|
-
#
|
100
|
-
# @api private
|
101
87
|
def source_path
|
102
|
-
|
88
|
+
env.config.pathname.new(source_location.first)
|
103
89
|
end
|
104
90
|
memoize :source_path
|
105
91
|
|
106
92
|
# Source file line
|
107
93
|
#
|
108
94
|
# @return [Fixnum]
|
109
|
-
#
|
110
|
-
# @api private
|
111
95
|
def source_line
|
112
96
|
source_location.last
|
113
97
|
end
|
@@ -115,8 +99,6 @@ module Mutant
|
|
115
99
|
# Full source location
|
116
100
|
#
|
117
101
|
# @return [Array{String,Fixnum}]
|
118
|
-
#
|
119
|
-
# @api private
|
120
102
|
def source_location
|
121
103
|
target_method.source_location
|
122
104
|
end
|
@@ -128,8 +110,6 @@ module Mutant
|
|
128
110
|
#
|
129
111
|
# @return [nil]
|
130
112
|
# otherwise
|
131
|
-
#
|
132
|
-
# @api private
|
133
113
|
def subject
|
134
114
|
node = matched_node_path.last || return
|
135
115
|
self.class::SUBJECT_CLASS.new(context, node)
|
@@ -139,8 +119,6 @@ module Mutant
|
|
139
119
|
# Matched node path
|
140
120
|
#
|
141
121
|
# @return [Array<Parser::AST::Node>]
|
142
|
-
#
|
143
|
-
# @api private
|
144
122
|
def matched_node_path
|
145
123
|
AST.find_last_path(ast, &method(:match?))
|
146
124
|
end
|
@@ -10,8 +10,6 @@ module Mutant
|
|
10
10
|
# @param [UnboundMethod] method
|
11
11
|
#
|
12
12
|
# @return [Matcher::Method::Instance]
|
13
|
-
#
|
14
|
-
# @api private
|
15
13
|
def self.new(scope, target_method)
|
16
14
|
name = target_method.name
|
17
15
|
evaluator =
|
@@ -36,15 +34,13 @@ module Mutant
|
|
36
34
|
# @param [Parser::AST::Node] node
|
37
35
|
#
|
38
36
|
# @return [Boolean]
|
39
|
-
#
|
40
|
-
# @api private
|
41
37
|
def match?(node)
|
42
38
|
n_def?(node) &&
|
43
39
|
node.location.line.equal?(source_line) &&
|
44
40
|
node.children.fetch(NAME_INDEX).equal?(method_name)
|
45
41
|
end
|
46
42
|
|
47
|
-
# Evaluator specialized for memoized instance
|
43
|
+
# Evaluator specialized for memoized instance methods
|
48
44
|
class Memoized < self
|
49
45
|
SUBJECT_CLASS = Subject::Method::Instance::Memoized
|
50
46
|
|
@@ -53,8 +49,6 @@ module Mutant
|
|
53
49
|
# Source location
|
54
50
|
#
|
55
51
|
# @return [Array{String,Fixnum}]
|
56
|
-
#
|
57
|
-
# @api private
|
58
52
|
def source_location
|
59
53
|
scope
|
60
54
|
.unmemoized_instance_method(method_name)
|
@@ -10,8 +10,6 @@ module Mutant
|
|
10
10
|
# @param [Symbol] method_name
|
11
11
|
#
|
12
12
|
# @return [Matcher::Method::Singleton]
|
13
|
-
#
|
14
|
-
# @api private
|
15
13
|
def self.new(scope, method_name)
|
16
14
|
super(scope, method_name, Evaluator)
|
17
15
|
end
|
@@ -29,8 +27,6 @@ module Mutant
|
|
29
27
|
# @param [Parser::AST::Node] node
|
30
28
|
#
|
31
29
|
# @return [Boolean]
|
32
|
-
#
|
33
|
-
# @api private
|
34
30
|
def match?(node)
|
35
31
|
n_defs?(node) && line?(node) && name?(node) && receiver?(node)
|
36
32
|
end
|
@@ -40,8 +36,6 @@ module Mutant
|
|
40
36
|
# @param [Parser::AST::Node] node
|
41
37
|
#
|
42
38
|
# @return [Boolean]
|
43
|
-
#
|
44
|
-
# @api private
|
45
39
|
def line?(node)
|
46
40
|
node
|
47
41
|
.location
|
@@ -54,8 +48,6 @@ module Mutant
|
|
54
48
|
# @param [Parser::AST::Node] node
|
55
49
|
#
|
56
50
|
# @return [Boolean]
|
57
|
-
#
|
58
|
-
# @api private
|
59
51
|
def name?(node)
|
60
52
|
node.children.fetch(NAME_INDEX).equal?(method_name)
|
61
53
|
end
|
@@ -65,8 +57,6 @@ module Mutant
|
|
65
57
|
# @param [Parser::AST::Node] node
|
66
58
|
#
|
67
59
|
# @return [Boolean]
|
68
|
-
#
|
69
|
-
# @api private
|
70
60
|
def receiver?(node)
|
71
61
|
receiver = node.children.fetch(RECEIVER_INDEX)
|
72
62
|
case receiver.type
|
@@ -85,8 +75,6 @@ module Mutant
|
|
85
75
|
# @param [Parser::AST::Node] node
|
86
76
|
#
|
87
77
|
# @return [Boolean]
|
88
|
-
#
|
89
|
-
# @api private
|
90
78
|
def receiver_name?(node)
|
91
79
|
name = node.children.fetch(NAME_INDEX)
|
92
80
|
name.to_s.eql?(context.unqualified_name)
|
@@ -14,11 +14,9 @@ module Mutant
|
|
14
14
|
|
15
15
|
# Enumerate subjects
|
16
16
|
#
|
17
|
-
# @param [Env] env
|
17
|
+
# @param [Env::Bootstrap] env
|
18
18
|
#
|
19
19
|
# @return [Enumerable<Subject>]
|
20
|
-
#
|
21
|
-
# @api private
|
22
20
|
def call(env)
|
23
21
|
Chain.new(
|
24
22
|
methods.map { |method| matcher.new(scope, method) }
|
@@ -30,8 +28,6 @@ module Mutant
|
|
30
28
|
# method matcher class
|
31
29
|
#
|
32
30
|
# @return [Class:Matcher::Method]
|
33
|
-
#
|
34
|
-
# @api private
|
35
31
|
def matcher
|
36
32
|
self.class::MATCHER
|
37
33
|
end
|
@@ -39,8 +35,6 @@ module Mutant
|
|
39
35
|
# Available methods scope
|
40
36
|
#
|
41
37
|
# @return [Enumerable<Method, UnboundMethod>]
|
42
|
-
#
|
43
|
-
# @api private
|
44
38
|
def methods
|
45
39
|
candidate_names.each_with_object([]) do |name, methods|
|
46
40
|
method = access(name)
|
@@ -52,8 +46,6 @@ module Mutant
|
|
52
46
|
# Candidate method names on target scope
|
53
47
|
#
|
54
48
|
# @return [Enumerable<Symbol>]
|
55
|
-
#
|
56
|
-
# @api private
|
57
49
|
def candidate_names
|
58
50
|
CANDIDATE_NAMES
|
59
51
|
.map(&candidate_scope.method(:public_send))
|
@@ -64,8 +56,6 @@ module Mutant
|
|
64
56
|
# Candidate scope
|
65
57
|
#
|
66
58
|
# @return [Class, Module]
|
67
|
-
#
|
68
|
-
# @api private
|
69
59
|
abstract_method :candidate_scope
|
70
60
|
|
71
61
|
# Matcher for singleton methods
|
@@ -79,8 +69,6 @@ module Mutant
|
|
79
69
|
# @param [Symbol] method_name
|
80
70
|
#
|
81
71
|
# @return [Method]
|
82
|
-
#
|
83
|
-
# @api private
|
84
72
|
def access(method_name)
|
85
73
|
scope.method(method_name)
|
86
74
|
end
|
@@ -88,8 +76,6 @@ module Mutant
|
|
88
76
|
# Candidate scope
|
89
77
|
#
|
90
78
|
# @return [Class]
|
91
|
-
#
|
92
|
-
# @api private
|
93
79
|
def candidate_scope
|
94
80
|
scope.singleton_class
|
95
81
|
end
|
@@ -108,8 +94,6 @@ module Mutant
|
|
108
94
|
# @param [Symbol] method_name
|
109
95
|
#
|
110
96
|
# @return [UnboundMethod]
|
111
|
-
#
|
112
|
-
# @api private
|
113
97
|
def access(method_name)
|
114
98
|
scope.instance_method(method_name)
|
115
99
|
end
|
@@ -117,8 +101,6 @@ module Mutant
|
|
117
101
|
# Candidate scope
|
118
102
|
#
|
119
103
|
# @return [Class, Module]
|
120
|
-
#
|
121
|
-
# @api private
|
122
104
|
def candidate_scope
|
123
105
|
scope
|
124
106
|
end
|
@@ -6,11 +6,9 @@ module Mutant
|
|
6
6
|
|
7
7
|
# Enumerate subjects
|
8
8
|
#
|
9
|
-
# @param [Env] env
|
9
|
+
# @param [Env::Bootstrap] env
|
10
10
|
#
|
11
11
|
# @return [Enumerable<Subject>]
|
12
|
-
#
|
13
|
-
# @api private
|
14
12
|
def call(env)
|
15
13
|
Chain.new(
|
16
14
|
matched_scopes(env).map { |scope| Scope.new(scope.raw) }
|
@@ -24,8 +22,6 @@ module Mutant
|
|
24
22
|
# @param [Env] env
|
25
23
|
#
|
26
24
|
# @return [Enumerable<Scope>]
|
27
|
-
#
|
28
|
-
# @api private
|
29
25
|
def matched_scopes(env)
|
30
26
|
env
|
31
27
|
.matchable_scopes
|
@@ -37,8 +33,6 @@ module Mutant
|
|
37
33
|
# @param [Scope] scope
|
38
34
|
#
|
39
35
|
# @return [Boolean]
|
40
|
-
#
|
41
|
-
# @api private
|
42
36
|
def match?(scope)
|
43
37
|
expression.prefix?(scope.expression)
|
44
38
|
end
|
data/lib/mutant/matcher/null.rb
CHANGED
data/lib/mutant/matcher/scope.rb
CHANGED
@@ -18,11 +18,9 @@ module Mutant
|
|
18
18
|
|
19
19
|
# Matched subjects
|
20
20
|
#
|
21
|
-
# @param [Env] env
|
21
|
+
# @param [Env::Bootstrap] env
|
22
22
|
#
|
23
23
|
# @return [Enumerable<Subject>]
|
24
|
-
#
|
25
|
-
# @api private
|
26
24
|
def call(env)
|
27
25
|
Chain.new(effective_matchers).call(env)
|
28
26
|
end
|
@@ -32,8 +30,6 @@ module Mutant
|
|
32
30
|
# Effective matchers
|
33
31
|
#
|
34
32
|
# @return [Enumerable<Matcher>]
|
35
|
-
#
|
36
|
-
# @api private
|
37
33
|
def effective_matchers
|
38
34
|
MATCHERS.map { |matcher| matcher.new(scope) }
|
39
35
|
end
|
data/lib/mutant/meta.rb
CHANGED
data/lib/mutant/meta/example.rb
CHANGED
@@ -6,8 +6,6 @@ module Mutant
|
|
6
6
|
# Verification instance for example
|
7
7
|
#
|
8
8
|
# @return [Verification]
|
9
|
-
#
|
10
|
-
# @api private
|
11
9
|
def verification
|
12
10
|
Verification.new(self, generated)
|
13
11
|
end
|
@@ -15,8 +13,6 @@ module Mutant
|
|
15
13
|
# Normalized source
|
16
14
|
#
|
17
15
|
# @return [String]
|
18
|
-
#
|
19
|
-
# @api private
|
20
16
|
def source
|
21
17
|
Unparser.unparse(node)
|
22
18
|
end
|
@@ -25,8 +21,6 @@ module Mutant
|
|
25
21
|
# Generated mutations on example source
|
26
22
|
#
|
27
23
|
# @return [Enumerable<Mutant::Mutation>]
|
28
|
-
#
|
29
|
-
# @api private
|
30
24
|
def generated
|
31
25
|
Mutator.each(node).map do |node|
|
32
26
|
Mutation::Evil.new(self, node)
|
@@ -41,8 +35,6 @@ module Mutant
|
|
41
35
|
# Test if mutation was verified successfully
|
42
36
|
#
|
43
37
|
# @return [Boolean]
|
44
|
-
#
|
45
|
-
# @api private
|
46
38
|
def success?
|
47
39
|
unparser.success? && missing.empty? && unexpected.empty? && no_diffs.empty?
|
48
40
|
end
|
@@ -50,8 +42,6 @@ module Mutant
|
|
50
42
|
# Error report
|
51
43
|
#
|
52
44
|
# @return [String]
|
53
|
-
#
|
54
|
-
# @api private
|
55
45
|
def error_report
|
56
46
|
unless unparser.success?
|
57
47
|
return unparser.report
|
@@ -64,8 +54,6 @@ module Mutant
|
|
64
54
|
# Unexpected mutations
|
65
55
|
#
|
66
56
|
# @return [Array<Parser::AST::Node>]
|
67
|
-
#
|
68
|
-
# @api private
|
69
57
|
def unexpected
|
70
58
|
mutations.map(&:node) - example.mutations
|
71
59
|
end
|
@@ -74,8 +62,6 @@ module Mutant
|
|
74
62
|
# Mutations with no diff to original
|
75
63
|
#
|
76
64
|
# @return [Enumerable<Mutation>]
|
77
|
-
#
|
78
|
-
# @api private
|
79
65
|
def no_diffs
|
80
66
|
mutations.select { |mutation| mutation.source.eql?(example.source) }
|
81
67
|
end
|
@@ -84,8 +70,6 @@ module Mutant
|
|
84
70
|
# Mutation report
|
85
71
|
#
|
86
72
|
# @return [String]
|
87
|
-
#
|
88
|
-
# @api private
|
89
73
|
def mutation_report
|
90
74
|
original_node = example.node
|
91
75
|
[
|
@@ -102,8 +86,6 @@ module Mutant
|
|
102
86
|
# Missing mutation report
|
103
87
|
#
|
104
88
|
# @return [Array, nil]
|
105
|
-
#
|
106
|
-
# @api private
|
107
89
|
def missing_report
|
108
90
|
[
|
109
91
|
'Missing mutations:',
|
@@ -114,8 +96,6 @@ module Mutant
|
|
114
96
|
# No diff mutation report
|
115
97
|
#
|
116
98
|
# @return [Array, nil]
|
117
|
-
#
|
118
|
-
# @api private
|
119
99
|
def no_diff_report
|
120
100
|
[
|
121
101
|
'No source diffs to original:',
|
@@ -128,8 +108,6 @@ module Mutant
|
|
128
108
|
# Unexpected mutation report
|
129
109
|
#
|
130
110
|
# @return [Array, nil]
|
131
|
-
#
|
132
|
-
# @api private
|
133
111
|
def unexpected_report
|
134
112
|
[
|
135
113
|
'Unexpected mutations:',
|
@@ -140,8 +118,6 @@ module Mutant
|
|
140
118
|
# Format mutation
|
141
119
|
#
|
142
120
|
# @return [String]
|
143
|
-
#
|
144
|
-
# @api private
|
145
121
|
def format_mutation(node)
|
146
122
|
[
|
147
123
|
node.inspect,
|
@@ -152,8 +128,6 @@ module Mutant
|
|
152
128
|
# Missing mutations
|
153
129
|
#
|
154
130
|
# @return [Array<Parser::AST::Node>]
|
155
|
-
#
|
156
|
-
# @api private
|
157
131
|
def missing
|
158
132
|
example.mutations - mutations.map(&:node)
|
159
133
|
end
|
@@ -162,8 +136,6 @@ module Mutant
|
|
162
136
|
# Unparser verifier
|
163
137
|
#
|
164
138
|
# @return [Unparser::CLI::Source]
|
165
|
-
#
|
166
|
-
# @api private
|
167
139
|
def unparser
|
168
140
|
Unparser::CLI::Source::Node.new(Unparser::Preprocessor.run(example.node))
|
169
141
|
end
|