mutant 0.5.18 → 0.5.19
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 +7 -0
- data/README.md +2 -2
- data/config/flay.yml +1 -1
- data/lib/mutant.rb +4 -1
- data/lib/mutant/meta/example/dsl.rb +11 -0
- data/lib/mutant/mutator/node.rb +29 -5
- data/lib/mutant/mutator/node/and_asgn.rb +34 -0
- data/lib/mutant/mutator/node/binary.rb +1 -1
- data/lib/mutant/mutator/node/block.rb +1 -1
- data/lib/mutant/mutator/node/break.rb +29 -0
- data/lib/mutant/mutator/node/case.rb +1 -1
- data/lib/mutant/mutator/node/conditional_loop.rb +1 -1
- data/lib/mutant/mutator/node/const.rb +1 -1
- data/lib/mutant/mutator/node/defined.rb +30 -0
- data/lib/mutant/mutator/node/dstr.rb +1 -1
- data/lib/mutant/mutator/node/dsym.rb +1 -1
- data/lib/mutant/mutator/node/generic.rb +1 -1
- data/lib/mutant/mutator/node/if.rb +4 -2
- data/lib/mutant/mutator/node/kwbegin.rb +1 -1
- data/lib/mutant/mutator/node/literal/array.rb +1 -1
- data/lib/mutant/mutator/node/literal/fixnum.rb +1 -1
- data/lib/mutant/mutator/node/literal/float.rb +1 -1
- data/lib/mutant/mutator/node/literal/hash.rb +1 -1
- data/lib/mutant/mutator/node/literal/range.rb +1 -1
- data/lib/mutant/mutator/node/literal/regex.rb +1 -1
- data/lib/mutant/mutator/node/literal/string.rb +1 -1
- data/lib/mutant/mutator/node/literal/symbol.rb +1 -1
- data/lib/mutant/mutator/node/masgn.rb +1 -1
- data/lib/mutant/mutator/node/match_current_line.rb +1 -1
- data/lib/mutant/mutator/node/named_value/access.rb +1 -1
- data/lib/mutant/mutator/node/named_value/variable_assignment.rb +1 -1
- data/lib/mutant/mutator/node/{loop_control.rb → next.rb} +5 -9
- data/lib/mutant/mutator/node/op_asgn.rb +9 -4
- data/lib/mutant/mutator/node/or_asgn.rb +6 -2
- data/lib/mutant/mutator/node/resbody.rb +2 -2
- data/lib/mutant/mutator/node/return.rb +1 -1
- data/lib/mutant/mutator/node/send.rb +1 -1
- data/lib/mutant/mutator/node/splat.rb +1 -1
- data/lib/mutant/mutator/node/super.rb +1 -1
- data/lib/mutant/mutator/node/yield.rb +1 -1
- data/lib/mutant/mutator/node/zsuper.rb +1 -1
- data/lib/mutant/node_helpers.rb +6 -5
- data/lib/mutant/version.rb +1 -1
- data/meta/and.rb +1 -1
- data/meta/and_asgn.rb +3 -1
- data/meta/array.rb +2 -2
- data/meta/block.rb +6 -4
- data/meta/block_pass.rb +1 -1
- data/meta/blockarg.rb +1 -1
- data/meta/break.rb +1 -2
- data/meta/case.rb +104 -183
- data/meta/cbase.rb +1 -1
- data/meta/const.rb +1 -1
- data/meta/cvar.rb +1 -1
- data/meta/cvasgn.rb +1 -1
- data/meta/{define.rb → def.rb} +2 -1
- data/meta/dstr.rb +4 -1
- data/meta/dsym.rb +4 -2
- data/meta/ensure.rb +1 -1
- data/meta/false.rb +8 -0
- data/meta/float.rb +3 -4
- data/meta/gvar.rb +1 -1
- data/meta/gvasgn.rb +1 -1
- data/meta/hash.rb +1 -2
- data/meta/if.rb +25 -27
- data/meta/{fixnum.rb → int.rb} +1 -2
- data/meta/ivasgn.rb +1 -1
- data/meta/kwbegin.rb +1 -1
- data/meta/lvar.rb +2 -0
- data/meta/lvasgn.rb +1 -1
- data/meta/masgn.rb +1 -1
- data/meta/match_current_line.rb +1 -1
- data/meta/next.rb +1 -1
- data/meta/op_assgn.rb +3 -1
- data/meta/{binary.rb → or.rb} +1 -1
- data/meta/or_asgn.rb +4 -2
- data/meta/range.rb +6 -2
- data/meta/regex.rb +4 -2
- data/meta/rescue.rb +7 -6
- data/meta/restarg.rb +3 -1
- data/meta/return.rb +3 -2
- data/meta/send.rb +48 -51
- data/meta/{string.rb → str.rb} +1 -1
- data/meta/super.rb +6 -3
- data/meta/symbol.rb +1 -1
- data/meta/true.rb +8 -0
- data/meta/until.rb +17 -0
- data/meta/while.rb +4 -2
- data/meta/yield.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +13 -8
- data/meta/unless.rb +0 -15
@@ -5,14 +5,9 @@ module Mutant
|
|
5
5
|
class Node
|
6
6
|
|
7
7
|
# Mutator for loop control keywords
|
8
|
-
class
|
8
|
+
class Next < Generic
|
9
9
|
|
10
|
-
|
11
|
-
next: :break,
|
12
|
-
break: :next
|
13
|
-
)
|
14
|
-
|
15
|
-
handle(*INVERSE.keys)
|
10
|
+
handle(:next)
|
16
11
|
|
17
12
|
private
|
18
13
|
|
@@ -24,12 +19,13 @@ module Mutant
|
|
24
19
|
#
|
25
20
|
def dispatch
|
26
21
|
super
|
22
|
+
emit_singletons
|
27
23
|
children.each_index(&method(:delete_child))
|
28
|
-
emit(s(
|
29
|
-
emit_nil
|
24
|
+
emit(s(:break, *children))
|
30
25
|
end
|
31
26
|
|
32
27
|
end # Next
|
33
28
|
end # Node
|
34
29
|
end # Mutator
|
35
30
|
end # Mutant
|
31
|
+
|
@@ -5,9 +5,11 @@ module Mutant
|
|
5
5
|
class Node
|
6
6
|
|
7
7
|
# OpAsgn mutator
|
8
|
-
class OpAsgn <
|
8
|
+
class OpAsgn < self
|
9
9
|
|
10
|
-
handle(:op_asgn
|
10
|
+
handle(:op_asgn)
|
11
|
+
|
12
|
+
children :left, :operation, :right
|
11
13
|
|
12
14
|
private
|
13
15
|
|
@@ -18,8 +20,11 @@ module Mutant
|
|
18
20
|
# @api private
|
19
21
|
#
|
20
22
|
def dispatch
|
21
|
-
|
22
|
-
|
23
|
+
emit_singletons
|
24
|
+
emit_left_mutations do |mutation|
|
25
|
+
!mutation.type.equal?(:self)
|
26
|
+
end
|
27
|
+
emit_right_mutations
|
23
28
|
end
|
24
29
|
|
25
30
|
end # OpAsgn
|
@@ -20,8 +20,12 @@ module Mutant
|
|
20
20
|
# @api private
|
21
21
|
#
|
22
22
|
def dispatch
|
23
|
-
|
24
|
-
|
23
|
+
emit_singletons
|
24
|
+
unless left.type.equal?(:ivasgn)
|
25
|
+
emit_left_mutations do |mutation|
|
26
|
+
!mutation.type.equal?(:self)
|
27
|
+
end
|
28
|
+
end
|
25
29
|
emit_right_mutations
|
26
30
|
end
|
27
31
|
|
@@ -32,8 +32,8 @@ module Mutant
|
|
32
32
|
#
|
33
33
|
def mutate_captures
|
34
34
|
return unless captures
|
35
|
-
Util::Array.each(captures.children, self) do |matchers|
|
36
|
-
next if matchers.
|
35
|
+
Util::Array::Element.each(captures.children, self) do |matchers|
|
36
|
+
next if matchers.any? { |node| node.type.equal?(:nil) }
|
37
37
|
emit_captures(s(:array, *matchers))
|
38
38
|
end
|
39
39
|
end
|
data/lib/mutant/node_helpers.rb
CHANGED
@@ -24,12 +24,13 @@ module Mutant
|
|
24
24
|
NEGATIVE_INFINITY =
|
25
25
|
s(:send, s(:float, -1.0), :/, s(:float, 0.0))
|
26
26
|
|
27
|
-
RAISE
|
27
|
+
RAISE = s(:send, nil, :raise)
|
28
28
|
|
29
|
-
N_TRUE
|
30
|
-
N_FALSE
|
31
|
-
N_NIL
|
32
|
-
N_EMPTY
|
29
|
+
N_TRUE = s(:true)
|
30
|
+
N_FALSE = s(:false)
|
31
|
+
N_NIL = s(:nil)
|
32
|
+
N_EMPTY = s(:empty)
|
33
|
+
N_SELF = s(:self)
|
33
34
|
|
34
35
|
# Build a negated boolean node
|
35
36
|
#
|
data/lib/mutant/version.rb
CHANGED
data/meta/and.rb
CHANGED
data/meta/and_asgn.rb
CHANGED
data/meta/array.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Mutant::Meta::Example.add do
|
4
4
|
source '[true]'
|
5
5
|
|
6
|
-
|
6
|
+
singleton_mutations
|
7
7
|
mutation 'true'
|
8
8
|
mutation '[false]'
|
9
9
|
mutation '[nil]'
|
@@ -13,7 +13,7 @@ end
|
|
13
13
|
Mutant::Meta::Example.add do
|
14
14
|
source '[true, false]'
|
15
15
|
|
16
|
-
|
16
|
+
singleton_mutations
|
17
17
|
|
18
18
|
# Mutation of each element in array
|
19
19
|
mutation '[nil, false]'
|
data/meta/block.rb
CHANGED
@@ -3,19 +3,22 @@
|
|
3
3
|
Mutant::Meta::Example.add do
|
4
4
|
source 'foo() { a; b }'
|
5
5
|
|
6
|
+
singleton_mutations
|
6
7
|
mutation 'foo { a }'
|
7
8
|
mutation 'foo { b }'
|
8
9
|
mutation 'foo {}'
|
9
10
|
mutation 'foo { raise }'
|
10
11
|
mutation 'foo { a; nil }'
|
12
|
+
mutation 'foo { a; self }'
|
11
13
|
mutation 'foo { nil; b }'
|
14
|
+
mutation 'foo { self; b }'
|
12
15
|
mutation 'foo'
|
13
|
-
mutation 'nil'
|
14
16
|
end
|
15
17
|
|
16
18
|
Mutant::Meta::Example.add do
|
17
19
|
source 'foo { |a, b| }'
|
18
20
|
|
21
|
+
singleton_mutations
|
19
22
|
mutation 'foo'
|
20
23
|
mutation 'foo { |a, b| raise }'
|
21
24
|
mutation 'foo { |a, b__mutant__| }'
|
@@ -23,13 +26,12 @@ Mutant::Meta::Example.add do
|
|
23
26
|
mutation 'foo { |a| }'
|
24
27
|
mutation 'foo { |b| }'
|
25
28
|
mutation 'foo { || }'
|
26
|
-
mutation 'nil'
|
27
29
|
end
|
28
30
|
|
29
31
|
Mutant::Meta::Example.add do
|
30
32
|
source 'foo { |(a, b), c| }'
|
31
33
|
|
32
|
-
|
34
|
+
singleton_mutations
|
33
35
|
mutation 'foo { || }'
|
34
36
|
mutation 'foo { |a, b, c| }'
|
35
37
|
mutation 'foo { |(a, b), c| raise }'
|
@@ -46,10 +48,10 @@ end
|
|
46
48
|
Mutant::Meta::Example.add do
|
47
49
|
source 'foo { |(a)| }'
|
48
50
|
|
51
|
+
singleton_mutations
|
49
52
|
mutation 'foo { || }'
|
50
53
|
mutation 'foo { |a| }'
|
51
54
|
mutation 'foo { |(a)| raise }'
|
52
55
|
mutation 'foo { |(a__mutant__)| }'
|
53
56
|
mutation 'foo'
|
54
|
-
mutation 'nil'
|
55
57
|
end
|
data/meta/block_pass.rb
CHANGED
data/meta/blockarg.rb
CHANGED
data/meta/break.rb
CHANGED
data/meta/case.rb
CHANGED
@@ -8,7 +8,7 @@ Mutant::Meta::Example.add do
|
|
8
8
|
end
|
9
9
|
RUBY
|
10
10
|
|
11
|
-
|
11
|
+
singleton_mutations
|
12
12
|
|
13
13
|
mutation <<-RUBY
|
14
14
|
case
|
@@ -33,271 +33,192 @@ end
|
|
33
33
|
|
34
34
|
Mutant::Meta::Example.add do
|
35
35
|
source <<-RUBY
|
36
|
-
case
|
37
|
-
when
|
38
|
-
when
|
39
|
-
|
36
|
+
case condition
|
37
|
+
when A
|
38
|
+
when B, C
|
39
|
+
C
|
40
40
|
else
|
41
|
-
|
41
|
+
D
|
42
42
|
end
|
43
43
|
RUBY
|
44
44
|
|
45
|
-
|
46
|
-
mutation <<-RUBY
|
47
|
-
case :condition
|
48
|
-
when :bar, :baz
|
49
|
-
:barbaz
|
50
|
-
else
|
51
|
-
:else
|
52
|
-
end
|
53
|
-
RUBY
|
54
|
-
mutation <<-RUBY
|
55
|
-
case :condition
|
56
|
-
when :foo
|
57
|
-
else
|
58
|
-
:else
|
59
|
-
end
|
60
|
-
RUBY
|
61
|
-
mutation <<-RUBY
|
62
|
-
case :condition
|
63
|
-
when :foo
|
64
|
-
when :bar, :baz
|
65
|
-
:barbaz
|
66
|
-
end
|
67
|
-
RUBY
|
45
|
+
singleton_mutations
|
68
46
|
|
69
|
-
# Mutations of condition
|
70
47
|
mutation <<-RUBY
|
71
48
|
case nil
|
72
|
-
when
|
73
|
-
when
|
74
|
-
|
49
|
+
when A
|
50
|
+
when B, C
|
51
|
+
C
|
75
52
|
else
|
76
|
-
|
53
|
+
D
|
77
54
|
end
|
78
55
|
RUBY
|
56
|
+
|
79
57
|
mutation <<-RUBY
|
80
|
-
case
|
81
|
-
when
|
82
|
-
when
|
83
|
-
|
58
|
+
case self
|
59
|
+
when A
|
60
|
+
when B, C
|
61
|
+
C
|
84
62
|
else
|
85
|
-
|
63
|
+
D
|
86
64
|
end
|
87
65
|
RUBY
|
88
66
|
|
89
|
-
# Mutations of branch bodies
|
90
67
|
mutation <<-RUBY
|
91
|
-
case
|
92
|
-
when
|
68
|
+
case condition
|
69
|
+
when A
|
93
70
|
raise
|
94
|
-
when
|
95
|
-
|
96
|
-
else
|
97
|
-
:else
|
98
|
-
end
|
99
|
-
RUBY
|
100
|
-
mutation <<-RUBY
|
101
|
-
case :condition
|
102
|
-
when :foo
|
103
|
-
when :bar, :baz
|
104
|
-
:barbaz__mutant__
|
71
|
+
when B, C
|
72
|
+
C
|
105
73
|
else
|
106
|
-
|
107
|
-
end
|
108
|
-
RUBY
|
109
|
-
mutation <<-RUBY
|
110
|
-
case :condition
|
111
|
-
when :foo
|
112
|
-
when :bar, :baz
|
113
|
-
nil
|
114
|
-
else
|
115
|
-
:else
|
116
|
-
end
|
117
|
-
RUBY
|
118
|
-
mutation <<-RUBY
|
119
|
-
case :condition
|
120
|
-
when :foo
|
121
|
-
when :bar, :baz
|
122
|
-
:barbaz
|
123
|
-
else
|
124
|
-
:else__mutant__
|
125
|
-
end
|
126
|
-
RUBY
|
127
|
-
mutation <<-RUBY
|
128
|
-
case :condition
|
129
|
-
when :foo
|
130
|
-
when :bar, :baz
|
131
|
-
:barbaz
|
132
|
-
else
|
133
|
-
nil
|
74
|
+
D
|
134
75
|
end
|
135
76
|
RUBY
|
136
77
|
|
137
|
-
# Mutations of when conditions
|
138
78
|
mutation <<-RUBY
|
139
|
-
case
|
140
|
-
when :foo__mutant__
|
141
|
-
when :bar, :baz
|
142
|
-
:barbaz
|
143
|
-
else
|
144
|
-
:else
|
145
|
-
end
|
146
|
-
RUBY
|
147
|
-
mutation <<-RUBY
|
148
|
-
case :condition
|
79
|
+
case condition
|
149
80
|
when nil
|
150
|
-
when
|
151
|
-
|
152
|
-
else
|
153
|
-
:else
|
154
|
-
end
|
155
|
-
RUBY
|
156
|
-
mutation <<-RUBY
|
157
|
-
case :condition
|
158
|
-
when :foo
|
159
|
-
when :bar__mutant__, :baz
|
160
|
-
:barbaz
|
161
|
-
else
|
162
|
-
:else
|
163
|
-
end
|
164
|
-
RUBY
|
165
|
-
mutation <<-RUBY
|
166
|
-
case :condition
|
167
|
-
when :foo
|
168
|
-
when nil, :baz
|
169
|
-
:barbaz
|
81
|
+
when B, C
|
82
|
+
C
|
170
83
|
else
|
171
|
-
|
84
|
+
D
|
172
85
|
end
|
173
86
|
RUBY
|
87
|
+
|
174
88
|
mutation <<-RUBY
|
175
|
-
case
|
176
|
-
when
|
177
|
-
when
|
178
|
-
|
89
|
+
case condition
|
90
|
+
when self
|
91
|
+
when B, C
|
92
|
+
C
|
179
93
|
else
|
180
|
-
|
94
|
+
D
|
181
95
|
end
|
182
96
|
RUBY
|
97
|
+
|
183
98
|
mutation <<-RUBY
|
184
|
-
case
|
185
|
-
when
|
186
|
-
|
187
|
-
:barbaz
|
99
|
+
case condition
|
100
|
+
when B, C
|
101
|
+
C
|
188
102
|
else
|
189
|
-
|
103
|
+
D
|
190
104
|
end
|
191
105
|
RUBY
|
106
|
+
|
192
107
|
mutation <<-RUBY
|
193
|
-
case
|
194
|
-
when
|
195
|
-
when
|
196
|
-
|
108
|
+
case condition
|
109
|
+
when A
|
110
|
+
when B, C
|
111
|
+
nil
|
197
112
|
else
|
198
|
-
|
113
|
+
D
|
199
114
|
end
|
200
115
|
RUBY
|
116
|
+
|
201
117
|
mutation <<-RUBY
|
202
|
-
case
|
203
|
-
when
|
204
|
-
when
|
205
|
-
|
118
|
+
case condition
|
119
|
+
when A
|
120
|
+
when B, C
|
121
|
+
self
|
206
122
|
else
|
207
|
-
|
123
|
+
D
|
208
124
|
end
|
209
125
|
RUBY
|
210
126
|
|
211
|
-
mutation
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
case :condition
|
217
|
-
when :foo
|
218
|
-
:foo
|
127
|
+
mutation <<-RUBY
|
128
|
+
case condition
|
129
|
+
when A
|
130
|
+
when C
|
131
|
+
C
|
219
132
|
else
|
220
|
-
|
133
|
+
D
|
221
134
|
end
|
222
135
|
RUBY
|
223
136
|
|
224
|
-
# Presence of branches
|
225
137
|
mutation <<-RUBY
|
226
|
-
case
|
227
|
-
when
|
228
|
-
|
138
|
+
case condition
|
139
|
+
when A
|
140
|
+
when nil, C
|
141
|
+
C
|
142
|
+
else
|
143
|
+
D
|
229
144
|
end
|
230
145
|
RUBY
|
231
146
|
|
232
|
-
# Mutations of condition
|
233
147
|
mutation <<-RUBY
|
234
|
-
case
|
235
|
-
when
|
236
|
-
|
148
|
+
case condition
|
149
|
+
when A
|
150
|
+
when self, C
|
151
|
+
C
|
237
152
|
else
|
238
|
-
|
153
|
+
D
|
239
154
|
end
|
240
155
|
RUBY
|
156
|
+
|
241
157
|
mutation <<-RUBY
|
242
|
-
case
|
243
|
-
when
|
244
|
-
|
158
|
+
case condition
|
159
|
+
when A
|
160
|
+
when B
|
161
|
+
C
|
245
162
|
else
|
246
|
-
|
163
|
+
D
|
247
164
|
end
|
248
165
|
RUBY
|
249
166
|
|
250
|
-
# Mutations of branch bodies
|
251
167
|
mutation <<-RUBY
|
252
|
-
case
|
253
|
-
when
|
254
|
-
|
168
|
+
case condition
|
169
|
+
when A
|
170
|
+
when B, nil
|
171
|
+
C
|
255
172
|
else
|
256
|
-
|
173
|
+
D
|
257
174
|
end
|
258
175
|
RUBY
|
176
|
+
|
259
177
|
mutation <<-RUBY
|
260
|
-
case
|
261
|
-
when
|
262
|
-
|
178
|
+
case condition
|
179
|
+
when A
|
180
|
+
when B, self
|
181
|
+
C
|
263
182
|
else
|
264
|
-
|
183
|
+
D
|
265
184
|
end
|
266
185
|
RUBY
|
186
|
+
|
267
187
|
mutation <<-RUBY
|
268
|
-
case
|
269
|
-
when
|
270
|
-
:foo
|
188
|
+
case condition
|
189
|
+
when A
|
271
190
|
else
|
272
|
-
|
191
|
+
D
|
273
192
|
end
|
274
193
|
RUBY
|
194
|
+
|
275
195
|
mutation <<-RUBY
|
276
|
-
case
|
277
|
-
when
|
278
|
-
|
196
|
+
case condition
|
197
|
+
when A
|
198
|
+
when B, C
|
199
|
+
C
|
279
200
|
else
|
280
201
|
nil
|
281
202
|
end
|
282
203
|
RUBY
|
283
204
|
|
284
|
-
# Mutations of when conditions
|
285
205
|
mutation <<-RUBY
|
286
|
-
case
|
287
|
-
when
|
288
|
-
|
206
|
+
case condition
|
207
|
+
when A
|
208
|
+
when B, C
|
209
|
+
C
|
289
210
|
else
|
290
|
-
|
211
|
+
self
|
291
212
|
end
|
292
213
|
RUBY
|
214
|
+
|
293
215
|
mutation <<-RUBY
|
294
|
-
case
|
295
|
-
when
|
296
|
-
|
297
|
-
|
298
|
-
:else
|
216
|
+
case condition
|
217
|
+
when A
|
218
|
+
when B, C
|
219
|
+
C
|
299
220
|
end
|
300
221
|
RUBY
|
301
|
-
|
302
|
-
mutation 'nil'
|
303
222
|
end
|
223
|
+
|
224
|
+
|