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,10 +1,12 @@
|
|
1
1
|
module Mutant
|
2
2
|
class Mutator
|
3
3
|
class Node
|
4
|
-
#
|
4
|
+
# Emitter for mutations on 19 blocks
|
5
5
|
class Block < self
|
6
6
|
|
7
|
-
handle(
|
7
|
+
handle(:block)
|
8
|
+
|
9
|
+
children :send, :arguments, :body
|
8
10
|
|
9
11
|
private
|
10
12
|
|
@@ -15,18 +17,16 @@ module Mutant
|
|
15
17
|
# @api private
|
16
18
|
#
|
17
19
|
def dispatch
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
mutation
|
20
|
+
emit(send)
|
21
|
+
emit_arguments_mutations
|
22
|
+
if body
|
23
|
+
emit_body_mutations
|
24
|
+
else
|
25
|
+
emit_body(NEW_OBJECT)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
29
|
+
end # Block
|
30
|
+
end # Node
|
31
|
+
end # Mutator
|
32
|
+
end # Mutant
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Mutant
|
2
|
+
class Mutator
|
3
|
+
class Node
|
4
|
+
|
5
|
+
# Mutator for case nodes
|
6
|
+
class Case < self
|
7
|
+
|
8
|
+
handle(:case)
|
9
|
+
|
10
|
+
children :condition
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
# Emit mutations
|
15
|
+
#
|
16
|
+
# @return [undefined]
|
17
|
+
#
|
18
|
+
# @api private
|
19
|
+
#
|
20
|
+
def dispatch
|
21
|
+
emit_condition_mutations
|
22
|
+
emit_when_mutations
|
23
|
+
emit_else_mutations
|
24
|
+
end
|
25
|
+
|
26
|
+
# Emit when mutations
|
27
|
+
#
|
28
|
+
# @return [undefined]
|
29
|
+
#
|
30
|
+
# @api private
|
31
|
+
#
|
32
|
+
def emit_when_mutations
|
33
|
+
indices = children.each_index.drop(1).take(children.length-2)
|
34
|
+
one = indices.one?
|
35
|
+
indices.each do |index|
|
36
|
+
mutate_child(index)
|
37
|
+
delete_child(index) unless one
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Emit else mutations
|
42
|
+
#
|
43
|
+
# @return [undefined]
|
44
|
+
#
|
45
|
+
# @api private
|
46
|
+
#
|
47
|
+
def emit_else_mutations
|
48
|
+
else_branch = children.last
|
49
|
+
else_index = children.length - 1
|
50
|
+
if else_branch
|
51
|
+
mutate_child(else_index)
|
52
|
+
emit_child_update(else_index, nil)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end # Case
|
57
|
+
end # Node
|
58
|
+
end # Mutator
|
59
|
+
end # Mutant
|
@@ -1,11 +1,9 @@
|
|
1
1
|
module Mutant
|
2
2
|
class Mutator
|
3
3
|
class Node
|
4
|
+
# Namespace for define mutations
|
4
5
|
class Define < self
|
5
6
|
|
6
|
-
handle(Rubinius::AST::Define)
|
7
|
-
handle(Rubinius::AST::DefineSingletonScope)
|
8
|
-
|
9
7
|
private
|
10
8
|
|
11
9
|
# Emit mutations
|
@@ -15,27 +13,33 @@ module Mutant
|
|
15
13
|
# @api private
|
16
14
|
#
|
17
15
|
def dispatch
|
18
|
-
|
19
|
-
|
16
|
+
emit_arguments_mutations
|
17
|
+
if body
|
18
|
+
emit_body_mutations
|
19
|
+
else
|
20
|
+
emit_body(NEW_OBJECT)
|
21
|
+
end
|
20
22
|
end
|
21
|
-
end
|
22
23
|
|
23
|
-
|
24
|
+
# Mutator for instance method defines
|
25
|
+
class Instance < self
|
24
26
|
|
25
|
-
|
27
|
+
handle :def
|
26
28
|
|
27
|
-
|
29
|
+
children :name, :arguments, :body
|
28
30
|
|
29
|
-
#
|
30
|
-
|
31
|
-
#
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
31
|
+
end # Instance
|
32
|
+
|
33
|
+
# Mutator for singleton method defines
|
34
|
+
class Singleton < self
|
35
|
+
|
36
|
+
handle :defs
|
37
|
+
|
38
|
+
children :subject, :name, :arguments, :body
|
39
|
+
|
40
|
+
end # Singelton
|
41
|
+
|
42
|
+
end # Define
|
43
|
+
end # Node
|
44
|
+
end # Mutator
|
45
|
+
end # Mutant
|
@@ -1,108 +1,68 @@
|
|
1
1
|
module Mutant
|
2
2
|
class Mutator
|
3
3
|
class Node
|
4
|
-
# Mutator for
|
4
|
+
# Mutator for if nodes
|
5
5
|
class If < self
|
6
6
|
|
7
|
-
handle(
|
7
|
+
handle(:if)
|
8
|
+
|
9
|
+
children :condition, :if_branch, :else_branch
|
8
10
|
|
9
11
|
private
|
10
12
|
|
11
|
-
# Emit mutations
|
13
|
+
# Emit mutations
|
12
14
|
#
|
13
15
|
# @return [undefined]
|
14
16
|
#
|
15
17
|
# @api private
|
16
18
|
#
|
17
19
|
def dispatch
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
emit_inverted_condition
|
22
|
-
emit_deleted_if_branch
|
23
|
-
emit_deleted_else_branch
|
24
|
-
end
|
25
|
-
|
26
|
-
# Test if attribute is non nil literal
|
27
|
-
#
|
28
|
-
# @param [Symbol] name
|
29
|
-
#
|
30
|
-
# @return [true]
|
31
|
-
# if attribute value a nil literal
|
32
|
-
#
|
33
|
-
# @return [false]
|
34
|
-
# otherwise
|
35
|
-
#
|
36
|
-
# @api private
|
37
|
-
#
|
38
|
-
def nil_literal?(name)
|
39
|
-
node.public_send(name).kind_of?(Rubinius::AST::NilLiteral)
|
20
|
+
mutate_condition
|
21
|
+
mutate_if_branch
|
22
|
+
mutate_else_branch
|
40
23
|
end
|
41
24
|
|
42
|
-
# Emit
|
43
|
-
#
|
44
|
-
# Especially the same like swap branches but more universal as it also
|
45
|
-
# covers the case there is no else branch
|
25
|
+
# Emit conditon mutations
|
46
26
|
#
|
47
27
|
# @return [undefined]
|
48
28
|
#
|
49
29
|
# @api private
|
50
30
|
#
|
51
|
-
def
|
52
|
-
|
31
|
+
def mutate_condition
|
32
|
+
emit_condition_mutations
|
33
|
+
emit_self(s(:send, condition, :!), if_branch, else_branch)
|
34
|
+
emit_self(s(:true), if_branch, else_branch)
|
35
|
+
emit_self(s(:false), if_branch, else_branch)
|
53
36
|
end
|
54
37
|
|
55
|
-
# Emit
|
38
|
+
# Emit if branch mutations
|
56
39
|
#
|
57
40
|
# @return [undefined]
|
58
41
|
#
|
59
42
|
# @api private
|
60
43
|
#
|
61
|
-
def
|
62
|
-
emit_self(condition,
|
44
|
+
def mutate_if_branch
|
45
|
+
emit_self(condition, else_branch, nil) if else_branch
|
46
|
+
if if_branch
|
47
|
+
emit_if_branch_mutations
|
48
|
+
emit_self(condition, if_branch, nil)
|
49
|
+
end
|
63
50
|
end
|
64
51
|
|
65
|
-
# Emit
|
52
|
+
# Emit else branch mutations
|
66
53
|
#
|
67
54
|
# @return [undefined]
|
68
55
|
#
|
69
56
|
# @api private
|
70
57
|
#
|
71
|
-
def
|
72
|
-
|
73
|
-
|
58
|
+
def mutate_else_branch
|
59
|
+
if else_branch
|
60
|
+
emit_else_branch_mutations
|
61
|
+
emit_self(condition, nil, else_branch)
|
62
|
+
end
|
74
63
|
end
|
75
64
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
# @api private
|
81
|
-
#
|
82
|
-
def if_branch
|
83
|
-
node.body
|
84
|
-
end
|
85
|
-
|
86
|
-
# Return condition of node
|
87
|
-
#
|
88
|
-
# @return [Rubinius::AST::Node]
|
89
|
-
#
|
90
|
-
# @api private
|
91
|
-
#
|
92
|
-
def condition
|
93
|
-
node.condition
|
94
|
-
end
|
95
|
-
|
96
|
-
# Return else body of node
|
97
|
-
#
|
98
|
-
# @return [Rubinius::AST::Node]
|
99
|
-
#
|
100
|
-
# @api private
|
101
|
-
#
|
102
|
-
def else_branch
|
103
|
-
node.else
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
65
|
+
end # If
|
66
|
+
end # Node
|
67
|
+
end # Mutator
|
68
|
+
end # Mutant
|
@@ -5,7 +5,7 @@ module Mutant
|
|
5
5
|
# Mutator for array literals
|
6
6
|
class Array < self
|
7
7
|
|
8
|
-
handle(
|
8
|
+
handle(:array)
|
9
9
|
|
10
10
|
private
|
11
11
|
|
@@ -16,13 +16,29 @@ module Mutant
|
|
16
16
|
# @api private
|
17
17
|
#
|
18
18
|
def dispatch
|
19
|
-
emit_attribute_mutations(:body)
|
20
|
-
emit_self([])
|
21
19
|
emit_nil
|
22
|
-
emit_self
|
20
|
+
emit_self
|
21
|
+
mutate_body
|
23
22
|
end
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
|
24
|
+
# Mutate body
|
25
|
+
#
|
26
|
+
# @return [undefined]
|
27
|
+
#
|
28
|
+
# @api private
|
29
|
+
#
|
30
|
+
def mutate_body
|
31
|
+
children.each_index do |index|
|
32
|
+
dup_children = children.dup
|
33
|
+
dup_children.delete_at(index)
|
34
|
+
emit_self(*dup_children)
|
35
|
+
mutate_child(index)
|
36
|
+
end
|
37
|
+
emit_self(s(:nil), *children)
|
38
|
+
end
|
39
|
+
|
40
|
+
end # Array
|
41
|
+
end # Literal
|
42
|
+
end # Node
|
43
|
+
end # Mutator
|
44
|
+
end # Mutant
|
@@ -7,6 +7,13 @@ module Mutant
|
|
7
7
|
|
8
8
|
private
|
9
9
|
|
10
|
+
MAP = {
|
11
|
+
:true => :false,
|
12
|
+
:false => :true
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
handle(*MAP.keys)
|
16
|
+
|
10
17
|
# Emit mutants
|
11
18
|
#
|
12
19
|
# @return [undefined]
|
@@ -15,35 +22,11 @@ module Mutant
|
|
15
22
|
#
|
16
23
|
def dispatch
|
17
24
|
emit_nil
|
18
|
-
emit(
|
19
|
-
end
|
20
|
-
|
21
|
-
# Return inverse
|
22
|
-
#
|
23
|
-
# @return [Rubinius::AST::Node]
|
24
|
-
#
|
25
|
-
# @api private
|
26
|
-
#
|
27
|
-
def inverse
|
28
|
-
new(self.class::INVERSE_CLASS)
|
29
|
-
end
|
30
|
-
|
31
|
-
# Mutator for true literals
|
32
|
-
class TrueLiteral < self
|
33
|
-
INVERSE_CLASS = Rubinius::AST::FalseLiteral
|
34
|
-
|
35
|
-
handle(Rubinius::AST::TrueLiteral)
|
25
|
+
emit(s(MAP.fetch(node.type)))
|
36
26
|
end
|
37
27
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
handle(Rubinius::AST::FalseLiteral)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
28
|
+
end # Boolean
|
29
|
+
end # Literal
|
30
|
+
end # Node
|
31
|
+
end # Mutatork
|
32
|
+
end # Mutant
|
@@ -5,7 +5,7 @@ module Mutant
|
|
5
5
|
# Mutator for fixnum literals
|
6
6
|
class Fixnum < self
|
7
7
|
|
8
|
-
handle(
|
8
|
+
handle(:int)
|
9
9
|
|
10
10
|
private
|
11
11
|
|
@@ -28,10 +28,21 @@ module Mutant
|
|
28
28
|
# @api private
|
29
29
|
#
|
30
30
|
def values
|
31
|
-
[0, 1, -
|
31
|
+
[0, 1, -value, value+1, value-1]
|
32
32
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
|
34
|
+
# Return value
|
35
|
+
#
|
36
|
+
# @return [Object]
|
37
|
+
#
|
38
|
+
# @api private
|
39
|
+
#
|
40
|
+
def value
|
41
|
+
children.first
|
42
|
+
end
|
43
|
+
|
44
|
+
end # Fixnuma
|
45
|
+
end # Literal
|
46
|
+
end # Node
|
47
|
+
end # Mutator
|
48
|
+
end # Mutant
|
@@ -5,7 +5,7 @@ module Mutant
|
|
5
5
|
# Mutator for float literals
|
6
6
|
class Float < self
|
7
7
|
|
8
|
-
handle(
|
8
|
+
handle(:float)
|
9
9
|
|
10
10
|
private
|
11
11
|
|
@@ -20,6 +20,12 @@ module Mutant
|
|
20
20
|
emit_new { new_self(Random.float) }
|
21
21
|
end
|
22
22
|
|
23
|
+
SPECIAL = [
|
24
|
+
NodeHelpers::NAN,
|
25
|
+
NodeHelpers::NEGATIVE_INFINITY,
|
26
|
+
NodeHelpers::INFINITY
|
27
|
+
].freeze
|
28
|
+
|
23
29
|
# Emit special cases
|
24
30
|
#
|
25
31
|
# @return [undefined]
|
@@ -27,7 +33,7 @@ module Mutant
|
|
27
33
|
# @api private
|
28
34
|
#
|
29
35
|
def emit_special_cases
|
30
|
-
|
36
|
+
SPECIAL.each do |value|
|
31
37
|
emit(value)
|
32
38
|
end
|
33
39
|
end
|
@@ -39,10 +45,11 @@ module Mutant
|
|
39
45
|
# @api private
|
40
46
|
#
|
41
47
|
def values
|
42
|
-
[0.0, 1.0
|
48
|
+
[0.0, 1.0, -children.first]
|
43
49
|
end
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
50
|
+
|
51
|
+
end # Float
|
52
|
+
end # Literal
|
53
|
+
end # Node
|
54
|
+
end # Mutator
|
55
|
+
end # Mutant
|
@@ -5,7 +5,7 @@ module Mutant
|
|
5
5
|
# Mutator for hash literals
|
6
6
|
class Hash < self
|
7
7
|
|
8
|
-
handle(
|
8
|
+
handle(:hash)
|
9
9
|
|
10
10
|
private
|
11
11
|
|
@@ -17,67 +17,48 @@ module Mutant
|
|
17
17
|
#
|
18
18
|
def dispatch
|
19
19
|
emit_nil
|
20
|
-
|
21
|
-
|
22
|
-
emit_body
|
20
|
+
emit_self
|
21
|
+
mutate_body
|
23
22
|
end
|
24
23
|
|
25
|
-
#
|
24
|
+
# Mutate body
|
26
25
|
#
|
27
26
|
# @return [undefined]
|
28
27
|
#
|
29
28
|
# @api private
|
30
29
|
#
|
31
|
-
def
|
32
|
-
|
30
|
+
def mutate_body
|
31
|
+
children.each_index do |index|
|
32
|
+
mutate_child(index)
|
33
|
+
dup_children = children.dup
|
34
|
+
dup_children.delete_at(index)
|
35
|
+
emit_self(*dup_children)
|
36
|
+
end
|
33
37
|
end
|
34
38
|
|
35
|
-
#
|
36
|
-
|
37
|
-
# @return [Array]
|
38
|
-
#
|
39
|
-
# @api private
|
40
|
-
#
|
41
|
-
def array
|
42
|
-
node.array
|
43
|
-
end
|
39
|
+
# Mutator for hash pairs
|
40
|
+
class Pair < Node
|
44
41
|
|
45
|
-
|
46
|
-
#
|
47
|
-
# @return [Array]
|
48
|
-
#
|
49
|
-
# @api private
|
50
|
-
#
|
51
|
-
def dup_array
|
52
|
-
array.dup
|
53
|
-
end
|
42
|
+
handle(:pair)
|
54
43
|
|
55
|
-
|
56
|
-
#
|
57
|
-
# @return [Array]
|
58
|
-
#
|
59
|
-
# @api private
|
60
|
-
#
|
61
|
-
def values
|
62
|
-
[[]]
|
63
|
-
end
|
44
|
+
children :key, :value
|
64
45
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
emit_self(contents)
|
46
|
+
private
|
47
|
+
|
48
|
+
# Perform dispatch
|
49
|
+
#
|
50
|
+
# @return [undefined]
|
51
|
+
#
|
52
|
+
# @api private
|
53
|
+
#
|
54
|
+
def dispatch
|
55
|
+
emit_key_mutations
|
56
|
+
emit_value_mutations
|
77
57
|
end
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
58
|
+
|
59
|
+
end # Pair
|
60
|
+
end # Hash
|
61
|
+
end # Literal
|
62
|
+
end # Node
|
63
|
+
end # Mutator
|
64
|
+
end # Mutant
|
@@ -5,7 +5,7 @@ module Mutant
|
|
5
5
|
# Mutator for nil literals
|
6
6
|
class Nil < self
|
7
7
|
|
8
|
-
handle(
|
8
|
+
handle(:nil)
|
9
9
|
|
10
10
|
private
|
11
11
|
|
@@ -16,10 +16,11 @@ module Mutant
|
|
16
16
|
# @api private
|
17
17
|
#
|
18
18
|
def dispatch
|
19
|
-
emit(
|
19
|
+
emit(NEW_OBJECT)
|
20
20
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
21
|
+
|
22
|
+
end # Nil
|
23
|
+
end # Literal
|
24
|
+
end # Node
|
25
|
+
end # Mutator
|
26
|
+
end # Mutant
|