mutant 0.3.0.beta20 → 0.3.0.beta21
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/config/flay.yml +1 -1
- data/lib/mutant.rb +3 -0
- data/lib/mutant/constants.rb +1 -1
- data/lib/mutant/mutator/node/begin.rb +2 -1
- data/lib/mutant/mutator/node/cbase.rb +25 -0
- data/lib/mutant/mutator/node/connective/binary.rb +59 -0
- data/lib/mutant/mutator/node/const.rb +28 -0
- data/lib/mutant/mutator/node/generic.rb +2 -2
- data/lib/mutant/mutator/node/if.rb +4 -4
- data/lib/mutant/mutator/node/literal/regex.rb +13 -2
- data/lib/mutant/mutator/node/named_value/access.rb +1 -1
- data/lib/mutant/node_helpers.rb +14 -1
- data/mutant.gemspec +1 -1
- data/spec/unit/mutant/mutator/node/cbase/mutation_spec.rb +17 -0
- data/spec/unit/mutant/mutator/node/connective/binary/mutation_spec.rb +39 -0
- data/spec/unit/mutant/mutator/node/const/mutation_spec.rb +18 -0
- data/spec/unit/mutant/mutator/node/literal/regex_spec.rb +24 -7
- data/spec/unit/mutant/mutator/node/named_value/access/mutation_spec.rb +0 -11
- data/spec/unit/mutant/mutator/node/send/mutation_spec.rb +2 -0
- data/spec/unit/mutant/node_helpers/n_not_spec.rb +12 -0
- metadata +13 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 226c5aebcbb82e525556434b669aadde2eda433d
|
4
|
+
data.tar.gz: edf27540f7fdbad5176ed5b2c5e464e98fb06242
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e98fbc5850bc2b1de41d76484dbdd0f8755a625bad6f1830b9cd27e42cb3fafebdbdb6f779175deb7a57e86901ac0677be34a55679342f05c0d5f05e528960c
|
7
|
+
data.tar.gz: 2cc30f257f34cd3e113a5fa39e183a0abf0cfbc5c40efe10feba21b6b761756498abbc16a99e5356fd407b950bf9f7c1b6cc73b5b44192b7fb18bb1d05b417e9
|
data/config/flay.yml
CHANGED
data/lib/mutant.rb
CHANGED
@@ -57,6 +57,9 @@ require 'mutant/mutator/node/literal/nil'
|
|
57
57
|
require 'mutant/mutator/node/argument'
|
58
58
|
require 'mutant/mutator/node/arguments'
|
59
59
|
require 'mutant/mutator/node/begin'
|
60
|
+
require 'mutant/mutator/node/cbase'
|
61
|
+
require 'mutant/mutator/node/connective/binary'
|
62
|
+
require 'mutant/mutator/node/const'
|
60
63
|
require 'mutant/mutator/node/named_value/access'
|
61
64
|
require 'mutant/mutator/node/named_value/constant_assignment'
|
62
65
|
require 'mutant/mutator/node/named_value/variable_assignment'
|
data/lib/mutant/constants.rb
CHANGED
@@ -72,7 +72,7 @@ module Mutant
|
|
72
72
|
:kwarg, :restarg, :arg, :block_pass, :or, :and,
|
73
73
|
:next, :undef, :if, :module, :cbase, :block, :send,
|
74
74
|
:zsuper, :super, :empty, :alias, :for, :redo,
|
75
|
-
:return, :splat, :
|
75
|
+
:return, :splat, :defined?, :op_asgn, :self,
|
76
76
|
:true, :false, :nil, :dstr, :dsym, :regexp,
|
77
77
|
:regopt, :int, :str, :float, :sym, :pair, :hash, :array,
|
78
78
|
:xstr, :def, :defs, :case, :when, :ivar, :lvar, :cvar, :gvar,
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Mutant
|
2
|
+
class Mutator
|
3
|
+
class Node
|
4
|
+
|
5
|
+
# Mutation emitter to handle cbase nodes
|
6
|
+
class Cbase < self
|
7
|
+
|
8
|
+
handle(:cbase)
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
# Emit mutations
|
13
|
+
#
|
14
|
+
# @return [undefined]
|
15
|
+
#
|
16
|
+
# @api private
|
17
|
+
#
|
18
|
+
def dispatch
|
19
|
+
# noop, for now
|
20
|
+
end
|
21
|
+
|
22
|
+
end # Cbase
|
23
|
+
end # Node
|
24
|
+
end # Mutator
|
25
|
+
end # Mutant
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Mutant
|
2
|
+
class Mutator
|
3
|
+
class Node
|
4
|
+
module Connective
|
5
|
+
|
6
|
+
# Mutation emitter to handle binary connectives
|
7
|
+
class Binary < Node
|
8
|
+
|
9
|
+
INVERSE = {
|
10
|
+
:and => :or,
|
11
|
+
:or => :and,
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
handle *INVERSE.keys
|
15
|
+
|
16
|
+
children :left, :right
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# Emit mutations
|
21
|
+
#
|
22
|
+
# @return [undefined]
|
23
|
+
#
|
24
|
+
# @api private
|
25
|
+
#
|
26
|
+
def dispatch
|
27
|
+
emit_nil
|
28
|
+
emit(left)
|
29
|
+
emit(right)
|
30
|
+
mutate_operator
|
31
|
+
mutate_operands
|
32
|
+
end
|
33
|
+
|
34
|
+
# Emit operator mutations
|
35
|
+
#
|
36
|
+
# @return [undefined]
|
37
|
+
#
|
38
|
+
# @api private
|
39
|
+
#
|
40
|
+
def mutate_operator
|
41
|
+
emit(s(INVERSE.fetch(node.type), left, right))
|
42
|
+
end
|
43
|
+
|
44
|
+
# Emit condition mutations
|
45
|
+
#
|
46
|
+
# @return [undefined]
|
47
|
+
#
|
48
|
+
# @api private
|
49
|
+
#
|
50
|
+
def mutate_operands
|
51
|
+
emit(s(node.type, n_not(left), right))
|
52
|
+
emit(n_not(node))
|
53
|
+
end
|
54
|
+
|
55
|
+
end # Binary
|
56
|
+
end # Connective
|
57
|
+
end # Node
|
58
|
+
end # Mutator
|
59
|
+
end # Mutant
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Mutant
|
2
|
+
class Mutator
|
3
|
+
class Node
|
4
|
+
|
5
|
+
# Mutation emitter to handle const nodes
|
6
|
+
class Const < self
|
7
|
+
|
8
|
+
handle(:const)
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
# Emit mutations
|
13
|
+
#
|
14
|
+
# @return [undefined]
|
15
|
+
#
|
16
|
+
# @api private
|
17
|
+
#
|
18
|
+
def dispatch
|
19
|
+
emit_nil
|
20
|
+
children.each_with_index do |child, index|
|
21
|
+
mutate_child(index) if child.kind_of?(Parser::AST::Node)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end # Const
|
26
|
+
end # Node
|
27
|
+
end # Mutator
|
28
|
+
end # Mutant
|
@@ -8,12 +8,12 @@ module Mutant
|
|
8
8
|
# These nodes still need a dedicated mutator,
|
9
9
|
# your contribution is that close!
|
10
10
|
handle(
|
11
|
-
:
|
11
|
+
:defined,
|
12
12
|
:next, :break, :match, :ensure,
|
13
13
|
:dstr, :dsym, :yield, :rescue, :redo, :defined?,
|
14
14
|
:blockarg, :block_pass, :op_asgn, :and_asgn,
|
15
15
|
:regopt, :restarg, :resbody, :retry, :arg_expr,
|
16
|
-
:kwrestarg, :kwoptarg, :kwarg, :undef, :module, :
|
16
|
+
:kwrestarg, :kwoptarg, :kwarg, :undef, :module, :empty,
|
17
17
|
:alias, :for, :xstr, :back_ref, :nth_ref, :class,
|
18
18
|
:sclass, :match_with_lvasgn, :match_current_line, :or_asgn, :kwbegin
|
19
19
|
)
|
@@ -30,9 +30,9 @@ module Mutant
|
|
30
30
|
#
|
31
31
|
def mutate_condition
|
32
32
|
emit_condition_mutations
|
33
|
-
emit_self(
|
34
|
-
emit_self(
|
35
|
-
emit_self(
|
33
|
+
emit_self(n_not(condition), if_branch, else_branch)
|
34
|
+
emit_self(N_TRUE, if_branch, else_branch)
|
35
|
+
emit_self(N_FALSE, if_branch, else_branch)
|
36
36
|
end
|
37
37
|
|
38
38
|
# Emit if branch mutations
|
@@ -45,7 +45,7 @@ module Mutant
|
|
45
45
|
emit_self(condition, else_branch, nil) if else_branch
|
46
46
|
if if_branch
|
47
47
|
emit_if_branch_mutations
|
48
|
-
emit_self(condition, if_branch,
|
48
|
+
emit_self(condition, if_branch, nil)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -10,10 +10,18 @@ module Mutant
|
|
10
10
|
# No input can ever be matched with this
|
11
11
|
NULL_REGEXP_SOURCE = 'a\A'.freeze
|
12
12
|
|
13
|
-
children :source, :options
|
14
|
-
|
15
13
|
private
|
16
14
|
|
15
|
+
# Return options
|
16
|
+
#
|
17
|
+
# @return [Parser::AST::Node]
|
18
|
+
#
|
19
|
+
# @api private
|
20
|
+
#
|
21
|
+
def options
|
22
|
+
children.last
|
23
|
+
end
|
24
|
+
|
17
25
|
# Emit mutants
|
18
26
|
#
|
19
27
|
# @return [undefined]
|
@@ -22,6 +30,9 @@ module Mutant
|
|
22
30
|
#
|
23
31
|
def dispatch
|
24
32
|
emit_nil
|
33
|
+
children.each_with_index do |child, index|
|
34
|
+
mutate_child(index) unless child.type == :str
|
35
|
+
end
|
25
36
|
emit_self(s(:str, EMPTY_STRING), options)
|
26
37
|
emit_self(s(:str, NULL_REGEXP_SOURCE), options)
|
27
38
|
end
|
data/lib/mutant/node_helpers.rb
CHANGED
@@ -15,7 +15,6 @@ module Mutant
|
|
15
15
|
end
|
16
16
|
module_function :s
|
17
17
|
|
18
|
-
|
19
18
|
NAN = s(:send, s(:float, 0.0), :/, s(:args, s(:float, 0.0)))
|
20
19
|
NEGATIVE_INFINITY = s(:send, s(:float, -1.0), :/, s(:args, s(:float, 0.0)))
|
21
20
|
INFINITY = s(:send, s(:float, 1.0), :/, s(:args, s(:float, 0.0)))
|
@@ -23,8 +22,22 @@ module Mutant
|
|
23
22
|
|
24
23
|
RAISE = s(:send, nil, :raise)
|
25
24
|
|
25
|
+
N_TRUE = s(:true)
|
26
|
+
N_FALSE = s(:false)
|
26
27
|
N_NIL = s(:nil)
|
27
28
|
N_EMPTY = s(:empty)
|
28
29
|
|
30
|
+
# Build a negated boolean node
|
31
|
+
#
|
32
|
+
# @param [Parser::AST::Node] node
|
33
|
+
#
|
34
|
+
# @return [Parser::AST::Node]
|
35
|
+
#
|
36
|
+
# @api private
|
37
|
+
#
|
38
|
+
def n_not(node)
|
39
|
+
s(:send, node, :!)
|
40
|
+
end
|
41
|
+
|
29
42
|
end # NodeHelpers
|
30
43
|
end # Mutant
|
data/mutant.gemspec
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mutant::Mutator::Node::NamedValue::Access, 'cbase' do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Mutant::Random.stub(:hex_string => :random)
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:source) { '::A' }
|
10
|
+
|
11
|
+
let(:mutations) do
|
12
|
+
mutants = []
|
13
|
+
mutants << 'nil'
|
14
|
+
end
|
15
|
+
|
16
|
+
it_should_behave_like 'a mutator'
|
17
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mutant::Mutator::Node::Connective::Binary, 'mutations' do
|
4
|
+
context 'and' do
|
5
|
+
let(:source) { 'true and false' }
|
6
|
+
|
7
|
+
let(:mutations) do
|
8
|
+
mutations = []
|
9
|
+
mutations << 'nil'
|
10
|
+
mutations << 'true'
|
11
|
+
mutations << 'false'
|
12
|
+
|
13
|
+
mutations << 'true or false'
|
14
|
+
|
15
|
+
mutations << 'not true and false'
|
16
|
+
mutations << 'not(true and false)'
|
17
|
+
end
|
18
|
+
|
19
|
+
it_should_behave_like 'a mutator'
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'or' do
|
23
|
+
let(:source) { 'true or false' }
|
24
|
+
|
25
|
+
let(:mutations) do
|
26
|
+
mutations = []
|
27
|
+
mutations << 'nil'
|
28
|
+
mutations << 'true'
|
29
|
+
mutations << 'false'
|
30
|
+
|
31
|
+
mutations << 'true and false'
|
32
|
+
|
33
|
+
mutations << 'not true or false'
|
34
|
+
mutations << 'not(true or false)'
|
35
|
+
end
|
36
|
+
|
37
|
+
it_should_behave_like 'a mutator'
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mutant::Mutator::Node::NamedValue::Access, 'const' do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Mutant::Random.stub(:hex_string => :random)
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:source) { 'A::B' }
|
10
|
+
|
11
|
+
let(:mutations) do
|
12
|
+
mutants = []
|
13
|
+
mutants << 'nil'
|
14
|
+
mutants << 'nil::B'
|
15
|
+
end
|
16
|
+
|
17
|
+
it_should_behave_like 'a mutator'
|
18
|
+
end
|
@@ -2,14 +2,31 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Mutant::Mutator::Node::Literal, 'regex' do
|
4
4
|
|
5
|
-
|
5
|
+
context 'literal' do
|
6
|
+
let(:source) { '/foo/' }
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
let(:mutations) do
|
9
|
+
mutations = []
|
10
|
+
mutations << 'nil'
|
11
|
+
mutations << '//' # match all
|
12
|
+
mutations << '/a\A/' # match nothing
|
13
|
+
end
|
14
|
+
|
15
|
+
it_should_behave_like 'a mutator'
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'interpolated' do
|
19
|
+
let(:source) { '/#{foo.bar}n/' }
|
20
|
+
|
21
|
+
let(:mutations) do
|
22
|
+
mutations = []
|
23
|
+
mutations << 'nil'
|
24
|
+
mutations << '//' # match all
|
25
|
+
mutations << '/#{foo}n/' # match all
|
26
|
+
mutations << '/a\A/' # match nothing
|
27
|
+
end
|
28
|
+
|
29
|
+
it_should_behave_like 'a mutator'
|
12
30
|
end
|
13
31
|
|
14
|
-
it_should_behave_like 'a mutator'
|
15
32
|
end
|
@@ -64,17 +64,6 @@ describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
|
|
64
64
|
it_should_behave_like 'a mutator'
|
65
65
|
end
|
66
66
|
|
67
|
-
context 'constant' do
|
68
|
-
let(:source) { 'A' }
|
69
|
-
|
70
|
-
let(:mutations) do
|
71
|
-
mutants = []
|
72
|
-
mutants << 'nil'
|
73
|
-
end
|
74
|
-
|
75
|
-
it_should_behave_like 'a mutator'
|
76
|
-
end
|
77
|
-
|
78
67
|
context 'self' do
|
79
68
|
let(:source) { 'self' }
|
80
69
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mutant::NodeHelpers, '#n_not' do
|
4
|
+
subject { object.n_not(node) }
|
5
|
+
|
6
|
+
let(:object) { Object.new.extend(described_class) }
|
7
|
+
let(:node) { described_class::N_TRUE }
|
8
|
+
|
9
|
+
it 'returns the negated node' do
|
10
|
+
expect(subject).to eq(parse('not true'))
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mutant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.0.
|
4
|
+
version: 0.3.0.beta21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Schirp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -224,6 +224,9 @@ files:
|
|
224
224
|
- lib/mutant/mutator/node/begin.rb
|
225
225
|
- lib/mutant/mutator/node/block.rb
|
226
226
|
- lib/mutant/mutator/node/case.rb
|
227
|
+
- lib/mutant/mutator/node/cbase.rb
|
228
|
+
- lib/mutant/mutator/node/connective/binary.rb
|
229
|
+
- lib/mutant/mutator/node/const.rb
|
227
230
|
- lib/mutant/mutator/node/define.rb
|
228
231
|
- lib/mutant/mutator/node/generic.rb
|
229
232
|
- lib/mutant/mutator/node/if.rb
|
@@ -324,6 +327,9 @@ files:
|
|
324
327
|
- spec/unit/mutant/mutator/node/begin/mutation_spec.rb
|
325
328
|
- spec/unit/mutant/mutator/node/block/mutation_spec.rb
|
326
329
|
- spec/unit/mutant/mutator/node/case/mutation_spec.rb
|
330
|
+
- spec/unit/mutant/mutator/node/cbase/mutation_spec.rb
|
331
|
+
- spec/unit/mutant/mutator/node/connective/binary/mutation_spec.rb
|
332
|
+
- spec/unit/mutant/mutator/node/const/mutation_spec.rb
|
327
333
|
- spec/unit/mutant/mutator/node/define/mutation_spec.rb
|
328
334
|
- spec/unit/mutant/mutator/node/if/mutation_spec.rb
|
329
335
|
- spec/unit/mutant/mutator/node/literal/array_spec.rb
|
@@ -344,6 +350,7 @@ files:
|
|
344
350
|
- spec/unit/mutant/mutator/node/send/mutation_spec.rb
|
345
351
|
- spec/unit/mutant/mutator/node/super/mutation_spec.rb
|
346
352
|
- spec/unit/mutant/mutator/node/while/mutation_spec.rb
|
353
|
+
- spec/unit/mutant/node_helpers/n_not_spec.rb
|
347
354
|
- spec/unit/mutant/runner/config/subjects_spec.rb
|
348
355
|
- spec/unit/mutant/runner/config/success_predicate_spec.rb
|
349
356
|
- spec/unit/mutant/runner/mutation/killer_spec.rb
|
@@ -432,6 +439,9 @@ test_files:
|
|
432
439
|
- spec/unit/mutant/mutator/node/begin/mutation_spec.rb
|
433
440
|
- spec/unit/mutant/mutator/node/block/mutation_spec.rb
|
434
441
|
- spec/unit/mutant/mutator/node/case/mutation_spec.rb
|
442
|
+
- spec/unit/mutant/mutator/node/cbase/mutation_spec.rb
|
443
|
+
- spec/unit/mutant/mutator/node/connective/binary/mutation_spec.rb
|
444
|
+
- spec/unit/mutant/mutator/node/const/mutation_spec.rb
|
435
445
|
- spec/unit/mutant/mutator/node/define/mutation_spec.rb
|
436
446
|
- spec/unit/mutant/mutator/node/if/mutation_spec.rb
|
437
447
|
- spec/unit/mutant/mutator/node/literal/array_spec.rb
|
@@ -452,6 +462,7 @@ test_files:
|
|
452
462
|
- spec/unit/mutant/mutator/node/send/mutation_spec.rb
|
453
463
|
- spec/unit/mutant/mutator/node/super/mutation_spec.rb
|
454
464
|
- spec/unit/mutant/mutator/node/while/mutation_spec.rb
|
465
|
+
- spec/unit/mutant/node_helpers/n_not_spec.rb
|
455
466
|
- spec/unit/mutant/runner/config/subjects_spec.rb
|
456
467
|
- spec/unit/mutant/runner/config/success_predicate_spec.rb
|
457
468
|
- spec/unit/mutant/runner/mutation/killer_spec.rb
|