mutant 0.5.17 → 0.5.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +6 -0
- data/Rakefile +13 -0
- data/config/flay.yml +1 -1
- data/config/reek.yml +8 -1
- data/lib/mutant.rb +18 -3
- data/lib/mutant/cli.rb +6 -3
- data/lib/mutant/constants.rb +3 -0
- data/lib/mutant/expression.rb +110 -0
- data/lib/mutant/expression/method.rb +92 -0
- data/lib/mutant/expression/namespace.rb +90 -0
- data/lib/mutant/matcher/namespace.rb +3 -4
- data/lib/mutant/meta.rb +31 -0
- data/lib/mutant/meta/example.rb +152 -0
- data/lib/mutant/meta/example/dsl.rb +105 -0
- data/lib/mutant/mutator/node.rb +6 -6
- data/lib/mutant/mutator/node/arguments.rb +1 -1
- data/lib/mutant/mutator/node/begin.rb +1 -1
- data/lib/mutant/mutator/node/const.rb +1 -1
- data/lib/mutant/mutator/node/if.rb +6 -6
- data/lib/mutant/mutator/node/literal/array.rb +2 -2
- data/lib/mutant/mutator/node/literal/hash.rb +2 -2
- data/lib/mutant/mutator/node/literal/range.rb +3 -3
- data/lib/mutant/mutator/node/literal/regex.rb +2 -2
- data/lib/mutant/mutator/node/literal/symbol.rb +1 -1
- data/lib/mutant/mutator/node/op_asgn.rb +1 -3
- data/lib/mutant/mutator/node/or_asgn.rb +31 -0
- data/lib/mutant/mutator/node/send.rb +1 -1
- data/lib/mutant/mutator/node/send/attribute_assignment.rb +1 -1
- data/lib/mutant/reporter/cli/report/mutation.rb +11 -1
- data/lib/mutant/strategy.rb +1 -1
- data/lib/mutant/version.rb +1 -1
- data/meta/and.rb +12 -0
- data/meta/and_asgn.rb +12 -0
- data/meta/array.rb +30 -0
- data/meta/begin.rb +15 -0
- data/meta/binary.rb +12 -0
- data/meta/block.rb +55 -0
- data/meta/block_pass.rb +8 -0
- data/meta/blockarg.rb +10 -0
- data/meta/boolean.rb +15 -0
- data/meta/break.rb +11 -0
- data/meta/case.rb +303 -0
- data/meta/casgn.rb +9 -0
- data/meta/cbase.rb +8 -0
- data/meta/const.rb +9 -0
- data/meta/cvar.rb +7 -0
- data/meta/cvasgn.rb +10 -0
- data/meta/define.rb +118 -0
- data/meta/defined.rb +7 -0
- data/meta/dstr.rb +10 -0
- data/meta/dsym.rb +11 -0
- data/meta/ensure.rb +9 -0
- data/meta/fixnum.rb +19 -0
- data/meta/float.rb +38 -0
- data/meta/gvar.rb +7 -0
- data/meta/gvasgn.rb +10 -0
- data/meta/hash.rb +25 -0
- data/meta/if.rb +57 -0
- data/meta/ivasgn.rb +10 -0
- data/meta/kwbegin.rb +9 -0
- data/meta/lvar.rb +14 -0
- data/meta/lvasgn.rb +10 -0
- data/meta/masgn.rb +7 -0
- data/meta/match_current_line.rb +14 -0
- data/meta/next.rb +11 -0
- data/meta/nil.rb +5 -0
- data/meta/nthref.rb +14 -0
- data/meta/op_assgn.rb +15 -0
- data/meta/or_asgn.rb +22 -0
- data/meta/range.rb +41 -0
- data/meta/redo.rb +5 -0
- data/meta/regex.rb +20 -0
- data/meta/rescue.rb +38 -0
- data/meta/restarg.rb +11 -0
- data/meta/return.rb +15 -0
- data/meta/self.rb +7 -0
- data/meta/send.rb +240 -0
- data/meta/string.rb +7 -0
- data/meta/super.rb +26 -0
- data/meta/symbol.rb +8 -0
- data/meta/unless.rb +15 -0
- data/meta/while.rb +24 -0
- data/meta/yield.rb +10 -0
- data/mutant.gemspec +1 -0
- data/spec/integration/mutant/corpus_spec.rb +29 -25
- data/spec/spec_helper.rb +2 -0
- data/spec/support/mutation_verifier.rb +1 -0
- data/spec/unit/mutant/cli_new_spec.rb +6 -6
- data/spec/unit/mutant/expression/method_spec.rb +50 -0
- data/spec/unit/mutant/expression/namespace/flat_spec.rb +32 -0
- data/spec/unit/mutant/expression/namespace/recursive_spec.rb +37 -0
- data/spec/unit/mutant/matcher/namespace_spec.rb +2 -2
- data/spec/unit/mutant/mutation_spec.rb +1 -1
- data/spec/unit/mutant/mutator/node_spec.rb +14 -0
- metadata +123 -139
- data/lib/mutant/cli/classifier.rb +0 -139
- data/lib/mutant/cli/classifier/method.rb +0 -105
- data/lib/mutant/cli/classifier/namespace.rb +0 -49
- data/spec/unit/mutant/cli/classifier/method_spec.rb +0 -77
- data/spec/unit/mutant/cli/classifier/namespace/flat_spec.rb +0 -58
- data/spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb +0 -58
- data/spec/unit/mutant/cli/classifier_spec.rb +0 -59
- data/spec/unit/mutant/mutator/node/and_asgn_spec.rb +0 -19
- data/spec/unit/mutant/mutator/node/begin_spec.rb +0 -32
- data/spec/unit/mutant/mutator/node/binary_spec.rb +0 -41
- data/spec/unit/mutant/mutator/node/block_pass_spec.rb +0 -15
- data/spec/unit/mutant/mutator/node/block_spec.rb +0 -83
- data/spec/unit/mutant/mutator/node/blockarg_spec.rb +0 -17
- data/spec/unit/mutant/mutator/node/case_spec.rb +0 -329
- data/spec/unit/mutant/mutator/node/cbase_spec.rb +0 -15
- data/spec/unit/mutant/mutator/node/conditional_loop_spec.rb +0 -58
- data/spec/unit/mutant/mutator/node/const_spec.rb +0 -16
- data/spec/unit/mutant/mutator/node/define_spec.rb +0 -171
- data/spec/unit/mutant/mutator/node/defined_spec.rb +0 -14
- data/spec/unit/mutant/mutator/node/dstr_spec.rb +0 -17
- data/spec/unit/mutant/mutator/node/dsym_spec.rb +0 -18
- data/spec/unit/mutant/mutator/node/ensure_spec.rb +0 -16
- data/spec/unit/mutant/mutator/node/if_spec.rb +0 -77
- data/spec/unit/mutant/mutator/node/kwbegin_spec.rb +0 -16
- data/spec/unit/mutant/mutator/node/literal/array_spec.rb +0 -47
- data/spec/unit/mutant/mutator/node/literal/boolean_spec.rb +0 -25
- data/spec/unit/mutant/mutator/node/literal/fixnum_spec.rb +0 -13
- data/spec/unit/mutant/mutator/node/literal/float_spec.rb +0 -53
- data/spec/unit/mutant/mutator/node/literal/hash_spec.rb +0 -33
- data/spec/unit/mutant/mutator/node/literal/nil_spec.rb +0 -10
- data/spec/unit/mutant/mutator/node/literal/range_spec.rb +0 -56
- data/spec/unit/mutant/mutator/node/literal/regex_spec.rb +0 -36
- data/spec/unit/mutant/mutator/node/literal/string_spec.rb +0 -15
- data/spec/unit/mutant/mutator/node/literal/symbol_spec.rb +0 -15
- data/spec/unit/mutant/mutator/node/loop_ctrl_spec.rb +0 -37
- data/spec/unit/mutant/mutator/node/masgn_spec.rb +0 -14
- data/spec/unit/mutant/mutator/node/match_current_line_spec.rb +0 -21
- data/spec/unit/mutant/mutator/node/named_value/access_spec.rb +0 -78
- data/spec/unit/mutant/mutator/node/named_value/constant_assignment_spec.rb +0 -16
- data/spec/unit/mutant/mutator/node/named_value/variable_assignment_spec.rb +0 -61
- data/spec/unit/mutant/mutator/node/nthref_spec.rb +0 -19
- data/spec/unit/mutant/mutator/node/op_assgn_spec.rb +0 -22
- data/spec/unit/mutant/mutator/node/or_asgn_spec.rb +0 -19
- data/spec/unit/mutant/mutator/node/redo_spec.rb +0 -10
- data/spec/unit/mutant/mutator/node/rescue_spec.rb +0 -63
- data/spec/unit/mutant/mutator/node/restarg_spec.rb +0 -18
- data/spec/unit/mutant/mutator/node/return_spec.rb +0 -31
- data/spec/unit/mutant/mutator/node/send_spec.rb +0 -382
- data/spec/unit/mutant/mutator/node/super_spec.rb +0 -46
- data/spec/unit/mutant/mutator/node/yield_spec.rb +0 -17
data/meta/casgn.rb
ADDED
data/meta/cbase.rb
ADDED
data/meta/const.rb
ADDED
data/meta/cvar.rb
ADDED
data/meta/cvasgn.rb
ADDED
data/meta/define.rb
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Mutant::Meta::Example.add do
|
4
|
+
source 'def foo; end'
|
5
|
+
|
6
|
+
mutation 'def foo; raise; end'
|
7
|
+
end
|
8
|
+
|
9
|
+
Mutant::Meta::Example.add do
|
10
|
+
source "def foo\nfoo\nrescue\nend"
|
11
|
+
|
12
|
+
mutation 'def foo; raise; end'
|
13
|
+
mutation 'def foo; nil; rescue; end'
|
14
|
+
mutation 'def foo; end'
|
15
|
+
end
|
16
|
+
|
17
|
+
Mutant::Meta::Example.add do
|
18
|
+
source 'def foo; true; false; end'
|
19
|
+
|
20
|
+
# Mutation of each statement in block
|
21
|
+
mutation 'def foo; true; true; end'
|
22
|
+
mutation 'def foo; false; false; end'
|
23
|
+
mutation 'def foo; true; nil; end'
|
24
|
+
mutation 'def foo; nil; false; end'
|
25
|
+
|
26
|
+
# Remove statement in block
|
27
|
+
mutation 'def foo; true; end'
|
28
|
+
mutation 'def foo; false; end'
|
29
|
+
|
30
|
+
# Remove all statements
|
31
|
+
mutation 'def foo; end'
|
32
|
+
|
33
|
+
mutation 'def foo; raise; end'
|
34
|
+
end
|
35
|
+
|
36
|
+
Mutant::Meta::Example.add do
|
37
|
+
source 'def foo(a, b); end'
|
38
|
+
|
39
|
+
# Deletion of each argument
|
40
|
+
mutation 'def foo(a); end'
|
41
|
+
mutation 'def foo(b); end'
|
42
|
+
|
43
|
+
# Deletion of all arguments
|
44
|
+
mutation 'def foo; end'
|
45
|
+
|
46
|
+
# Rename each argument
|
47
|
+
mutation 'def foo(a__mutant__, b); end'
|
48
|
+
mutation 'def foo(a, b__mutant__); end'
|
49
|
+
|
50
|
+
# Mutation of body
|
51
|
+
mutation 'def foo(a, b); raise; end'
|
52
|
+
end
|
53
|
+
|
54
|
+
Mutant::Meta::Example.add do
|
55
|
+
source 'def foo(_unused); end'
|
56
|
+
|
57
|
+
mutation 'def foo(_unused); raise; end'
|
58
|
+
mutation 'def foo; end'
|
59
|
+
end
|
60
|
+
|
61
|
+
Mutant::Meta::Example.add do
|
62
|
+
source 'def foo(_unused = true); end'
|
63
|
+
|
64
|
+
mutation 'def foo(_unused = nil); end'
|
65
|
+
mutation 'def foo(_unused = false); end'
|
66
|
+
mutation 'def foo(_unused = true); raise; end'
|
67
|
+
mutation 'def foo(_unused); end'
|
68
|
+
mutation 'def foo; end'
|
69
|
+
end
|
70
|
+
|
71
|
+
Mutant::Meta::Example.add do
|
72
|
+
source 'def foo(a = true); end'
|
73
|
+
|
74
|
+
mutation 'def foo(a); end'
|
75
|
+
mutation 'def foo(); end'
|
76
|
+
mutation 'def foo(a = false); end'
|
77
|
+
mutation 'def foo(a = nil); end'
|
78
|
+
mutation 'def foo(a__mutant__ = true); end'
|
79
|
+
mutation 'def foo(a = true); raise; end'
|
80
|
+
end
|
81
|
+
|
82
|
+
Mutant::Meta::Example.add do
|
83
|
+
source 'def self.foo; true; false; end'
|
84
|
+
|
85
|
+
# Body presence mutation
|
86
|
+
mutation 'def self.foo; false; false; end'
|
87
|
+
mutation 'def self.foo; true; true; end'
|
88
|
+
mutation 'def self.foo; true; nil; end'
|
89
|
+
mutation 'def self.foo; nil; false; end'
|
90
|
+
|
91
|
+
# Body presence mutation
|
92
|
+
mutation 'def self.foo; true; end'
|
93
|
+
mutation 'def self.foo; false; end'
|
94
|
+
|
95
|
+
# Remove all statements
|
96
|
+
mutation 'def self.foo; end'
|
97
|
+
|
98
|
+
mutation 'def self.foo; raise; end'
|
99
|
+
end
|
100
|
+
|
101
|
+
Mutant::Meta::Example.add do
|
102
|
+
|
103
|
+
source 'def self.foo(a, b); end'
|
104
|
+
|
105
|
+
# Deletion of each argument
|
106
|
+
mutation 'def self.foo(a); end'
|
107
|
+
mutation 'def self.foo(b); end'
|
108
|
+
|
109
|
+
# Deletion of all arguments
|
110
|
+
mutation 'def self.foo; end'
|
111
|
+
|
112
|
+
# Rename each argument
|
113
|
+
mutation 'def self.foo(a__mutant__, b); end'
|
114
|
+
mutation 'def self.foo(a, b__mutant__); end'
|
115
|
+
|
116
|
+
# Mutation of body
|
117
|
+
mutation 'def self.foo(a, b); raise; end'
|
118
|
+
end
|
data/meta/defined.rb
ADDED
data/meta/dstr.rb
ADDED
data/meta/dsym.rb
ADDED
data/meta/ensure.rb
ADDED
data/meta/fixnum.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Mutant::Meta::Example.add do
|
4
|
+
source '10'
|
5
|
+
|
6
|
+
# generic
|
7
|
+
mutation 'nil'
|
8
|
+
|
9
|
+
# edge cases
|
10
|
+
mutation '0'
|
11
|
+
mutation '1'
|
12
|
+
|
13
|
+
# negative
|
14
|
+
mutation '-10'
|
15
|
+
|
16
|
+
# scalar boundary
|
17
|
+
mutation '9'
|
18
|
+
mutation '11'
|
19
|
+
end
|
data/meta/float.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Mutant::Meta::Example.add do
|
4
|
+
source '10.0'
|
5
|
+
|
6
|
+
# generic
|
7
|
+
mutation 'nil'
|
8
|
+
|
9
|
+
# edge cases
|
10
|
+
mutation '0.0'
|
11
|
+
mutation '1.0'
|
12
|
+
mutation '(0.0 / 0.0)'
|
13
|
+
mutation '(1.0 / 0.0)'
|
14
|
+
mutation '(-1.0 / 0.0)'
|
15
|
+
|
16
|
+
# negative
|
17
|
+
mutation '-10.0'
|
18
|
+
end
|
19
|
+
|
20
|
+
Mutant::Meta::Example.add do
|
21
|
+
source '0.0'
|
22
|
+
|
23
|
+
mutation 'nil'
|
24
|
+
mutation '1.0'
|
25
|
+
mutation '(0.0 / 0.0)'
|
26
|
+
mutation '(1.0 / 0.0)'
|
27
|
+
mutation '(-1.0 / 0.0)'
|
28
|
+
end
|
29
|
+
|
30
|
+
Mutant::Meta::Example.add do
|
31
|
+
source '-0.0'
|
32
|
+
|
33
|
+
mutation 'nil'
|
34
|
+
mutation '1.0'
|
35
|
+
mutation '(0.0 / 0.0)'
|
36
|
+
mutation '(1.0 / 0.0)'
|
37
|
+
mutation '(-1.0 / 0.0)'
|
38
|
+
end
|
data/meta/gvar.rb
ADDED
data/meta/gvasgn.rb
ADDED
data/meta/hash.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Mutant::Meta::Example.add do
|
4
|
+
source '{true => true, false => false}'
|
5
|
+
|
6
|
+
# Literal replaced with nil
|
7
|
+
mutation 'nil'
|
8
|
+
|
9
|
+
# Mutation of each key and value in hash
|
10
|
+
mutation '{ false => true , false => false }'
|
11
|
+
mutation '{ nil => true , false => false }'
|
12
|
+
mutation '{ true => false , false => false }'
|
13
|
+
mutation '{ true => nil , false => false }'
|
14
|
+
mutation '{ true => true , true => false }'
|
15
|
+
mutation '{ true => true , nil => false }'
|
16
|
+
mutation '{ true => true , false => true }'
|
17
|
+
mutation '{ true => true , false => nil }'
|
18
|
+
|
19
|
+
# Remove each key once
|
20
|
+
mutation '{ true => true }'
|
21
|
+
mutation '{ false => false }'
|
22
|
+
|
23
|
+
# Empty hash
|
24
|
+
mutation '{}'
|
25
|
+
end
|
data/meta/if.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Mutant::Meta::Example.add do
|
4
|
+
source 'if :condition; true; else false; end'
|
5
|
+
|
6
|
+
# mutation of condition
|
7
|
+
mutation 'if :condition__mutant__; true; else false; end'
|
8
|
+
mutation 'if !:condition; true; else false; end'
|
9
|
+
mutation 'if nil; true; else false; end'
|
10
|
+
mutation 'if true; true; else false; end'
|
11
|
+
mutation 'if false; true; else false; end'
|
12
|
+
|
13
|
+
# Deleted else branch
|
14
|
+
mutation 'if :condition; true end'
|
15
|
+
|
16
|
+
# Deleted if branch resuting in unless rendering
|
17
|
+
mutation 'unless :condition; false; end'
|
18
|
+
|
19
|
+
# Deleted if branch with promoting else branch to if branch
|
20
|
+
mutation 'if :condition; false end'
|
21
|
+
|
22
|
+
# mutation of if body
|
23
|
+
mutation 'if :condition; false; else false; end'
|
24
|
+
mutation 'if :condition; nil; else false; end'
|
25
|
+
|
26
|
+
# mutation of else body
|
27
|
+
mutation 'if :condition; true; else true; end'
|
28
|
+
mutation 'if :condition; true; else nil; end'
|
29
|
+
|
30
|
+
mutation 'nil'
|
31
|
+
end
|
32
|
+
|
33
|
+
Mutant::Meta::Example.add do
|
34
|
+
source 'if condition; true; end'
|
35
|
+
|
36
|
+
mutation 'if !condition; true; end'
|
37
|
+
mutation 'if condition; false; end'
|
38
|
+
mutation 'if condition; nil; end'
|
39
|
+
mutation 'if true; true; end'
|
40
|
+
mutation 'if false; true; end'
|
41
|
+
mutation 'if nil; true; end'
|
42
|
+
mutation 'nil'
|
43
|
+
end
|
44
|
+
|
45
|
+
Mutant::Meta::Example.add do
|
46
|
+
source 'unless :condition; true; end'
|
47
|
+
|
48
|
+
mutation 'unless !:condition; true; end'
|
49
|
+
mutation 'unless :condition__mutant__; true; end'
|
50
|
+
mutation 'unless nil; true; end'
|
51
|
+
mutation 'unless :condition; false; end'
|
52
|
+
mutation 'unless :condition; nil; end'
|
53
|
+
mutation 'unless true; true; end'
|
54
|
+
mutation 'unless false; true; end'
|
55
|
+
mutation 'if :condition; true; end'
|
56
|
+
mutation 'nil'
|
57
|
+
end
|
data/meta/ivasgn.rb
ADDED
data/meta/kwbegin.rb
ADDED
data/meta/lvar.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Mutant::Meta::Example.add do
|
4
|
+
source 'a = nil; a'
|
5
|
+
|
6
|
+
mutation 'a = nil; nil'
|
7
|
+
mutation 'a = nil'
|
8
|
+
# TODO: fix invalid AST
|
9
|
+
# These ASTs are not valid and should NOT be emitted
|
10
|
+
# Mutations of lvarasgn need to be special cased to avoid this.
|
11
|
+
mutation s(:begin, s(:lvasgn, :a__mutant__, s(:nil)), s(:lvar, :a))
|
12
|
+
mutation s(:begin, s(:nil), s(:lvar, :a))
|
13
|
+
mutation s(:lvar, :a)
|
14
|
+
end
|
data/meta/lvasgn.rb
ADDED