mutant 0.5.17 → 0.5.18
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.
- 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
@@ -1,15 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::Mutator::Node::Noop, 'cbase' do
|
6
|
-
let(:source) { '::A' }
|
7
|
-
|
8
|
-
let(:mutations) do
|
9
|
-
mutants = []
|
10
|
-
mutants << 'nil'
|
11
|
-
mutants << 'A'
|
12
|
-
end
|
13
|
-
|
14
|
-
it_should_behave_like 'a mutator'
|
15
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::Mutator::Node::ConditionalLoop do
|
6
|
-
|
7
|
-
context 'with empty body' do
|
8
|
-
let(:source) { 'while true; end' }
|
9
|
-
|
10
|
-
let(:mutations) do
|
11
|
-
mutations = []
|
12
|
-
mutations << 'while true; raise; end'
|
13
|
-
mutations << 'while false; end'
|
14
|
-
mutations << 'while nil; end'
|
15
|
-
mutations << 'nil'
|
16
|
-
end
|
17
|
-
|
18
|
-
it_should_behave_like 'a mutator'
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'with while statement' do
|
22
|
-
let(:source) { 'while true; foo; bar; end' }
|
23
|
-
|
24
|
-
let(:mutations) do
|
25
|
-
mutations = []
|
26
|
-
mutations << 'while true; bar; end'
|
27
|
-
mutations << 'while true; foo; end'
|
28
|
-
mutations << 'while true; end'
|
29
|
-
mutations << 'while false; foo; bar; end'
|
30
|
-
mutations << 'while nil; foo; bar; end'
|
31
|
-
mutations << 'while true; foo; nil; end'
|
32
|
-
mutations << 'while true; nil; bar; end'
|
33
|
-
mutations << 'while true; raise; end'
|
34
|
-
mutations << 'nil'
|
35
|
-
end
|
36
|
-
|
37
|
-
it_should_behave_like 'a mutator'
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'with until statement' do
|
41
|
-
let(:source) { 'until true; foo; bar; end' }
|
42
|
-
|
43
|
-
let(:mutations) do
|
44
|
-
mutations = []
|
45
|
-
mutations << 'until true; bar; end'
|
46
|
-
mutations << 'until true; foo; end'
|
47
|
-
mutations << 'until true; end'
|
48
|
-
mutations << 'until false; foo; bar; end'
|
49
|
-
mutations << 'until nil; foo; bar; end'
|
50
|
-
mutations << 'until true; foo; nil; end'
|
51
|
-
mutations << 'until true; nil; bar; end'
|
52
|
-
mutations << 'until true; raise; end'
|
53
|
-
mutations << 'nil'
|
54
|
-
end
|
55
|
-
|
56
|
-
it_should_behave_like 'a mutator'
|
57
|
-
end
|
58
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::Mutator::Node::Const, 'const' do
|
6
|
-
let(:source) { 'A::B::C' }
|
7
|
-
|
8
|
-
let(:mutations) do
|
9
|
-
mutants = []
|
10
|
-
mutants << 'nil'
|
11
|
-
mutants << 'B::C'
|
12
|
-
mutants << 'C'
|
13
|
-
end
|
14
|
-
|
15
|
-
it_should_behave_like 'a mutator'
|
16
|
-
end
|
@@ -1,171 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::Mutator, 'def' do
|
6
|
-
context 'empty' do
|
7
|
-
let(:source) { 'def foo; end' }
|
8
|
-
|
9
|
-
let(:mutations) do
|
10
|
-
mutations = []
|
11
|
-
mutations << 'def foo; raise; end'
|
12
|
-
end
|
13
|
-
|
14
|
-
it_should_behave_like 'a mutator'
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'empty rescue body' do
|
18
|
-
let(:source) { "def foo\nfoo\nrescue\nend" }
|
19
|
-
|
20
|
-
let(:mutations) do
|
21
|
-
mutations = []
|
22
|
-
mutations << 'def foo; raise; end'
|
23
|
-
mutations << 'def foo; nil; rescue; end'
|
24
|
-
mutations << 'def foo; end'
|
25
|
-
end
|
26
|
-
|
27
|
-
it_should_behave_like 'a mutator'
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'with no arguments' do
|
31
|
-
let(:source) { 'def foo; true; false; end' }
|
32
|
-
|
33
|
-
let(:mutations) do
|
34
|
-
mutations = []
|
35
|
-
|
36
|
-
# Mutation of each statement in block
|
37
|
-
mutations << 'def foo; true; true; end'
|
38
|
-
mutations << 'def foo; false; false; end'
|
39
|
-
mutations << 'def foo; true; nil; end'
|
40
|
-
mutations << 'def foo; nil; false; end'
|
41
|
-
|
42
|
-
# Remove statement in block
|
43
|
-
mutations << 'def foo; true; end'
|
44
|
-
mutations << 'def foo; false; end'
|
45
|
-
|
46
|
-
# Remove all statements
|
47
|
-
mutations << 'def foo; end'
|
48
|
-
|
49
|
-
mutations << 'def foo; raise; end'
|
50
|
-
end
|
51
|
-
|
52
|
-
it_should_behave_like 'a mutator'
|
53
|
-
end
|
54
|
-
|
55
|
-
context 'with arguments' do
|
56
|
-
let(:source) { 'def foo(a, b); end' }
|
57
|
-
|
58
|
-
let(:mutations) do
|
59
|
-
mutations = []
|
60
|
-
|
61
|
-
# Deletion of each argument
|
62
|
-
mutations << 'def foo(a); end'
|
63
|
-
mutations << 'def foo(b); end'
|
64
|
-
|
65
|
-
# Deletion of all arguments
|
66
|
-
mutations << 'def foo; end'
|
67
|
-
|
68
|
-
# Rename each argument
|
69
|
-
mutations << 'def foo(a__mutant__, b); end'
|
70
|
-
mutations << 'def foo(a, b__mutant__); end'
|
71
|
-
|
72
|
-
# Mutation of body
|
73
|
-
mutations << 'def foo(a, b); raise; end'
|
74
|
-
end
|
75
|
-
|
76
|
-
it_should_behave_like 'a mutator'
|
77
|
-
end
|
78
|
-
|
79
|
-
context 'with argument beginning in an underscore' do
|
80
|
-
let(:source) { 'def foo(_unused); end' }
|
81
|
-
|
82
|
-
let(:mutations) do
|
83
|
-
mutations = []
|
84
|
-
mutations << 'def foo(_unused); raise; end'
|
85
|
-
mutations << 'def foo; end'
|
86
|
-
end
|
87
|
-
|
88
|
-
it_should_behave_like 'a mutator'
|
89
|
-
end
|
90
|
-
|
91
|
-
context 'with optional argument beginning in an underscore' do
|
92
|
-
let(:source) { 'def foo(_unused = true); end' }
|
93
|
-
|
94
|
-
let(:mutations) do
|
95
|
-
mutations = []
|
96
|
-
mutations << 'def foo(_unused = nil); end'
|
97
|
-
mutations << 'def foo(_unused = false); end'
|
98
|
-
mutations << 'def foo(_unused = true); raise; end'
|
99
|
-
mutations << 'def foo(_unused); end'
|
100
|
-
mutations << 'def foo; end'
|
101
|
-
end
|
102
|
-
|
103
|
-
it_should_behave_like 'a mutator'
|
104
|
-
end
|
105
|
-
|
106
|
-
context 'default argument' do
|
107
|
-
let(:source) { 'def foo(a = true); end' }
|
108
|
-
|
109
|
-
let(:mutations) do
|
110
|
-
mutations = []
|
111
|
-
mutations << 'def foo(a); end'
|
112
|
-
mutations << 'def foo(); end'
|
113
|
-
mutations << 'def foo(a = false); end'
|
114
|
-
mutations << 'def foo(a = nil); end'
|
115
|
-
mutations << 'def foo(a__mutant__ = true); end'
|
116
|
-
mutations << 'def foo(a = true); raise; end'
|
117
|
-
end
|
118
|
-
|
119
|
-
it_should_behave_like 'a mutator'
|
120
|
-
end
|
121
|
-
|
122
|
-
context 'define on singleton' do
|
123
|
-
let(:source) { 'def self.foo; true; false; end' }
|
124
|
-
|
125
|
-
let(:mutations) do
|
126
|
-
mutations = []
|
127
|
-
|
128
|
-
# Body presence mutations
|
129
|
-
mutations << 'def self.foo; false; false; end'
|
130
|
-
mutations << 'def self.foo; true; true; end'
|
131
|
-
mutations << 'def self.foo; true; nil; end'
|
132
|
-
mutations << 'def self.foo; nil; false; end'
|
133
|
-
|
134
|
-
# Body presence mutations
|
135
|
-
mutations << 'def self.foo; true; end'
|
136
|
-
mutations << 'def self.foo; false; end'
|
137
|
-
|
138
|
-
# Remove all statements
|
139
|
-
mutations << 'def self.foo; end'
|
140
|
-
|
141
|
-
mutations << 'def self.foo; raise; end'
|
142
|
-
end
|
143
|
-
|
144
|
-
it_should_behave_like 'a mutator'
|
145
|
-
end
|
146
|
-
|
147
|
-
context 'define on singleton with argument' do
|
148
|
-
|
149
|
-
let(:source) { 'def self.foo(a, b); end' }
|
150
|
-
|
151
|
-
let(:mutations) do
|
152
|
-
mutations = []
|
153
|
-
|
154
|
-
# Deletion of each argument
|
155
|
-
mutations << 'def self.foo(a); end'
|
156
|
-
mutations << 'def self.foo(b); end'
|
157
|
-
|
158
|
-
# Deletion of all arguments
|
159
|
-
mutations << 'def self.foo; end'
|
160
|
-
|
161
|
-
# Rename each argument
|
162
|
-
mutations << 'def self.foo(a__mutant__, b); end'
|
163
|
-
mutations << 'def self.foo(a, b__mutant__); end'
|
164
|
-
|
165
|
-
# Mutation of body
|
166
|
-
mutations << 'def self.foo(a, b); raise; end'
|
167
|
-
end
|
168
|
-
|
169
|
-
it_should_behave_like 'a mutator'
|
170
|
-
end
|
171
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::Mutator::Node::Generic, 'defined?' do
|
6
|
-
let(:source) { 'defined?(foo)' }
|
7
|
-
|
8
|
-
let(:mutations) do
|
9
|
-
mutations = []
|
10
|
-
mutations << 'defined?(nil)'
|
11
|
-
end
|
12
|
-
|
13
|
-
it_should_behave_like 'a mutator'
|
14
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::Mutator::Node::Dstr, 'dstr' do
|
6
|
-
let(:source) { '"foo#{bar}baz"' }
|
7
|
-
|
8
|
-
let(:mutations) do
|
9
|
-
mutations = []
|
10
|
-
mutations << '"#{nil}#{bar}baz"'
|
11
|
-
mutations << '"foo#{bar}#{nil}"'
|
12
|
-
mutations << '"foo#{nil}baz"'
|
13
|
-
mutations << 'nil'
|
14
|
-
end
|
15
|
-
|
16
|
-
it_should_behave_like 'a mutator'
|
17
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::Mutator::Node::Dsym, 'dsym' do
|
6
|
-
|
7
|
-
let(:source) { ':"foo#{bar}baz"' }
|
8
|
-
|
9
|
-
let(:mutations) do
|
10
|
-
mutations = []
|
11
|
-
mutations << ':"#{nil}#{bar}baz"'
|
12
|
-
mutations << ':"foo#{bar}#{nil}"'
|
13
|
-
mutations << ':"foo#{nil}baz"'
|
14
|
-
mutations << 'nil'
|
15
|
-
end
|
16
|
-
|
17
|
-
it_should_behave_like 'a mutator'
|
18
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::Mutator::Node::Generic, 'ensure' do
|
6
|
-
let(:source) { 'begin; rescue; ensure; true; end' }
|
7
|
-
|
8
|
-
let(:mutations) do
|
9
|
-
mutations = []
|
10
|
-
mutations << 'begin; rescue; ensure; false; end'
|
11
|
-
mutations << 'begin; rescue; ensure; nil; end'
|
12
|
-
mutations << 'nil'
|
13
|
-
end
|
14
|
-
|
15
|
-
it_should_behave_like 'a mutator'
|
16
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::Mutator, 'if' do
|
6
|
-
context 'with if and else branches' do
|
7
|
-
let(:source) { 'if :condition; true; else false; end' }
|
8
|
-
|
9
|
-
let(:mutations) do
|
10
|
-
mutants = []
|
11
|
-
|
12
|
-
# mutations of condition
|
13
|
-
mutants << 'if :condition__mutant__; true; else false; end'
|
14
|
-
mutants << 'if !:condition; true; else false; end'
|
15
|
-
mutants << 'if nil; true; else false; end'
|
16
|
-
mutants << 'if true; true; else false; end'
|
17
|
-
mutants << 'if false; true; else false; end'
|
18
|
-
|
19
|
-
# Deleted else branch
|
20
|
-
mutants << 'if :condition; true end'
|
21
|
-
|
22
|
-
# Deleted if branch resuting in unless rendering
|
23
|
-
mutants << 'unless :condition; false; end'
|
24
|
-
|
25
|
-
# Deleted if branch with promoting else branch to if branch
|
26
|
-
mutants << 'if :condition; false end'
|
27
|
-
|
28
|
-
# mutations of if body
|
29
|
-
mutants << 'if :condition; false; else false; end'
|
30
|
-
mutants << 'if :condition; nil; else false; end'
|
31
|
-
|
32
|
-
# mutations of else body
|
33
|
-
mutants << 'if :condition; true; else true; end'
|
34
|
-
mutants << 'if :condition; true; else nil; end'
|
35
|
-
|
36
|
-
mutants << 'nil'
|
37
|
-
end
|
38
|
-
|
39
|
-
it_should_behave_like 'a mutator'
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'if with one branch' do
|
43
|
-
let(:source) { 'if condition; true; end' }
|
44
|
-
|
45
|
-
let(:mutations) do
|
46
|
-
mutants = []
|
47
|
-
mutants << 'if !condition; true; end'
|
48
|
-
mutants << 'if condition; false; end'
|
49
|
-
mutants << 'if condition; nil; end'
|
50
|
-
mutants << 'if true; true; end'
|
51
|
-
mutants << 'if false; true; end'
|
52
|
-
mutants << 'if nil; true; end'
|
53
|
-
mutants << 'nil'
|
54
|
-
end
|
55
|
-
|
56
|
-
it_should_behave_like 'a mutator'
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'unless with one branch' do
|
60
|
-
let(:source) { 'unless :condition; true; end' }
|
61
|
-
|
62
|
-
let(:mutations) do
|
63
|
-
mutants = []
|
64
|
-
mutants << 'unless !:condition; true; end'
|
65
|
-
mutants << 'unless :condition__mutant__; true; end'
|
66
|
-
mutants << 'unless nil; true; end'
|
67
|
-
mutants << 'unless :condition; false; end'
|
68
|
-
mutants << 'unless :condition; nil; end'
|
69
|
-
mutants << 'unless true; true; end'
|
70
|
-
mutants << 'unless false; true; end'
|
71
|
-
mutants << 'if :condition; true; end'
|
72
|
-
mutants << 'nil'
|
73
|
-
end
|
74
|
-
|
75
|
-
it_should_behave_like 'a mutator'
|
76
|
-
end
|
77
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::Mutator::Node::Kwbegin, 'kwbegin' do
|
6
|
-
let(:source) { 'begin; true; end' }
|
7
|
-
|
8
|
-
let(:mutations) do
|
9
|
-
mutations = []
|
10
|
-
mutations << 'begin; false; end'
|
11
|
-
mutations << 'begin; nil; end'
|
12
|
-
mutations << 'nil'
|
13
|
-
end
|
14
|
-
|
15
|
-
it_should_behave_like 'a mutator'
|
16
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::Mutator::Node::Literal, 'array' do
|
6
|
-
|
7
|
-
context 'on one item' do
|
8
|
-
let(:source) { '[true]' }
|
9
|
-
|
10
|
-
let(:mutations) do
|
11
|
-
mutations = []
|
12
|
-
mutations << 'nil'
|
13
|
-
mutations << 'true'
|
14
|
-
mutations << '[false]'
|
15
|
-
mutations << '[nil]'
|
16
|
-
mutations << '[]'
|
17
|
-
end
|
18
|
-
|
19
|
-
it_should_behave_like 'a mutator'
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'on arrays with more than one item' do
|
23
|
-
let(:source) { '[true, false]' }
|
24
|
-
|
25
|
-
let(:mutations) do
|
26
|
-
mutations = []
|
27
|
-
|
28
|
-
# Literal replaced with nil
|
29
|
-
mutations << 'nil'
|
30
|
-
|
31
|
-
# Mutation of each element in array
|
32
|
-
mutations << '[nil, false]'
|
33
|
-
mutations << '[false, false]'
|
34
|
-
mutations << '[true, nil]'
|
35
|
-
mutations << '[true, true]'
|
36
|
-
|
37
|
-
# Remove each element of array once
|
38
|
-
mutations << '[true]'
|
39
|
-
mutations << '[false]'
|
40
|
-
|
41
|
-
# Empty array
|
42
|
-
mutations << '[]'
|
43
|
-
end
|
44
|
-
|
45
|
-
it_should_behave_like 'a mutator'
|
46
|
-
end
|
47
|
-
end
|