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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b345e5eb8a65a538f350534528ca7c327bf2dde1
|
|
4
|
+
data.tar.gz: b516b255a58425b77916f19dc5640c2e4e849393
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6e1bcd22f9acf5400057b7dcac381f7c29ddf2dda558a422ed8b8d5d2c48189eeee17d3deee583cb0865ee3e2077f552b2451bc5743625f29739dca5bfb7021a
|
|
7
|
+
data.tar.gz: b242006807e001093b1f22ef974c22900987901263ef39fe4d0e6ef651fe3b54ee79c8fa6a0fb46367228b7cb8e45822c60c0de250f5cd0ef31a3d039d19c93e
|
data/Changelog.md
CHANGED
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@ mutant
|
|
|
4
4
|
[](http://travis-ci.org/mbj/mutant)
|
|
5
5
|
[](https://gemnasium.com/mbj/mutant)
|
|
6
6
|
[](https://codeclimate.com/github/mbj/mutant)
|
|
7
|
-
[](http://inch-ci.org/github/mbj/mutant)
|
|
8
8
|
|
|
9
9
|
Mutant is a mutation testing tool for ruby.
|
|
10
10
|
|
|
@@ -27,7 +27,7 @@ There are some presentations about mutant in the wild:
|
|
|
27
27
|
|
|
28
28
|
* [RailsConf 2014](http://railsconf.com/) / http://confreaks.com/videos/3333-railsconf-mutation-testing-with-mutant
|
|
29
29
|
* [Wrocloverb 2014](http://wrocloverb.com/) / https://www.youtube.com/watch?v=rz-lFKEioLk
|
|
30
|
-
* [
|
|
30
|
+
* [eurucamp 2013](http://2013.eurucamp.org/) / FrOSCon-2013 http://slid.es/markusschirp/mutation-testing
|
|
31
31
|
* [Cologne.rb](http://www.colognerb.de/topics/mutation-testing-mit-mutant) / https://github.com/DonSchado/colognerb-on-mutant/blob/master/mutation_testing_slides.pdf
|
|
32
32
|
|
|
33
33
|
Blog-Posts
|
data/config/flay.yml
CHANGED
data/lib/mutant.rb
CHANGED
|
@@ -156,9 +156,12 @@ require 'mutant/mutator/node/kwbegin'
|
|
|
156
156
|
require 'mutant/mutator/node/named_value/access'
|
|
157
157
|
require 'mutant/mutator/node/named_value/constant_assignment'
|
|
158
158
|
require 'mutant/mutator/node/named_value/variable_assignment'
|
|
159
|
-
require 'mutant/mutator/node/
|
|
159
|
+
require 'mutant/mutator/node/next'
|
|
160
|
+
require 'mutant/mutator/node/break'
|
|
160
161
|
require 'mutant/mutator/node/noop'
|
|
161
162
|
require 'mutant/mutator/node/or_asgn'
|
|
163
|
+
require 'mutant/mutator/node/and_asgn'
|
|
164
|
+
require 'mutant/mutator/node/defined'
|
|
162
165
|
require 'mutant/mutator/node/op_asgn'
|
|
163
166
|
require 'mutant/mutator/node/conditional_loop'
|
|
164
167
|
require 'mutant/mutator/node/yield'
|
|
@@ -74,6 +74,17 @@ module Mutant
|
|
|
74
74
|
self
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
+
# Add singleotn mutations
|
|
78
|
+
#
|
|
79
|
+
# @return [undefined]
|
|
80
|
+
#
|
|
81
|
+
# @api private
|
|
82
|
+
#
|
|
83
|
+
def singleton_mutations
|
|
84
|
+
mutation 'nil'
|
|
85
|
+
mutation 'self'
|
|
86
|
+
end
|
|
87
|
+
|
|
77
88
|
# Helper method to coerce input to node
|
|
78
89
|
#
|
|
79
90
|
# @param [String,Parser::AST::Node] input
|
data/lib/mutant/mutator/node.rb
CHANGED
|
@@ -23,8 +23,8 @@ module Mutant
|
|
|
23
23
|
children.at(index)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
define_method("emit_#{name}_mutations") do
|
|
27
|
-
mutate_child(index)
|
|
26
|
+
define_method("emit_#{name}_mutations") do |&block|
|
|
27
|
+
mutate_child(index, &block)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
define_method("emit_#{name}") do |node|
|
|
@@ -118,10 +118,13 @@ module Mutant
|
|
|
118
118
|
#
|
|
119
119
|
# @api private
|
|
120
120
|
#
|
|
121
|
-
def mutate_child(index, mutator = Mutator)
|
|
121
|
+
def mutate_child(index, mutator = Mutator, &block)
|
|
122
|
+
block ||= lambda { |_node| true }
|
|
122
123
|
child = children.at(index)
|
|
123
124
|
mutator.each(child, self) do |mutation|
|
|
124
|
-
|
|
125
|
+
if block.call(mutation)
|
|
126
|
+
emit_child_update(index, mutation)
|
|
127
|
+
end
|
|
125
128
|
end
|
|
126
129
|
end
|
|
127
130
|
|
|
@@ -166,7 +169,28 @@ module Mutant
|
|
|
166
169
|
emit(new_self(*children))
|
|
167
170
|
end
|
|
168
171
|
|
|
169
|
-
# Emit
|
|
172
|
+
# Emit singleton literals
|
|
173
|
+
#
|
|
174
|
+
# @return [undefined]
|
|
175
|
+
#
|
|
176
|
+
# @api private
|
|
177
|
+
#
|
|
178
|
+
def emit_singletons
|
|
179
|
+
emit_nil
|
|
180
|
+
emit_self
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# Emit a literal self
|
|
184
|
+
#
|
|
185
|
+
# @return [undefined]
|
|
186
|
+
#
|
|
187
|
+
# @api private
|
|
188
|
+
#
|
|
189
|
+
def emit_self
|
|
190
|
+
emit(N_SELF)
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# Emit a literal nil
|
|
170
194
|
#
|
|
171
195
|
# @return [undefined]
|
|
172
196
|
#
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
module Mutant
|
|
4
|
+
class Mutator
|
|
5
|
+
class Node
|
|
6
|
+
|
|
7
|
+
# OpAsgn mutator
|
|
8
|
+
class AndAsgn < self
|
|
9
|
+
|
|
10
|
+
handle(:and_asgn)
|
|
11
|
+
|
|
12
|
+
children :left, :right
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
# Emit mutations
|
|
17
|
+
#
|
|
18
|
+
# @return [undefined]
|
|
19
|
+
#
|
|
20
|
+
# @api private
|
|
21
|
+
#
|
|
22
|
+
def dispatch
|
|
23
|
+
emit_singletons
|
|
24
|
+
emit_left_mutations do |mutation|
|
|
25
|
+
!mutation.type.equal?(:self)
|
|
26
|
+
end
|
|
27
|
+
emit_right_mutations
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end # OrAsgn
|
|
31
|
+
end # Node
|
|
32
|
+
end # Mutator
|
|
33
|
+
end # Mutant
|
|
34
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
module Mutant
|
|
4
|
+
class Mutator
|
|
5
|
+
class Node
|
|
6
|
+
|
|
7
|
+
# Mutator for loop control keywords
|
|
8
|
+
class Break < Generic
|
|
9
|
+
|
|
10
|
+
handle(:break)
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
# Emit mutations
|
|
15
|
+
#
|
|
16
|
+
# @return [undefined]
|
|
17
|
+
#
|
|
18
|
+
# @api private
|
|
19
|
+
#
|
|
20
|
+
def dispatch
|
|
21
|
+
super
|
|
22
|
+
emit_singletons
|
|
23
|
+
children.each_index(&method(:delete_child))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end # Break
|
|
27
|
+
end # Node
|
|
28
|
+
end # Mutator
|
|
29
|
+
end # Mutant
|
|
@@ -18,7 +18,7 @@ module Mutant
|
|
|
18
18
|
# @api private
|
|
19
19
|
#
|
|
20
20
|
def dispatch
|
|
21
|
-
|
|
21
|
+
emit_singletons unless parent_type == :const
|
|
22
22
|
emit_type(nil, *children.drop(1))
|
|
23
23
|
children.each_with_index do |child, index|
|
|
24
24
|
mutate_child(index) if child.kind_of?(Parser::AST::Node)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
module Mutant
|
|
4
|
+
class Mutator
|
|
5
|
+
class Node
|
|
6
|
+
# Namespace for define mutations
|
|
7
|
+
class Defined < self
|
|
8
|
+
|
|
9
|
+
handle(:defined?)
|
|
10
|
+
|
|
11
|
+
children :expression
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
# Emit mutations
|
|
16
|
+
#
|
|
17
|
+
# @return [undefined]
|
|
18
|
+
#
|
|
19
|
+
# @api private
|
|
20
|
+
#
|
|
21
|
+
def dispatch
|
|
22
|
+
emit_expression_mutations do |node|
|
|
23
|
+
!node.type.equal?(:self)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end # Defined
|
|
28
|
+
end # Node
|
|
29
|
+
end # Mutator
|
|
30
|
+
end # Mutant
|
|
@@ -10,7 +10,7 @@ module Mutant
|
|
|
10
10
|
# These nodes still need a dedicated mutator,
|
|
11
11
|
# your contribution is that close!
|
|
12
12
|
handle(
|
|
13
|
-
:ensure, :redo, :
|
|
13
|
+
:ensure, :redo, :regopt, :retry, :arg_expr,
|
|
14
14
|
:kwrestarg, :kwoptarg, :kwarg, :undef, :module, :empty,
|
|
15
15
|
:alias, :for, :xstr, :back_ref, :class,
|
|
16
16
|
:sclass, :match_with_lvasgn, :while_post,
|
|
@@ -19,10 +19,10 @@ module Mutant
|
|
|
19
19
|
# @api private
|
|
20
20
|
#
|
|
21
21
|
def dispatch
|
|
22
|
+
emit_singletons
|
|
22
23
|
mutate_condition
|
|
23
24
|
mutate_if_branch
|
|
24
25
|
mutate_else_branch
|
|
25
|
-
emit_nil
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
# Emit conditon mutations
|
|
@@ -32,7 +32,9 @@ module Mutant
|
|
|
32
32
|
# @api private
|
|
33
33
|
#
|
|
34
34
|
def mutate_condition
|
|
35
|
-
emit_condition_mutations
|
|
35
|
+
emit_condition_mutations do |condition|
|
|
36
|
+
!condition.type.eql?(:self)
|
|
37
|
+
end
|
|
36
38
|
emit_type(n_not(condition), if_branch, else_branch) unless condition.type == :match_current_line
|
|
37
39
|
emit_type(N_TRUE, if_branch, else_branch)
|
|
38
40
|
emit_type(N_FALSE, if_branch, else_branch)
|
|
@@ -31,7 +31,7 @@ module Mutant
|
|
|
31
31
|
# @api private
|
|
32
32
|
#
|
|
33
33
|
def dispatch
|
|
34
|
-
|
|
34
|
+
emit_singletons unless parent_type == :match_current_line
|
|
35
35
|
children.each_with_index do |child, index|
|
|
36
36
|
mutate_child(index) unless child.type == :str
|
|
37
37
|
end
|