mutant 0.2.20 → 0.3.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +10 -11
- data/Changelog.md +93 -38
- data/Gemfile +3 -1
- data/Gemfile.devtools +16 -20
- data/Guardfile +1 -1
- data/README.md +36 -16
- data/Rakefile +21 -2
- data/TODO +11 -7
- data/bin/mutant +4 -0
- data/bin/zombie +4 -0
- data/config/devtools.yml +2 -0
- data/config/flay.yml +2 -2
- data/config/flog.yml +1 -1
- data/config/{site.reek → reek.yml} +94 -70
- data/lib/mutant/cli/classifier/method.rb +100 -0
- data/lib/mutant/cli/classifier/namespace.rb +47 -0
- data/lib/mutant/cli/classifier/scope.rb +35 -0
- data/lib/mutant/cli/classifier.rb +141 -0
- data/lib/mutant/cli.rb +115 -162
- data/lib/mutant/color.rb +2 -2
- data/lib/mutant/config.rb +27 -0
- data/lib/mutant/constants.rb +32 -17
- data/lib/mutant/context/scope.rb +33 -51
- data/lib/mutant/context.rb +8 -19
- data/lib/mutant/differ.rb +5 -5
- data/lib/mutant/helper.rb +2 -17
- data/lib/mutant/killer/forked.rb +44 -0
- data/lib/mutant/killer/forking.rb +3 -57
- data/lib/mutant/killer/rspec.rb +16 -20
- data/lib/mutant/killer/static.rb +6 -7
- data/lib/mutant/killer.rb +48 -74
- data/lib/mutant/loader.rb +6 -6
- data/lib/mutant/matcher/chain.rb +4 -25
- data/lib/mutant/matcher/method/instance.rb +14 -24
- data/lib/mutant/matcher/method/singleton.rb +35 -46
- data/lib/mutant/matcher/method.rb +95 -83
- data/lib/mutant/matcher/{scope_methods.rb → methods.rb} +53 -76
- data/lib/mutant/matcher/namespace.rb +71 -0
- data/lib/mutant/matcher/scope.rb +34 -0
- data/lib/mutant/matcher.rb +24 -34
- data/lib/mutant/mutation/evil.rb +35 -0
- data/lib/mutant/mutation/filter/code.rb +7 -28
- data/lib/mutant/mutation/filter/regexp.rb +6 -18
- data/lib/mutant/mutation/filter/whitelist.rb +5 -4
- data/lib/mutant/mutation/filter.rb +10 -9
- data/lib/mutant/mutation/neutral.rb +35 -0
- data/lib/mutant/mutation.rb +21 -61
- data/lib/mutant/mutator/node/argument.rb +88 -0
- data/lib/mutant/mutator/node/arguments.rb +52 -0
- data/lib/mutant/mutator/node/assignment.rb +34 -38
- data/lib/mutant/mutator/node/begin.rb +33 -0
- data/lib/mutant/mutator/node/block.rb +14 -14
- data/lib/mutant/mutator/node/case.rb +59 -0
- data/lib/mutant/mutator/node/define.rb +26 -22
- data/lib/mutant/mutator/node/if.rb +31 -71
- data/lib/mutant/mutator/node/literal/array.rb +25 -9
- data/lib/mutant/mutator/node/literal/boolean.rb +13 -30
- data/lib/mutant/mutator/node/literal/dynamic.rb +6 -5
- data/lib/mutant/mutator/node/literal/fixnum.rb +18 -7
- data/lib/mutant/mutator/node/literal/float.rb +15 -8
- data/lib/mutant/mutator/node/literal/hash.rb +33 -52
- data/lib/mutant/mutator/node/literal/nil.rb +8 -7
- data/lib/mutant/mutator/node/literal/range.rb +25 -50
- data/lib/mutant/mutator/node/literal/regex.rb +15 -23
- data/lib/mutant/mutator/node/literal/string.rb +7 -6
- data/lib/mutant/mutator/node/literal/symbol.rb +7 -6
- data/lib/mutant/mutator/node/literal.rb +4 -46
- data/lib/mutant/mutator/node/mlhs.rb +27 -0
- data/lib/mutant/mutator/node/noop.rb +18 -43
- data/lib/mutant/mutator/node/return.rb +8 -8
- data/lib/mutant/mutator/node/send/binary.rb +31 -0
- data/lib/mutant/mutator/node/send.rb +106 -72
- data/lib/mutant/mutator/node/super.rb +15 -20
- data/lib/mutant/mutator/node/when.rb +32 -7
- data/lib/mutant/mutator/node/while.rb +9 -7
- data/lib/mutant/mutator/node.rb +116 -66
- data/lib/mutant/mutator/registry.rb +14 -11
- data/lib/mutant/mutator/util/array.rb +9 -9
- data/lib/mutant/mutator/util/symbol.rb +6 -20
- data/lib/mutant/mutator/util.rb +6 -3
- data/lib/mutant/mutator.rb +12 -28
- data/lib/mutant/node_helpers.rb +28 -0
- data/lib/mutant/random.rb +3 -2
- data/lib/mutant/reporter/cli/printer/config.rb +174 -0
- data/lib/mutant/reporter/cli/printer/killer.rb +42 -0
- data/lib/mutant/reporter/cli/printer/mutation.rb +55 -0
- data/lib/mutant/reporter/cli/printer/subject.rb +147 -0
- data/lib/mutant/reporter/cli/printer.rb +165 -0
- data/lib/mutant/reporter/cli.rb +9 -277
- data/lib/mutant/reporter/null.rb +6 -30
- data/lib/mutant/reporter.rb +6 -73
- data/lib/mutant/runner/config.rb +82 -0
- data/lib/mutant/runner/mutation.rb +58 -0
- data/lib/mutant/runner/subject.rb +81 -0
- data/lib/mutant/runner.rb +42 -92
- data/lib/mutant/singleton_methods.rb +2 -2
- data/lib/mutant/strategy/method_expansion.rb +51 -0
- data/lib/mutant/strategy/rspec/dm2/lookup/method.rb +142 -0
- data/lib/mutant/strategy/rspec/dm2/lookup.rb +61 -0
- data/lib/mutant/strategy/rspec/dm2.rb +22 -0
- data/lib/mutant/strategy/rspec.rb +20 -22
- data/lib/mutant/strategy/static.rb +18 -0
- data/lib/mutant/strategy.rb +15 -50
- data/lib/mutant/subject/method.rb +100 -0
- data/lib/mutant/subject.rb +18 -49
- data/lib/mutant/support/method_object.rb +4 -2
- data/lib/mutant.rb +40 -35
- data/mutant.gemspec +9 -8
- data/spec/integration/mutant/rspec_killer_spec.rb +3 -3
- data/spec/integration/mutant/test_mutator_handles_types_spec.rb +9 -0
- data/spec/integration/mutant/zombie_spec.rb +1 -1
- data/spec/shared/method_matcher_behavior.rb +35 -0
- data/spec/shared/mutator_behavior.rb +63 -32
- data/spec/spec_helper.rb +13 -3
- data/spec/support/ice_nine_config.rb +8 -0
- data/spec/support/rspec.rb +1 -1
- data/spec/support/zombie.rb +1 -1
- data/spec/unit/mutant/cli/class_methods/new_spec.rb +42 -28
- data/spec/unit/mutant/cli/class_methods/run_spec.rb +15 -13
- data/spec/unit/mutant/cli/classifier/class_methods/build_spec.rb +44 -0
- data/spec/unit/mutant/context/scope/root_spec.rb +4 -4
- data/spec/unit/mutant/killer/rspec/class_methods/new_spec.rb +6 -5
- data/spec/unit/mutant/killer/success_predicate_spec.rb +28 -0
- data/spec/unit/mutant/loader/eval/class_methods/run_spec.rb +1 -1
- data/spec/unit/mutant/matcher/chain/each_spec.rb +1 -1
- data/spec/unit/mutant/matcher/chain/matchers_spec.rb +1 -1
- data/spec/unit/mutant/matcher/method/instance/each_spec.rb +112 -0
- data/spec/unit/mutant/matcher/method/singleton/each_spec.rb +93 -0
- data/spec/unit/mutant/matcher/methods/instance/each_spec.rb +59 -0
- data/spec/unit/mutant/matcher/methods/singleton/each_spec.rb +53 -0
- data/spec/unit/mutant/matcher/namespace/each_spec.rb +37 -0
- data/spec/unit/mutant/mutator/node/begin/mutation_spec.rb +33 -0
- data/spec/unit/mutant/mutator/node/block/mutation_spec.rb +42 -14
- data/spec/unit/mutant/mutator/node/case/mutation_spec.rb +319 -0
- data/spec/unit/mutant/mutator/node/define/mutation_spec.rb +31 -27
- data/spec/unit/mutant/mutator/node/if/mutation_spec.rb +75 -0
- data/spec/unit/mutant/mutator/node/literal/fixnum_spec.rb +1 -1
- data/spec/unit/mutant/mutator/node/literal/hash_spec.rb +2 -2
- data/spec/unit/mutant/mutator/node/literal/nil_spec.rb +1 -3
- data/spec/unit/mutant/mutator/node/literal/regex_spec.rb +1 -9
- data/spec/unit/mutant/mutator/node/return/mutation_spec.rb +6 -2
- data/spec/unit/mutant/mutator/node/send/mutation_spec.rb +111 -108
- data/spec/unit/mutant/mutator/node/super/mutation_spec.rb +0 -33
- data/spec/unit/mutant/mutator/node/while/mutation_spec.rb +2 -2
- data/spec/unit/mutant/runner/config/subjects_spec.rb +38 -0
- data/spec/unit/mutant/runner/config/success_predicate_spec.rb +53 -0
- data/spec/unit/mutant/runner/failed_predicte_spec.rb +33 -0
- data/spec/unit/mutant/runner/mutation/killer_spec.rb +39 -0
- data/spec/unit/mutant/runner/subject/success_predicate_spec.rb +49 -0
- data/spec/unit/mutant/strategy/method_expansion/class_methods/run_spec.rb +49 -0
- data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/instance/spec_files_spec.rb +52 -0
- data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/singleton/spec_files_spec.rb +42 -0
- data/spec/unit/mutant/subject/context_spec.rb +6 -3
- data/spec/unit/mutant/subject/each_spec.rb +11 -8
- data/spec/unit/mutant/subject/node_spec.rb +6 -2
- data/test_app/spec/shared/method_filter_parse_behavior.rb +0 -2
- data/test_app/spec/shared/method_match_behavior.rb +1 -1
- data/test_app/spec/spec_helper.rb +4 -2
- metadata +101 -109
- data/config/roodi.yml +0 -26
- data/lib/mutant/matcher/method/classifier.rb +0 -141
- data/lib/mutant/matcher/object_space.rb +0 -114
- data/lib/mutant/mutator/node/actual_arguments.rb +0 -25
- data/lib/mutant/mutator/node/default_arguments.rb +0 -25
- data/lib/mutant/mutator/node/formal_arguments_19/default_mutations.rb +0 -33
- data/lib/mutant/mutator/node/formal_arguments_19/pattern_argument_expansion.rb +0 -35
- data/lib/mutant/mutator/node/formal_arguments_19/require_defaults.rb +0 -37
- data/lib/mutant/mutator/node/formal_arguments_19.rb +0 -41
- data/lib/mutant/mutator/node/iter_19.rb +0 -27
- data/lib/mutant/mutator/node/literal/empty_array.rb +0 -26
- data/lib/mutant/mutator/node/pattern_arguments.rb +0 -41
- data/lib/mutant/mutator/node/pattern_variable.rb +0 -23
- data/lib/mutant/mutator/node/receiver_case.rb +0 -122
- data/lib/mutant/mutator/node/send/binary_operator_method.rb +0 -61
- data/lib/mutant/mutator/node/send/with_arguments.rb +0 -81
- data/lib/mutant/reporter/stats.rb +0 -120
- data/lib/mutant/strategy/rspec/example_lookup.rb +0 -163
- data/spec/integration/mutant/method_matching_spec.rb +0 -269
- data/spec/shared/method_match_behavior.rb +0 -39
- data/spec/unit/mutant/killer/fail_ques_spec.rb +0 -39
- data/spec/unit/mutant/matcher/class_methods/from_string_spec.rb +0 -49
- data/spec/unit/mutant/matcher/class_methods/parse_spec.rb +0 -12
- data/spec/unit/mutant/matcher/method/class_methods/parse_spec.rb +0 -21
- data/spec/unit/mutant/matcher/method/classifier/class_methods/run_spec.rb +0 -52
- data/spec/unit/mutant/matcher/object_space/class_methods/parse_spec.rb +0 -24
- data/spec/unit/mutant/matcher/object_space/each_spec.rb +0 -31
- data/spec/unit/mutant/mutator/node/if_statement/mutation_spec.rb +0 -60
- data/spec/unit/mutant/mutator/node/receiver_case/mutation_spec.rb +0 -27
- data/spec/unit/mutant/strategy/rspec/example_lookup/spec_file_spec.rb +0 -236
- data/spec/unit/mutant/subject/class_methods/new_spec.rb +0 -13
- data/tasks/metrics/ci.rake +0 -7
- data/tasks/metrics/flay.rake +0 -41
- data/tasks/metrics/flog.rake +0 -43
- data/tasks/metrics/heckle.rake +0 -216
- data/tasks/metrics/metric_fu.rake +0 -31
- data/tasks/metrics/reek.rake +0 -15
- data/tasks/metrics/roodi.rake +0 -15
- data/tasks/metrics/yardstick.rake +0 -23
- data/tasks/spec.rake +0 -45
- data/tasks/yard.rake +0 -9
@@ -1,114 +0,0 @@
|
|
1
|
-
module Mutant
|
2
|
-
class Matcher
|
3
|
-
# Matcher against object space
|
4
|
-
class ObjectSpace < self
|
5
|
-
include Equalizer.new(:scope_name_pattern)
|
6
|
-
|
7
|
-
PATTERN = %r(\A::(.+)\z)
|
8
|
-
|
9
|
-
# Parse matcher
|
10
|
-
#
|
11
|
-
# @param [String] input
|
12
|
-
#
|
13
|
-
# @return [Matcher::ObjectSpace]
|
14
|
-
# returns object space matcher if successful
|
15
|
-
#
|
16
|
-
# @return [nil]
|
17
|
-
# returns nil otherwise
|
18
|
-
#
|
19
|
-
# @api private
|
20
|
-
#
|
21
|
-
def self.parse(input)
|
22
|
-
match = PATTERN.match(input)
|
23
|
-
return unless match
|
24
|
-
|
25
|
-
new(%r(\A#{Regexp.escape(match[1])}(\z|::)))
|
26
|
-
end
|
27
|
-
|
28
|
-
# Enumerate subjects
|
29
|
-
#
|
30
|
-
# @return [Enumerator<Subject>]
|
31
|
-
# returns subject enumerator when no block given
|
32
|
-
#
|
33
|
-
# @return [self]
|
34
|
-
# returns self otherwise
|
35
|
-
#
|
36
|
-
# @api private
|
37
|
-
#
|
38
|
-
def each(&block)
|
39
|
-
return to_enum unless block_given?
|
40
|
-
|
41
|
-
scopes.each do |scope|
|
42
|
-
emit_scope_matches(scope, &block)
|
43
|
-
end
|
44
|
-
|
45
|
-
self
|
46
|
-
end
|
47
|
-
|
48
|
-
# Return scope name pattern
|
49
|
-
#
|
50
|
-
# @return [Regexp]
|
51
|
-
#
|
52
|
-
# @api private
|
53
|
-
#
|
54
|
-
def scope_name_pattern; @scope_name_pattern; end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
# Initialize object space matcher
|
59
|
-
#
|
60
|
-
# @param [Regexp] scope_name_pattern
|
61
|
-
# @param [Enumerable<#each(scope)>] matchers
|
62
|
-
#
|
63
|
-
# @return [undefined]
|
64
|
-
#
|
65
|
-
# @api private
|
66
|
-
#
|
67
|
-
def initialize(scope_name_pattern, matchers = [Matcher::ScopeMethods::Singleton, Matcher::ScopeMethods::Instance])
|
68
|
-
@scope_name_pattern, @matchers = scope_name_pattern, @matchers = matchers #[Method::Singleton, Method::Instance]
|
69
|
-
end
|
70
|
-
|
71
|
-
# Yield matchers for scope
|
72
|
-
#
|
73
|
-
# @param [::Class,::Module] scope
|
74
|
-
#
|
75
|
-
# @return [undefined]
|
76
|
-
#
|
77
|
-
# @api private
|
78
|
-
#
|
79
|
-
def emit_scope_matches(scope, &block)
|
80
|
-
@matchers.each do |matcher|
|
81
|
-
matcher.new(scope).each(&block)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
# Return scope enumerator
|
86
|
-
#
|
87
|
-
# @return [Enumerable<Object>]
|
88
|
-
#
|
89
|
-
# @api private
|
90
|
-
#
|
91
|
-
def scopes(&block)
|
92
|
-
return to_enum(__method__) unless block_given?
|
93
|
-
|
94
|
-
::ObjectSpace.each_object(Module) do |scope|
|
95
|
-
emit_scope(scope, &block)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
# Yield scope if name matches pattern
|
100
|
-
#
|
101
|
-
# @param [::Module,::Class] scope
|
102
|
-
#
|
103
|
-
# @return [undefined]
|
104
|
-
#
|
105
|
-
# @api private
|
106
|
-
#
|
107
|
-
def emit_scope(scope)
|
108
|
-
if [::Module, ::Class].include?(scope.class) and @scope_name_pattern =~ scope.name
|
109
|
-
yield scope
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Mutant
|
2
|
-
class Mutator
|
3
|
-
class Node
|
4
|
-
|
5
|
-
# Mutator for arguments
|
6
|
-
class Arguments < self
|
7
|
-
|
8
|
-
handle(Rubinius::AST::ActualArguments)
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
# Emit mutations
|
13
|
-
#
|
14
|
-
# @return [undefined]
|
15
|
-
#
|
16
|
-
# @api private
|
17
|
-
#
|
18
|
-
def dispatch
|
19
|
-
emit_attribute_mutations(:array)
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Mutant
|
2
|
-
class Mutator
|
3
|
-
class Node
|
4
|
-
# Mutantor for default arguments
|
5
|
-
class DefaultArguments < self
|
6
|
-
handle(Rubinius::AST::DefaultArguments)
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
# Emit mutations
|
11
|
-
#
|
12
|
-
# @return [undefined]
|
13
|
-
#
|
14
|
-
# @api private
|
15
|
-
#
|
16
|
-
def dispatch
|
17
|
-
emit_attribute_mutations(:arguments) do |argument|
|
18
|
-
argument.names = argument.arguments.map(&:name)
|
19
|
-
argument
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Mutant
|
2
|
-
class Mutator
|
3
|
-
class Node
|
4
|
-
class FormalArguments19
|
5
|
-
|
6
|
-
# Mutator for default argument values
|
7
|
-
class DefaultMutations < Node
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
# Emit mutations
|
12
|
-
#
|
13
|
-
# @return [undefined]
|
14
|
-
#
|
15
|
-
# @api private
|
16
|
-
#
|
17
|
-
def dispatch
|
18
|
-
return unless node.defaults
|
19
|
-
emit_attribute_mutations(:defaults) do |mutation|
|
20
|
-
mutation.optional = mutation.defaults.names
|
21
|
-
mutation.names = mutation.required + mutation.optional
|
22
|
-
if mutation.defaults.names.empty?
|
23
|
-
mutation.defaults = nil
|
24
|
-
end
|
25
|
-
mutation
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Mutant
|
2
|
-
class Mutator
|
3
|
-
class Node
|
4
|
-
class FormalArguments19
|
5
|
-
|
6
|
-
# Mutator that expands pattern arguments
|
7
|
-
class PatternArgumentExpansion < Node
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
# Emit mutations
|
12
|
-
#
|
13
|
-
# @return [undefined]
|
14
|
-
#
|
15
|
-
# @api private
|
16
|
-
#
|
17
|
-
def dispatch
|
18
|
-
node.required.each_with_index do |argument, index|
|
19
|
-
next unless argument.kind_of?(Rubinius::AST::PatternArguments)
|
20
|
-
dup = dup_node
|
21
|
-
required = dup.required
|
22
|
-
required.delete_at(index)
|
23
|
-
argument.arguments.body.reverse.each do |node|
|
24
|
-
required.insert(index, node.name)
|
25
|
-
end
|
26
|
-
dup.names |= required
|
27
|
-
emit(dup)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module Mutant
|
2
|
-
class Mutator
|
3
|
-
class Node
|
4
|
-
class FormalArguments19
|
5
|
-
|
6
|
-
# Mutator for removing defaults and transform them into required arguments
|
7
|
-
class RequireDefaults < Node
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
# Emit mutants
|
12
|
-
#
|
13
|
-
# @return [undefined]
|
14
|
-
#
|
15
|
-
# @api private
|
16
|
-
#
|
17
|
-
def dispatch
|
18
|
-
return unless node.defaults
|
19
|
-
arguments = node.defaults.arguments
|
20
|
-
arguments.each_index do |index|
|
21
|
-
names = arguments.take(index+1).map(&:name)
|
22
|
-
dup = dup_node
|
23
|
-
defaults = dup.defaults
|
24
|
-
defaults.arguments = defaults.arguments.drop(names.size)
|
25
|
-
names.each { |name| dup.optional.delete(name) }
|
26
|
-
dup.required.concat(names)
|
27
|
-
if dup.optional.empty?
|
28
|
-
dup.defaults = nil
|
29
|
-
end
|
30
|
-
emit(dup)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module Mutant
|
2
|
-
class Mutator
|
3
|
-
class Node
|
4
|
-
|
5
|
-
# Mutator for formal arguments in 1.9 mode
|
6
|
-
class FormalArguments19 < self
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
handle(Rubinius::AST::FormalArguments19)
|
11
|
-
|
12
|
-
# Emit mutations
|
13
|
-
#
|
14
|
-
# @return [undefined]
|
15
|
-
#
|
16
|
-
# @api private
|
17
|
-
#
|
18
|
-
def dispatch
|
19
|
-
run(DefaultMutations)
|
20
|
-
run(RequireDefaults)
|
21
|
-
run(PatternArgumentExpansion)
|
22
|
-
emit_required_mutations
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
# Emit required mutations
|
27
|
-
#
|
28
|
-
# @return [undefined]
|
29
|
-
#
|
30
|
-
# @api private
|
31
|
-
#
|
32
|
-
def emit_required_mutations
|
33
|
-
emit_attribute_mutations(:required) do |mutation|
|
34
|
-
mutation.names = mutation.optional + mutation.required
|
35
|
-
mutation
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Mutant
|
2
|
-
class Mutator
|
3
|
-
class Node
|
4
|
-
# Emitter for mutations on 19 blocks
|
5
|
-
class Iter19 < self
|
6
|
-
|
7
|
-
handle(Rubinius::AST::Iter19)
|
8
|
-
|
9
|
-
# Emit mutants
|
10
|
-
#
|
11
|
-
# @return [undefined]
|
12
|
-
#
|
13
|
-
# @api private
|
14
|
-
#
|
15
|
-
def dispatch
|
16
|
-
emit_attribute_mutations(:body)
|
17
|
-
emit_attribute_mutations(:arguments) do |mutation|
|
18
|
-
arguments = mutation.arguments
|
19
|
-
arguments.names = arguments.required + arguments.optional
|
20
|
-
mutation
|
21
|
-
end if node.arguments
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Mutant
|
2
|
-
class Mutator
|
3
|
-
class Node
|
4
|
-
class Literal < self
|
5
|
-
# Mutator for empty array literals
|
6
|
-
class EmptyArray < self
|
7
|
-
|
8
|
-
handle(Rubinius::AST::EmptyArray)
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
# Emit mutants
|
13
|
-
#
|
14
|
-
# @return [undefined]
|
15
|
-
#
|
16
|
-
# @api private
|
17
|
-
#
|
18
|
-
def dispatch
|
19
|
-
emit_nil
|
20
|
-
emit_node(Rubinius::AST::ArrayLiteral, [new_nil])
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module Mutant
|
2
|
-
class Mutator
|
3
|
-
class Node
|
4
|
-
# Mutator for pattern arguments
|
5
|
-
class PatternArguments < self
|
6
|
-
|
7
|
-
handle(Rubinius::AST::PatternArguments)
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
# Emit mutations
|
12
|
-
#
|
13
|
-
# @return [undefined]
|
14
|
-
#
|
15
|
-
# @api private
|
16
|
-
#
|
17
|
-
def dispatch
|
18
|
-
Mutator.each(node.arguments.body) do |mutation|
|
19
|
-
dup = dup_node
|
20
|
-
dup.arguments.body = mutation
|
21
|
-
emit(dup)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# Test if mutation should be skipped
|
26
|
-
#
|
27
|
-
# @return [true]
|
28
|
-
# if mutation should be skipped
|
29
|
-
#
|
30
|
-
# @return [false]
|
31
|
-
# otherwise
|
32
|
-
#
|
33
|
-
# @api private
|
34
|
-
#
|
35
|
-
def allow?(object)
|
36
|
-
object.arguments.body.size >= 2
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Mutant
|
2
|
-
class Mutator
|
3
|
-
class Node
|
4
|
-
# Mutator for pattern variable
|
5
|
-
class PatternVariable < self
|
6
|
-
|
7
|
-
handle(Rubinius::AST::PatternVariable)
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
# Emit mutations
|
12
|
-
#
|
13
|
-
# @return [undefined]
|
14
|
-
#
|
15
|
-
# @api private
|
16
|
-
#
|
17
|
-
def dispatch
|
18
|
-
emit_attribute_mutations(:name)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,122 +0,0 @@
|
|
1
|
-
module Mutant
|
2
|
-
class Mutator
|
3
|
-
class Node
|
4
|
-
|
5
|
-
# Mutator for Rubinius::AST::ReceiverCase nodes
|
6
|
-
class ReceiverCase < self
|
7
|
-
|
8
|
-
handle(Rubinius::AST::ReceiverCase)
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
# Emit mutations
|
13
|
-
#
|
14
|
-
# @return [undefined]
|
15
|
-
#
|
16
|
-
# @api private
|
17
|
-
#
|
18
|
-
def dispatch
|
19
|
-
emit_attribute_mutations(:receiver)
|
20
|
-
emit_when_branch_presence_mutations
|
21
|
-
emit_else_branch_presence_mutation
|
22
|
-
emit_when_branch_mutations
|
23
|
-
end
|
24
|
-
|
25
|
-
# Emit else branch presence mutation
|
26
|
-
#
|
27
|
-
# @return [undefined]
|
28
|
-
#
|
29
|
-
# @api private
|
30
|
-
#
|
31
|
-
def emit_else_branch_presence_mutation
|
32
|
-
emit_self(receiver, when_branches, nil)
|
33
|
-
end
|
34
|
-
|
35
|
-
# Emit when branch body mutations
|
36
|
-
#
|
37
|
-
# @return [undefined]
|
38
|
-
#
|
39
|
-
# @api private
|
40
|
-
#
|
41
|
-
def emit_when_branch_mutations
|
42
|
-
when_branches.each_with_index do |branch, index|
|
43
|
-
Mutator.each(branch) do |mutant|
|
44
|
-
branches = dup_when_branches
|
45
|
-
branches[index]=mutant
|
46
|
-
emit_self(receiver, branches, else_branch)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# Emit when branch presence mutations
|
52
|
-
#
|
53
|
-
# @return [undefined]
|
54
|
-
#
|
55
|
-
# @api private
|
56
|
-
#
|
57
|
-
def emit_when_branch_presence_mutations
|
58
|
-
return if one?
|
59
|
-
when_branches.each_index do |index|
|
60
|
-
dup_branches = dup_when_branches
|
61
|
-
dup_branches.delete_at(index)
|
62
|
-
emit_self(receiver, dup_branches, else_branch)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# Check for case there is only one when branch
|
67
|
-
#
|
68
|
-
# @return [true]
|
69
|
-
# returns true when there is only one when branch
|
70
|
-
#
|
71
|
-
# @return [false]
|
72
|
-
# returns false otherwise
|
73
|
-
#
|
74
|
-
# @api private
|
75
|
-
#
|
76
|
-
def one?
|
77
|
-
when_branches.one?
|
78
|
-
end
|
79
|
-
|
80
|
-
# Return duplicate of when branches
|
81
|
-
#
|
82
|
-
# @return [Array]
|
83
|
-
#
|
84
|
-
# @api private
|
85
|
-
#
|
86
|
-
def dup_when_branches
|
87
|
-
when_branches.dup
|
88
|
-
end
|
89
|
-
|
90
|
-
# Return when branches
|
91
|
-
#
|
92
|
-
# @return [Array]
|
93
|
-
#
|
94
|
-
# @api private
|
95
|
-
#
|
96
|
-
def when_branches
|
97
|
-
node.whens
|
98
|
-
end
|
99
|
-
|
100
|
-
# Return receiver
|
101
|
-
#
|
102
|
-
# @return [Rubinius::AST::Node]
|
103
|
-
#
|
104
|
-
# @api private
|
105
|
-
#
|
106
|
-
def receiver
|
107
|
-
node.receiver
|
108
|
-
end
|
109
|
-
|
110
|
-
# Return else branch
|
111
|
-
#
|
112
|
-
# @return [Rubinius::AST::Node]
|
113
|
-
#
|
114
|
-
# @api private
|
115
|
-
#
|
116
|
-
def else_branch
|
117
|
-
node.else
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
module Mutant
|
2
|
-
class Mutator
|
3
|
-
class Node
|
4
|
-
class Send
|
5
|
-
|
6
|
-
# Mutator for sends that correspond to a binary operator
|
7
|
-
class BinaryOperatorMethod < Node
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
# Emit mutations
|
12
|
-
#
|
13
|
-
# @return [undefined]
|
14
|
-
#
|
15
|
-
# @api private
|
16
|
-
#
|
17
|
-
def dispatch
|
18
|
-
emit_left_mutations
|
19
|
-
emit_right_mutations
|
20
|
-
emit(right)
|
21
|
-
end
|
22
|
-
|
23
|
-
# Emit left mutations
|
24
|
-
#
|
25
|
-
# @return [undefined]
|
26
|
-
#
|
27
|
-
# @api private
|
28
|
-
#
|
29
|
-
def emit_left_mutations
|
30
|
-
emit_attribute_mutations(:receiver)
|
31
|
-
end
|
32
|
-
|
33
|
-
# Return right
|
34
|
-
#
|
35
|
-
# @return [Rubinius::AST::Node]
|
36
|
-
#
|
37
|
-
# @api private
|
38
|
-
#
|
39
|
-
def right
|
40
|
-
node.arguments.array.first
|
41
|
-
end
|
42
|
-
|
43
|
-
# Emit right mutations
|
44
|
-
#
|
45
|
-
# @return [undefined]
|
46
|
-
#
|
47
|
-
# @api private
|
48
|
-
#
|
49
|
-
def emit_right_mutations
|
50
|
-
Mutator.each(right).each do |mutated|
|
51
|
-
dup = dup_node
|
52
|
-
dup.arguments.array[0] = mutated
|
53
|
-
emit(dup)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
module Mutant
|
2
|
-
class Mutator
|
3
|
-
class Node
|
4
|
-
class Send
|
5
|
-
|
6
|
-
# Mutator for send with arguments
|
7
|
-
class WithArguments < self
|
8
|
-
|
9
|
-
handle(Rubinius::AST::SendWithArguments)
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
# Emit mutations
|
14
|
-
#
|
15
|
-
# @return [undefined]
|
16
|
-
#
|
17
|
-
# @api private
|
18
|
-
#
|
19
|
-
def dispatch
|
20
|
-
super
|
21
|
-
|
22
|
-
if binary_operator?
|
23
|
-
run(BinaryOperatorMethod)
|
24
|
-
return
|
25
|
-
end
|
26
|
-
|
27
|
-
emit_send_remove_mutation
|
28
|
-
emit_argument_mutations
|
29
|
-
end
|
30
|
-
|
31
|
-
# Test if message is a binary operator
|
32
|
-
#
|
33
|
-
# @return [true]
|
34
|
-
# if message is a binary operator
|
35
|
-
#
|
36
|
-
# @return [false]
|
37
|
-
# otherwise
|
38
|
-
#
|
39
|
-
# @api private
|
40
|
-
#
|
41
|
-
def binary_operator?
|
42
|
-
Mutant::BINARY_METHOD_OPERATORS.include?(node.name)
|
43
|
-
end
|
44
|
-
|
45
|
-
# Emit argument mutations
|
46
|
-
#
|
47
|
-
# @api private
|
48
|
-
#
|
49
|
-
# @return [undefined]
|
50
|
-
#
|
51
|
-
# @api private
|
52
|
-
#
|
53
|
-
def emit_argument_mutations
|
54
|
-
emit_attribute_mutations(:arguments) do |mutation|
|
55
|
-
if mutation.arguments.array.empty?
|
56
|
-
mutation = new_send(receiver, node.name)
|
57
|
-
mutation.privately = node.privately
|
58
|
-
mutation
|
59
|
-
else
|
60
|
-
mutation
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# Emit send remove mutation
|
66
|
-
#
|
67
|
-
# @return [undefined]
|
68
|
-
#
|
69
|
-
# @api private
|
70
|
-
#
|
71
|
-
def emit_send_remove_mutation
|
72
|
-
array = node.arguments.array
|
73
|
-
return unless array.length == 1
|
74
|
-
emit(array.first)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|