mutant 0.1.1 → 0.2.0
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.
- data/.gitignore +5 -11
- data/.rspec +0 -1
- data/.travis.yml +14 -3
- data/Changelog.md +3 -0
- data/Gemfile +5 -1
- data/Gemfile.devtools +49 -0
- data/Guardfile +18 -0
- data/README.md +67 -0
- data/Rakefile +4 -1
- data/TODO +13 -0
- data/bin/mutant +14 -0
- data/bin/zombie +14 -0
- data/config/flay.yml +3 -0
- data/config/flog.yml +2 -0
- data/config/roodi.yml +26 -0
- data/config/site.reek +93 -0
- data/config/yardstick.yml +2 -0
- data/lib/inflector.rb +7 -0
- data/lib/inflector/defaults.rb +62 -0
- data/lib/inflector/inflections.rb +209 -0
- data/lib/inflector/methods.rb +149 -0
- data/lib/inflector/version.rb +3 -0
- data/lib/mutant.rb +96 -21
- data/lib/mutant/cli.rb +309 -0
- data/lib/mutant/color.rb +61 -0
- data/lib/mutant/context.rb +36 -0
- data/lib/mutant/context/scope.rb +138 -0
- data/lib/mutant/differ.rb +100 -0
- data/lib/mutant/helper.rb +38 -0
- data/lib/mutant/killer.rb +136 -0
- data/lib/mutant/killer/forking.rb +41 -0
- data/lib/mutant/killer/rspec.rb +49 -0
- data/lib/mutant/killer/static.rb +19 -0
- data/lib/mutant/loader.rb +129 -0
- data/lib/mutant/matcher.rb +55 -0
- data/lib/mutant/matcher/chain.rb +66 -0
- data/lib/mutant/matcher/method.rb +173 -0
- data/lib/mutant/matcher/method/classifier.rb +126 -0
- data/lib/mutant/matcher/method/instance.rb +67 -0
- data/lib/mutant/matcher/method/singleton.rb +141 -0
- data/lib/mutant/matcher/object_space.rb +114 -0
- data/lib/mutant/matcher/scope_methods.rb +127 -0
- data/lib/mutant/mutation.rb +101 -12
- data/lib/mutant/mutation/filter.rb +75 -0
- data/lib/mutant/mutation/filter/code.rb +68 -0
- data/lib/mutant/mutation/filter/regexp.rb +39 -0
- data/lib/mutant/mutation/filter/whitelist.rb +47 -0
- data/lib/mutant/mutator.rb +134 -30
- data/lib/mutant/mutator/node.rb +163 -0
- data/lib/mutant/mutator/node/arguments.rb +24 -0
- data/lib/mutant/mutator/node/block.rb +24 -0
- data/lib/mutant/mutator/node/define.rb +24 -0
- data/lib/mutant/mutator/node/if_statement.rb +93 -0
- data/lib/mutant/mutator/node/literal.rb +54 -0
- data/lib/mutant/mutator/node/literal/array.rb +28 -0
- data/lib/mutant/mutator/node/literal/boolean.rb +49 -0
- data/lib/mutant/mutator/node/literal/dynamic.rb +24 -0
- data/lib/mutant/mutator/node/literal/empty_array.rb +26 -0
- data/lib/mutant/mutator/node/literal/fixnum.rb +37 -0
- data/lib/mutant/mutator/node/literal/float.rb +48 -0
- data/lib/mutant/mutator/node/literal/hash.rb +89 -0
- data/lib/mutant/mutator/node/literal/nil.rb +25 -0
- data/lib/mutant/mutator/node/literal/range.rb +94 -0
- data/lib/mutant/mutator/node/literal/regex.rb +43 -0
- data/lib/mutant/mutator/node/literal/string.rb +26 -0
- data/lib/mutant/mutator/node/literal/symbol.rb +26 -0
- data/lib/mutant/mutator/node/noop.rb +55 -0
- data/lib/mutant/mutator/node/receiver_case.rb +140 -0
- data/lib/mutant/mutator/node/return.rb +31 -0
- data/lib/mutant/mutator/node/send.rb +112 -0
- data/lib/mutant/mutator/registry.rb +48 -0
- data/lib/mutant/mutator/util.rb +87 -0
- data/lib/mutant/random.rb +24 -27
- data/lib/mutant/reporter.rb +48 -30
- data/lib/mutant/reporter/cli.rb +221 -0
- data/lib/mutant/reporter/null.rb +42 -0
- data/lib/mutant/reporter/stats.rb +64 -0
- data/lib/mutant/runner.rb +112 -0
- data/lib/mutant/strategy.rb +42 -0
- data/lib/mutant/strategy/rspec.rb +59 -0
- data/lib/mutant/strategy/rspec/example_lookup.rb +122 -0
- data/lib/mutant/subject.rb +115 -0
- data/lib/mutant/support/method_object.rb +31 -0
- data/locator.rb +87 -0
- data/mutant.gemspec +21 -21
- data/spec/integration/mutant/differ_spec.rb +15 -0
- data/spec/integration/mutant/loader_spec.rb +21 -0
- data/spec/integration/mutant/method_matching_spec.rb +269 -0
- data/spec/integration/mutant/rspec_killer_spec.rb +24 -0
- data/spec/integration/mutant/runner_spec.rb +26 -0
- data/spec/integration/mutant/zombie_spec.rb +8 -0
- data/spec/rcov.opts +7 -0
- data/spec/shared/command_method_behavior.rb +7 -0
- data/spec/shared/each_method_behaviour.rb +15 -0
- data/spec/shared/hash_method_behavior.rb +17 -0
- data/spec/shared/idempotent_method_behavior.rb +7 -0
- data/spec/shared/invertible_method_behaviour.rb +9 -0
- data/spec/shared/method_filter_parse_behavior.rb +16 -0
- data/spec/shared/method_match_behavior.rb +39 -0
- data/spec/shared/mutator_behavior.rb +46 -0
- data/spec/spec_helper.rb +11 -14
- data/spec/support/compress_helper.rb +10 -0
- data/spec/support/rspec.rb +22 -0
- data/spec/support/test_app.rb +5 -0
- data/spec/support/zombie.rb +141 -0
- data/spec/unit/mutant/cli/class_methods/new_spec.rb +87 -0
- data/spec/unit/mutant/cli/class_methods/run_spec.rb +38 -0
- data/spec/unit/mutant/context/root_spec.rb +11 -0
- data/spec/unit/mutant/context/scope/class_methods/build_spec.rb +29 -0
- data/spec/unit/mutant/context/scope/root_spec.rb +22 -0
- data/spec/unit/mutant/context/scope/unqualified_name_spec.rb +27 -0
- data/spec/unit/mutant/killer/fail_ques_spec.rb +39 -0
- data/spec/unit/mutant/killer/rspec/class_methods/new_spec.rb +32 -0
- data/spec/unit/mutant/loader/eval/class_methods/run_spec.rb +33 -0
- data/spec/unit/mutant/loader/rubinius/class_methods/run_spec.rb +42 -0
- data/spec/unit/mutant/matcher/chain/each_spec.rb +37 -0
- data/spec/unit/mutant/matcher/chain/matchers_spec.rb +12 -0
- data/spec/unit/mutant/matcher/class_methods/from_string_spec.rb +49 -0
- data/spec/unit/mutant/matcher/class_methods/parse_spec.rb +12 -0
- data/spec/unit/mutant/matcher/each_spec.rb +14 -0
- data/spec/unit/mutant/matcher/method/class_methods/parse_spec.rb +21 -0
- data/spec/unit/mutant/matcher/method/classifier/class_methods/run_spec.rb +34 -0
- data/spec/unit/mutant/matcher/method/method_spec.rb +11 -0
- data/spec/unit/mutant/matcher/object_space/class_methods/parse_spec.rb +24 -0
- data/spec/unit/mutant/matcher/object_space/each_spec.rb +31 -0
- data/spec/unit/mutant/mutator/each_spec.rb +25 -0
- data/spec/unit/mutant/mutator/emit_new_spec.rb +51 -0
- data/spec/unit/mutant/mutator/emit_spec.rb +52 -0
- data/spec/unit/mutant/mutator/node/block/mutation_spec.rb +36 -0
- data/spec/unit/mutant/mutator/node/define/mutation_spec.rb +47 -0
- data/spec/unit/mutant/mutator/node/if_statement/mutation_spec.rb +30 -0
- data/spec/unit/mutant/mutator/node/literal/array_spec.rb +30 -0
- data/spec/unit/mutant/mutator/node/literal/boolean/mutation_spec.rb +23 -0
- data/spec/unit/mutant/mutator/node/literal/empty_array_spec.rb +17 -0
- data/spec/unit/mutant/mutator/node/literal/fixnum_spec.rb +17 -0
- data/spec/unit/mutant/mutator/node/literal/float_spec.rb +25 -0
- data/spec/unit/mutant/mutator/node/literal/hash_spec.rb +34 -0
- data/spec/unit/mutant/mutator/node/literal/nil_spec.rb +13 -0
- data/spec/unit/mutant/mutator/node/literal/range_spec.rb +35 -0
- data/spec/unit/mutant/mutator/node/literal/regex_spec.rb +23 -0
- data/spec/unit/mutant/mutator/node/literal/string_spec.rb +17 -0
- data/spec/unit/mutant/mutator/node/literal/symbol_spec.rb +17 -0
- data/spec/unit/mutant/mutator/node/receiver_case/mutation_spec.rb +27 -0
- data/spec/unit/mutant/mutator/node/return/mutation_spec.rb +21 -0
- data/spec/unit/mutant/mutator/node/send/mutation_spec.rb +78 -0
- data/spec/unit/mutant/mutator/self_spec.rb +7 -0
- data/spec/unit/mutant/subject/class_methods/new_spec.rb +13 -0
- data/spec/unit/mutant/subject/context_spec.rb +14 -0
- data/spec/unit/mutant/subject/each_spec.rb +35 -0
- data/spec/unit/mutant/subject/node_spec.rb +13 -0
- data/tasks/metrics/ci.rake +7 -0
- data/tasks/metrics/flay.rake +41 -0
- data/tasks/metrics/flog.rake +43 -0
- data/tasks/metrics/heckle.rake +216 -0
- data/tasks/metrics/metric_fu.rake +31 -0
- data/tasks/metrics/reek.rake +15 -0
- data/tasks/metrics/roodi.rake +15 -0
- data/tasks/metrics/yardstick.rake +23 -0
- data/tasks/spec.rake +45 -0
- data/tasks/yard.rake +9 -0
- data/test_app/.rspec +1 -0
- data/test_app/lib/test_app.rb +5 -0
- data/test_app/lib/test_app/literal.rb +32 -0
- data/test_app/spec/shared/command_method_behavior.rb +7 -0
- data/test_app/spec/shared/each_method_behaviour.rb +15 -0
- data/test_app/spec/shared/hash_method_behavior.rb +17 -0
- data/test_app/spec/shared/idempotent_method_behavior.rb +7 -0
- data/test_app/spec/shared/invertible_method_behaviour.rb +9 -0
- data/test_app/spec/shared/method_filter_parse_behavior.rb +16 -0
- data/test_app/spec/shared/method_match_behavior.rb +39 -0
- data/test_app/spec/shared/mutator_behavior.rb +44 -0
- data/test_app/spec/spec_helper.rb +7 -0
- data/test_app/spec/unit/test_app/literal/command_spec.rb +9 -0
- data/test_app/spec/unit/test_app/literal/string_spec.rb +9 -0
- metadata +346 -124
- data/.rvmrc +0 -1
- data/Readme.md +0 -13
- data/exe/mutate +0 -6
- data/lib/mutant/extensions.rb +0 -8
- data/lib/mutant/formatter.rb +0 -19
- data/lib/mutant/implementation.rb +0 -70
- data/lib/mutant/literal.rb +0 -147
- data/lib/mutant/method.rb +0 -31
- data/lib/mutant/mutatee.rb +0 -61
- data/lib/mutant/node.rb +0 -26
- data/lib/mutant/runners/rspec.rb +0 -34
- data/lib/mutant/version.rb +0 -3
- data/spec/functional/class_spec.rb +0 -46
- data/spec/functional/instance_method/array_spec.rb +0 -53
- data/spec/functional/instance_method/boolean_spec.rb +0 -101
- data/spec/functional/instance_method/call_spec.rb +0 -161
- data/spec/functional/instance_method/fixnum_spec.rb +0 -53
- data/spec/functional/instance_method/float_spec.rb +0 -53
- data/spec/functional/instance_method/hash_spec.rb +0 -53
- data/spec/functional/instance_method/if_spec.rb +0 -57
- data/spec/functional/instance_method/ivar_assign_spec.rb +0 -62
- data/spec/functional/instance_method/range_spec.rb +0 -53
- data/spec/functional/instance_method/regex_spec.rb +0 -55
- data/spec/functional/instance_method/string_spec.rb +0 -53
- data/spec/functional/instance_method/symbol_spec.rb +0 -53
- data/spec/functional/reporter/method_loaded_spec.rb +0 -62
- data/spec/functional/reporter/running_mutations_spec.rb +0 -60
- data/spec/functional/runners/rspec_spec.rb +0 -26
- data/spec/functional/singleton_method/array_spec.rb +0 -53
- data/spec/functional/singleton_method/boolean_spec.rb +0 -101
- data/spec/functional/singleton_method/call_spec.rb +0 -161
- data/spec/functional/singleton_method/fixnum_spec.rb +0 -53
- data/spec/functional/singleton_method/float_spec.rb +0 -53
- data/spec/functional/singleton_method/hash_spec.rb +0 -53
- data/spec/functional/singleton_method/if_spec.rb +0 -57
- data/spec/functional/singleton_method/ivar_assign_spec.rb +0 -60
- data/spec/functional/singleton_method/range_spec.rb +0 -53
- data/spec/functional/singleton_method/regex_spec.rb +0 -55
- data/spec/functional/singleton_method/string_spec.rb +0 -53
- data/spec/functional/singleton_method/symbol_spec.rb +0 -53
- data/spec/mutant/extensions_spec.rb +0 -13
- data/spec/mutant/implementation_spec.rb +0 -223
- data/spec/mutant/literal_spec.rb +0 -129
- data/spec/mutant/mutatee_spec.rb +0 -28
- data/spec/mutant/node_spec.rb +0 -41
- data/spec/mutant/random_spec.rb +0 -33
- data/spec/mutant/reporter_spec.rb +0 -17
- data/spec/mutant_spec.rb +0 -28
- data/spec/support/example_group_helpers.rb +0 -11
- data/spec/support/example_helpers.rb +0 -5
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Mutant
|
|
2
|
+
class Mutator
|
|
3
|
+
class Node
|
|
4
|
+
# Mutator for arguments
|
|
5
|
+
class Arguments < self
|
|
6
|
+
|
|
7
|
+
handle(Rubinius::AST::ActualArguments)
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
# Emit mutations
|
|
12
|
+
#
|
|
13
|
+
# @return [undefined]
|
|
14
|
+
#
|
|
15
|
+
# @api private
|
|
16
|
+
#
|
|
17
|
+
def dispatch
|
|
18
|
+
emit_attribute_mutations(:array)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Mutant
|
|
2
|
+
class Mutator
|
|
3
|
+
class Node
|
|
4
|
+
# Mutator on AST blocks
|
|
5
|
+
class Block < self
|
|
6
|
+
|
|
7
|
+
handle(Rubinius::AST::Block)
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
# Emit mutants
|
|
12
|
+
#
|
|
13
|
+
# @return [undefined]
|
|
14
|
+
#
|
|
15
|
+
# @api private
|
|
16
|
+
#
|
|
17
|
+
def dispatch
|
|
18
|
+
array = input.array
|
|
19
|
+
emit_attribute_mutations(:array)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Mutant
|
|
2
|
+
class Mutator
|
|
3
|
+
class Node
|
|
4
|
+
class Define < self
|
|
5
|
+
|
|
6
|
+
handle(Rubinius::AST::Define)
|
|
7
|
+
handle(Rubinius::AST::DefineSingleton)
|
|
8
|
+
handle(Rubinius::AST::DefineSingletonScope)
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
# Emit mutations
|
|
13
|
+
#
|
|
14
|
+
# @return [undefined]
|
|
15
|
+
#
|
|
16
|
+
# @api private
|
|
17
|
+
#
|
|
18
|
+
def dispatch
|
|
19
|
+
emit_attribute_mutations(:body)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
module Mutant
|
|
2
|
+
class Mutator
|
|
3
|
+
class Node
|
|
4
|
+
# Mutator for Rubinius::AST::If nodes
|
|
5
|
+
class IfStatement < self
|
|
6
|
+
|
|
7
|
+
handle(Rubinius::AST::If)
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
# Emit mutations on Rubinius::AST::If nodes
|
|
12
|
+
#
|
|
13
|
+
# @return [undefined]
|
|
14
|
+
#
|
|
15
|
+
# @api private
|
|
16
|
+
#
|
|
17
|
+
def dispatch
|
|
18
|
+
emit_attribute_mutations(:condition)
|
|
19
|
+
emit_attribute_mutations(:body)
|
|
20
|
+
emit_attribute_mutations(:else) if node.else
|
|
21
|
+
emit_inverted_condition
|
|
22
|
+
emit_deleted_if_branch
|
|
23
|
+
emit_deleted_else_branch
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Emit inverted condition
|
|
27
|
+
#
|
|
28
|
+
# Especially the same like swap branches but more universal as it also
|
|
29
|
+
# covers the case there is no else branch
|
|
30
|
+
#
|
|
31
|
+
# @return [undefined]
|
|
32
|
+
#
|
|
33
|
+
# @api private
|
|
34
|
+
#
|
|
35
|
+
def emit_inverted_condition
|
|
36
|
+
emit_self(new_send(condition, :'!'), if_branch, else_branch)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Emit deleted else branch
|
|
40
|
+
#
|
|
41
|
+
# @return [undefined]
|
|
42
|
+
#
|
|
43
|
+
# @api private
|
|
44
|
+
#
|
|
45
|
+
def emit_deleted_else_branch
|
|
46
|
+
emit_self(condition, if_branch, nil)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Emit deleted if branch
|
|
50
|
+
#
|
|
51
|
+
# @return [undefined]
|
|
52
|
+
#
|
|
53
|
+
# @api private
|
|
54
|
+
#
|
|
55
|
+
def emit_deleted_if_branch
|
|
56
|
+
body = else_branch
|
|
57
|
+
return unless body
|
|
58
|
+
emit_self(condition, else_branch, nil)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Return if_branch of node
|
|
62
|
+
#
|
|
63
|
+
# @return [Rubinius::AST::Node]
|
|
64
|
+
#
|
|
65
|
+
# @api private
|
|
66
|
+
#
|
|
67
|
+
def if_branch
|
|
68
|
+
node.body
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Return condition of node
|
|
72
|
+
#
|
|
73
|
+
# @return [Rubinius::AST::Node]
|
|
74
|
+
#
|
|
75
|
+
# @api private
|
|
76
|
+
#
|
|
77
|
+
def condition
|
|
78
|
+
node.condition
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Return else body of node
|
|
82
|
+
#
|
|
83
|
+
# @return [Rubinius::AST::Node]
|
|
84
|
+
#
|
|
85
|
+
# @api private
|
|
86
|
+
#
|
|
87
|
+
def else_branch
|
|
88
|
+
node.else
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module Mutant
|
|
2
|
+
class Mutator
|
|
3
|
+
class Node
|
|
4
|
+
# Abstract mutator for literal AST nodes
|
|
5
|
+
class Literal < self
|
|
6
|
+
include AbstractType
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
|
|
10
|
+
# Return new float literal
|
|
11
|
+
#
|
|
12
|
+
# @param [#to_f] value
|
|
13
|
+
#
|
|
14
|
+
# @return [Rubinius::Node::FloatLiteral]
|
|
15
|
+
#
|
|
16
|
+
# @api private
|
|
17
|
+
#
|
|
18
|
+
def new_float(value)
|
|
19
|
+
new(Rubinius::AST::FloatLiteral, value)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Return AST representing NaN
|
|
23
|
+
#
|
|
24
|
+
# @return [Rubinius::Node::AST]
|
|
25
|
+
#
|
|
26
|
+
# @api private
|
|
27
|
+
#
|
|
28
|
+
def nan
|
|
29
|
+
new_send(new_float(0), :/, new_float(0))
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Return AST representing negative infinity
|
|
33
|
+
#
|
|
34
|
+
# @return [Rubinius::Node::AST]
|
|
35
|
+
#
|
|
36
|
+
# @api private
|
|
37
|
+
#
|
|
38
|
+
def negative_infinity
|
|
39
|
+
new(Rubinius::AST::Negate, infinity)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Return AST representing infinity
|
|
43
|
+
#
|
|
44
|
+
# @return [Rubinius::Node::AST]
|
|
45
|
+
#
|
|
46
|
+
# @api private
|
|
47
|
+
#
|
|
48
|
+
def infinity
|
|
49
|
+
new_send(new_float(1), :/, new_float(0))
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Mutant
|
|
2
|
+
class Mutator
|
|
3
|
+
class Node
|
|
4
|
+
class Literal < self
|
|
5
|
+
# Mutator for array literals
|
|
6
|
+
class Array < self
|
|
7
|
+
|
|
8
|
+
handle(Rubinius::AST::ArrayLiteral)
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
# Emit mutations
|
|
13
|
+
#
|
|
14
|
+
# @return [undefined]
|
|
15
|
+
#
|
|
16
|
+
# @api private
|
|
17
|
+
#
|
|
18
|
+
def dispatch
|
|
19
|
+
emit_attribute_mutations(:body)
|
|
20
|
+
emit_self([])
|
|
21
|
+
emit_nil
|
|
22
|
+
emit_self(node.body.dup << new_nil)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Mutant
|
|
2
|
+
class Mutator
|
|
3
|
+
class Node
|
|
4
|
+
class Literal < self
|
|
5
|
+
# Abstract mutator for boolean literals
|
|
6
|
+
class Boolean < self
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
|
|
10
|
+
# Emit mutants
|
|
11
|
+
#
|
|
12
|
+
# @return [undefined]
|
|
13
|
+
#
|
|
14
|
+
# @api private
|
|
15
|
+
#
|
|
16
|
+
def dispatch
|
|
17
|
+
emit_nil
|
|
18
|
+
emit(inverse)
|
|
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)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# Mutator for false literals
|
|
40
|
+
class FalseLiteral < self
|
|
41
|
+
INVERSE_CLASS = Rubinius::AST::TrueLiteral
|
|
42
|
+
|
|
43
|
+
handle(Rubinius::AST::FalseLiteral)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Mutant
|
|
2
|
+
class Mutator
|
|
3
|
+
class Node
|
|
4
|
+
class Literal
|
|
5
|
+
# Abstract mutations on dynamic literals
|
|
6
|
+
class Dynamic < self
|
|
7
|
+
include AbstractType
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
# Emit mutants
|
|
12
|
+
#
|
|
13
|
+
# @return [undefined]
|
|
14
|
+
#
|
|
15
|
+
# @api private
|
|
16
|
+
#
|
|
17
|
+
def dispatch
|
|
18
|
+
emit_nil
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module Mutant
|
|
2
|
+
class Mutator
|
|
3
|
+
class Node
|
|
4
|
+
class Literal < self
|
|
5
|
+
# Mutator for fixnum literals
|
|
6
|
+
class Fixnum < self
|
|
7
|
+
|
|
8
|
+
handle(Rubinius::AST::FixnumLiteral)
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
# Emit mutants
|
|
13
|
+
#
|
|
14
|
+
# @return [undefined]
|
|
15
|
+
#
|
|
16
|
+
# @api private
|
|
17
|
+
#
|
|
18
|
+
def dispatch
|
|
19
|
+
emit_nil
|
|
20
|
+
emit_values(values)
|
|
21
|
+
emit_new { new_self(Random.fixnum) }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Return values to mutate against
|
|
25
|
+
#
|
|
26
|
+
# @return [Array]
|
|
27
|
+
#
|
|
28
|
+
# @api private
|
|
29
|
+
#
|
|
30
|
+
def values
|
|
31
|
+
[0, 1, -node.value]
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module Mutant
|
|
2
|
+
class Mutator
|
|
3
|
+
class Node
|
|
4
|
+
class Literal < self
|
|
5
|
+
# Mutator for float literals
|
|
6
|
+
class Float < self
|
|
7
|
+
|
|
8
|
+
handle(Rubinius::AST::FloatLiteral)
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
# Emit mutants
|
|
13
|
+
#
|
|
14
|
+
# @return [undefined]
|
|
15
|
+
#
|
|
16
|
+
def dispatch
|
|
17
|
+
emit_nil
|
|
18
|
+
emit_values(values)
|
|
19
|
+
emit_special_cases
|
|
20
|
+
emit_new { new_self(Random.float) }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Emit special cases
|
|
24
|
+
#
|
|
25
|
+
# @return [undefined]
|
|
26
|
+
#
|
|
27
|
+
# @api private
|
|
28
|
+
#
|
|
29
|
+
def emit_special_cases
|
|
30
|
+
[infinity, negative_infinity, nan].each do |value|
|
|
31
|
+
emit(value)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Return values to test against
|
|
36
|
+
#
|
|
37
|
+
# @return [Array]
|
|
38
|
+
#
|
|
39
|
+
# @api private
|
|
40
|
+
#
|
|
41
|
+
def values
|
|
42
|
+
[0.0, 1.0] << -node.value
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
module Mutant
|
|
2
|
+
class Mutator
|
|
3
|
+
class Node
|
|
4
|
+
class Literal
|
|
5
|
+
# Mutator for hash literals
|
|
6
|
+
class Hash < self
|
|
7
|
+
|
|
8
|
+
handle(Rubinius::AST::HashLiteral)
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
# Emit mutations
|
|
13
|
+
#
|
|
14
|
+
# @return [undefined]
|
|
15
|
+
#
|
|
16
|
+
# @api private
|
|
17
|
+
#
|
|
18
|
+
def dispatch
|
|
19
|
+
emit_nil
|
|
20
|
+
emit_values(values)
|
|
21
|
+
emit_element_presence
|
|
22
|
+
emit_body
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Emit body mutations
|
|
26
|
+
#
|
|
27
|
+
# @return [undefined]
|
|
28
|
+
#
|
|
29
|
+
# @api private
|
|
30
|
+
#
|
|
31
|
+
def emit_body
|
|
32
|
+
array.each_with_index do |element, index|
|
|
33
|
+
dup = dup_array
|
|
34
|
+
Mutator.each(element).each do |mutation|
|
|
35
|
+
dup[index]=mutation
|
|
36
|
+
emit_self(dup)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Return array of values in literal
|
|
42
|
+
#
|
|
43
|
+
# @return [Array]
|
|
44
|
+
#
|
|
45
|
+
# @api private
|
|
46
|
+
#
|
|
47
|
+
def array
|
|
48
|
+
node.array
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Return duplicate of array values in literal
|
|
52
|
+
#
|
|
53
|
+
# @return [Array]
|
|
54
|
+
#
|
|
55
|
+
# @api private
|
|
56
|
+
#
|
|
57
|
+
def dup_array
|
|
58
|
+
array.dup
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Return values to mutate against
|
|
62
|
+
#
|
|
63
|
+
# @return [Array]
|
|
64
|
+
#
|
|
65
|
+
# @api private
|
|
66
|
+
#
|
|
67
|
+
def values
|
|
68
|
+
[[], dup_array << new_nil << new_nil ]
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Emit element presence mutations
|
|
72
|
+
#
|
|
73
|
+
# @return [undefined]
|
|
74
|
+
#
|
|
75
|
+
# @api private
|
|
76
|
+
#
|
|
77
|
+
def emit_element_presence
|
|
78
|
+
0.step(array.length-1, 2) do |index|
|
|
79
|
+
contents = dup_array
|
|
80
|
+
contents.delete_at(index)
|
|
81
|
+
contents.delete_at(index)
|
|
82
|
+
emit_self(contents)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|