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
@@ -1,59 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::CLI::Classifier, '.run' do
|
6
|
-
subject { described_class.run(cache, input) }
|
7
|
-
|
8
|
-
let(:cache) { double('Cache') }
|
9
|
-
|
10
|
-
this_spec = 'Mutant::CLI::Classifier.build'
|
11
|
-
|
12
|
-
shared_examples_for this_spec do
|
13
|
-
it 'shoud return expected instance' do
|
14
|
-
should eql(expected_matcher)
|
15
|
-
end
|
16
|
-
|
17
|
-
let(:expected_class) { Mutant::CLI::Classifier::Method }
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'with explicit toplevel scope' do
|
21
|
-
|
22
|
-
let(:input) { '::TestApp::Literal#string' }
|
23
|
-
|
24
|
-
let(:expected_matcher) do
|
25
|
-
Mutant::Matcher::Method::Instance.new(cache, TestApp::Literal, TestApp::Literal.instance_method(:string))
|
26
|
-
end
|
27
|
-
|
28
|
-
include_examples this_spec
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'with instance method notation' do
|
32
|
-
|
33
|
-
let(:input) { 'TestApp::Literal#string' }
|
34
|
-
|
35
|
-
let(:expected_matcher) do
|
36
|
-
Mutant::Matcher::Method::Instance.new(cache, TestApp::Literal, TestApp::Literal.instance_method(:string))
|
37
|
-
end
|
38
|
-
|
39
|
-
include_examples this_spec
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'with singleton method notation' do
|
43
|
-
let(:input) { 'TestApp::Literal.string' }
|
44
|
-
|
45
|
-
let(:expected_matcher) do
|
46
|
-
Mutant::Matcher::Method::Singleton.new(cache, TestApp::Literal, TestApp::Literal.method(:string))
|
47
|
-
end
|
48
|
-
|
49
|
-
include_examples this_spec
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'with invalid notation' do
|
53
|
-
let(:input) { '::' }
|
54
|
-
|
55
|
-
it 'should return nil' do
|
56
|
-
expect { subject }.to raise_error(Mutant::CLI::Error, "No matcher handles: #{input.inspect}")
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::Mutator::Node::OpAsgn, 'and_asgn' do
|
6
|
-
let(:source) { 'a &&= 1' }
|
7
|
-
|
8
|
-
let(:mutations) do
|
9
|
-
mutations = []
|
10
|
-
mutations << 'a__mutant__ &&= 1'
|
11
|
-
mutations << 'a &&= nil'
|
12
|
-
mutations << 'a &&= 0'
|
13
|
-
mutations << 'a &&= -1'
|
14
|
-
mutations << 'a &&= 2'
|
15
|
-
mutations << 'nil'
|
16
|
-
end
|
17
|
-
|
18
|
-
it_should_behave_like 'a mutator'
|
19
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::Mutator, 'begin' do
|
6
|
-
|
7
|
-
# This mutation and only this mutation can result in
|
8
|
-
# and empty emit that is parsed into nil, unparser cannot
|
9
|
-
# handle this so we guard this here!
|
10
|
-
def generate(node)
|
11
|
-
return '' if node.nil?
|
12
|
-
super
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:source) { "true\nfalse" }
|
16
|
-
|
17
|
-
let(:mutations) do
|
18
|
-
mutations = []
|
19
|
-
|
20
|
-
# Mutation of each statement in block
|
21
|
-
mutations << "true\ntrue"
|
22
|
-
mutations << "false\nfalse"
|
23
|
-
mutations << "nil\nfalse"
|
24
|
-
mutations << "true\nnil"
|
25
|
-
|
26
|
-
# Remove statement in block
|
27
|
-
mutations << 'true'
|
28
|
-
mutations << 'false'
|
29
|
-
end
|
30
|
-
|
31
|
-
it_should_behave_like 'a mutator'
|
32
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::Mutator::Node::Binary, 'mutations' do
|
6
|
-
context 'and' do
|
7
|
-
let(:source) { 'true and false' }
|
8
|
-
|
9
|
-
let(:mutations) do
|
10
|
-
mutations = []
|
11
|
-
mutations << 'nil'
|
12
|
-
mutations << 'true'
|
13
|
-
mutations << 'false'
|
14
|
-
|
15
|
-
mutations << 'true or false'
|
16
|
-
|
17
|
-
mutations << 'not true and false'
|
18
|
-
mutations << 'not(true and false)'
|
19
|
-
end
|
20
|
-
|
21
|
-
it_should_behave_like 'a mutator'
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'or' do
|
25
|
-
let(:source) { 'true or false' }
|
26
|
-
|
27
|
-
let(:mutations) do
|
28
|
-
mutations = []
|
29
|
-
mutations << 'nil'
|
30
|
-
mutations << 'true'
|
31
|
-
mutations << 'false'
|
32
|
-
|
33
|
-
mutations << 'true and false'
|
34
|
-
|
35
|
-
mutations << 'not true or false'
|
36
|
-
mutations << 'not(true or false)'
|
37
|
-
end
|
38
|
-
|
39
|
-
it_should_behave_like 'a mutator'
|
40
|
-
end
|
41
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::Mutator::Node::NamedValue::Access, 'block_pass' do
|
6
|
-
let(:source) { 'foo(&bar)' }
|
7
|
-
|
8
|
-
let(:mutations) do
|
9
|
-
mutants = []
|
10
|
-
mutants << 'foo'
|
11
|
-
mutants << 'nil'
|
12
|
-
end
|
13
|
-
|
14
|
-
it_should_behave_like 'a mutator'
|
15
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::Mutator, 'block' do
|
6
|
-
context 'with block' do
|
7
|
-
let(:source) { 'foo() { a; b }' }
|
8
|
-
|
9
|
-
let(:mutations) do
|
10
|
-
mutations = []
|
11
|
-
mutations << 'foo { a }'
|
12
|
-
mutations << 'foo { b }'
|
13
|
-
mutations << 'foo {}'
|
14
|
-
mutations << 'foo { raise }'
|
15
|
-
mutations << 'foo { a; nil }'
|
16
|
-
mutations << 'foo { nil; b }'
|
17
|
-
mutations << 'foo'
|
18
|
-
mutations << 'nil'
|
19
|
-
end
|
20
|
-
|
21
|
-
it_should_behave_like 'a mutator'
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'with block args' do
|
25
|
-
|
26
|
-
let(:source) { 'foo { |a, b| }' }
|
27
|
-
|
28
|
-
let(:mutations) do
|
29
|
-
mutations = []
|
30
|
-
mutations << 'foo'
|
31
|
-
mutations << 'foo { |a, b| raise }'
|
32
|
-
mutations << 'foo { |a, b__mutant__| }'
|
33
|
-
mutations << 'foo { |a__mutant__, b| }'
|
34
|
-
mutations << 'foo { |a| }'
|
35
|
-
mutations << 'foo { |b| }'
|
36
|
-
mutations << 'foo { || }'
|
37
|
-
mutations << 'nil'
|
38
|
-
end
|
39
|
-
|
40
|
-
it_should_behave_like 'a mutator'
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'with block pattern args' do
|
44
|
-
|
45
|
-
let(:source) { 'foo { |(a, b), c| }' }
|
46
|
-
|
47
|
-
let(:mutations) do
|
48
|
-
mutations = []
|
49
|
-
mutations << 'foo { || }'
|
50
|
-
mutations << 'foo { |a, b, c| }'
|
51
|
-
mutations << 'foo { |(a, b), c| raise }'
|
52
|
-
mutations << 'foo { |(a), c| }'
|
53
|
-
mutations << 'foo { |(b), c| }'
|
54
|
-
mutations << 'foo { |(a, b)| }'
|
55
|
-
mutations << 'foo { |c| }'
|
56
|
-
mutations << 'foo { |(a__mutant__, b), c| }'
|
57
|
-
mutations << 'foo { |(a, b__mutant__), c| }'
|
58
|
-
mutations << 'foo { |(a, b), c__mutant__| }'
|
59
|
-
mutations << 'foo'
|
60
|
-
mutations << 'nil'
|
61
|
-
end
|
62
|
-
|
63
|
-
it_should_behave_like 'a mutator'
|
64
|
-
end
|
65
|
-
|
66
|
-
context 'with mini block pattern arg' do
|
67
|
-
|
68
|
-
let(:source) { 'foo { |(a)| }' }
|
69
|
-
|
70
|
-
let(:mutations) do
|
71
|
-
mutations = []
|
72
|
-
mutations << 'foo { || }'
|
73
|
-
mutations << 'foo { |a| }'
|
74
|
-
mutations << 'foo { |(a)| raise }'
|
75
|
-
mutations << 'foo { |(a__mutant__)| }'
|
76
|
-
mutations << 'foo'
|
77
|
-
mutations << 'nil'
|
78
|
-
end
|
79
|
-
|
80
|
-
it_should_behave_like 'a mutator'
|
81
|
-
|
82
|
-
end
|
83
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::Mutator::Node::Blockarg, 'blockarg' do
|
6
|
-
let(:source) { 'foo { |&bar| }' }
|
7
|
-
|
8
|
-
let(:mutations) do
|
9
|
-
mutations = []
|
10
|
-
mutations << 'foo { |&bar| raise }'
|
11
|
-
mutations << 'foo {}'
|
12
|
-
mutations << 'foo'
|
13
|
-
mutations << 'nil'
|
14
|
-
end
|
15
|
-
|
16
|
-
it_should_behave_like 'a mutator'
|
17
|
-
end
|
@@ -1,329 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mutant::Mutator::Node::Case do
|
6
|
-
context 'without condition' do
|
7
|
-
let(:source) do
|
8
|
-
<<-RUBY
|
9
|
-
case
|
10
|
-
when true
|
11
|
-
else
|
12
|
-
end
|
13
|
-
RUBY
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:mutations) do
|
17
|
-
mutations = []
|
18
|
-
mutations << 'nil'
|
19
|
-
mutations << <<-RUBY
|
20
|
-
case
|
21
|
-
when true
|
22
|
-
raise
|
23
|
-
else
|
24
|
-
end
|
25
|
-
RUBY
|
26
|
-
mutations << <<-RUBY
|
27
|
-
case
|
28
|
-
when false
|
29
|
-
else
|
30
|
-
end
|
31
|
-
RUBY
|
32
|
-
mutations << <<-RUBY
|
33
|
-
case
|
34
|
-
when nil
|
35
|
-
else
|
36
|
-
end
|
37
|
-
RUBY
|
38
|
-
end
|
39
|
-
|
40
|
-
it_should_behave_like 'a mutator'
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'with multiple when branches' do
|
44
|
-
let(:source) do
|
45
|
-
<<-RUBY
|
46
|
-
case :condition
|
47
|
-
when :foo
|
48
|
-
when :bar, :baz
|
49
|
-
:barbaz
|
50
|
-
else
|
51
|
-
:else
|
52
|
-
end
|
53
|
-
RUBY
|
54
|
-
end
|
55
|
-
|
56
|
-
let(:mutations) do
|
57
|
-
mutations = []
|
58
|
-
|
59
|
-
# Presence of branches
|
60
|
-
mutations << <<-RUBY
|
61
|
-
case :condition
|
62
|
-
when :bar, :baz
|
63
|
-
:barbaz
|
64
|
-
else
|
65
|
-
:else
|
66
|
-
end
|
67
|
-
RUBY
|
68
|
-
mutations << <<-RUBY
|
69
|
-
case :condition
|
70
|
-
when :foo
|
71
|
-
else
|
72
|
-
:else
|
73
|
-
end
|
74
|
-
RUBY
|
75
|
-
mutations << <<-RUBY
|
76
|
-
case :condition
|
77
|
-
when :foo
|
78
|
-
when :bar, :baz
|
79
|
-
:barbaz
|
80
|
-
end
|
81
|
-
RUBY
|
82
|
-
|
83
|
-
# Mutations of condition
|
84
|
-
mutations << <<-RUBY
|
85
|
-
case nil
|
86
|
-
when :foo
|
87
|
-
when :bar, :baz
|
88
|
-
:barbaz
|
89
|
-
else
|
90
|
-
:else
|
91
|
-
end
|
92
|
-
RUBY
|
93
|
-
mutations << <<-RUBY
|
94
|
-
case :condition__mutant__
|
95
|
-
when :foo
|
96
|
-
when :bar, :baz
|
97
|
-
:barbaz
|
98
|
-
else
|
99
|
-
:else
|
100
|
-
end
|
101
|
-
RUBY
|
102
|
-
|
103
|
-
# Mutations of branch bodies
|
104
|
-
mutations << <<-RUBY
|
105
|
-
case :condition
|
106
|
-
when :foo
|
107
|
-
raise
|
108
|
-
when :bar, :baz
|
109
|
-
:barbaz
|
110
|
-
else
|
111
|
-
:else
|
112
|
-
end
|
113
|
-
RUBY
|
114
|
-
mutations << <<-RUBY
|
115
|
-
case :condition
|
116
|
-
when :foo
|
117
|
-
when :bar, :baz
|
118
|
-
:barbaz__mutant__
|
119
|
-
else
|
120
|
-
:else
|
121
|
-
end
|
122
|
-
RUBY
|
123
|
-
mutations << <<-RUBY
|
124
|
-
case :condition
|
125
|
-
when :foo
|
126
|
-
when :bar, :baz
|
127
|
-
nil
|
128
|
-
else
|
129
|
-
:else
|
130
|
-
end
|
131
|
-
RUBY
|
132
|
-
mutations << <<-RUBY
|
133
|
-
case :condition
|
134
|
-
when :foo
|
135
|
-
when :bar, :baz
|
136
|
-
:barbaz
|
137
|
-
else
|
138
|
-
:else__mutant__
|
139
|
-
end
|
140
|
-
RUBY
|
141
|
-
mutations << <<-RUBY
|
142
|
-
case :condition
|
143
|
-
when :foo
|
144
|
-
when :bar, :baz
|
145
|
-
:barbaz
|
146
|
-
else
|
147
|
-
nil
|
148
|
-
end
|
149
|
-
RUBY
|
150
|
-
|
151
|
-
# Mutations of when conditions
|
152
|
-
mutations << <<-RUBY
|
153
|
-
case :condition
|
154
|
-
when :foo__mutant__
|
155
|
-
when :bar, :baz
|
156
|
-
:barbaz
|
157
|
-
else
|
158
|
-
:else
|
159
|
-
end
|
160
|
-
RUBY
|
161
|
-
mutations << <<-RUBY
|
162
|
-
case :condition
|
163
|
-
when nil
|
164
|
-
when :bar, :baz
|
165
|
-
:barbaz
|
166
|
-
else
|
167
|
-
:else
|
168
|
-
end
|
169
|
-
RUBY
|
170
|
-
mutations << <<-RUBY
|
171
|
-
case :condition
|
172
|
-
when :foo
|
173
|
-
when :bar__mutant__, :baz
|
174
|
-
:barbaz
|
175
|
-
else
|
176
|
-
:else
|
177
|
-
end
|
178
|
-
RUBY
|
179
|
-
mutations << <<-RUBY
|
180
|
-
case :condition
|
181
|
-
when :foo
|
182
|
-
when nil, :baz
|
183
|
-
:barbaz
|
184
|
-
else
|
185
|
-
:else
|
186
|
-
end
|
187
|
-
RUBY
|
188
|
-
mutations << <<-RUBY
|
189
|
-
case :condition
|
190
|
-
when :foo
|
191
|
-
when :bar, nil
|
192
|
-
:barbaz
|
193
|
-
else
|
194
|
-
:else
|
195
|
-
end
|
196
|
-
RUBY
|
197
|
-
mutations << <<-RUBY
|
198
|
-
case :condition
|
199
|
-
when :foo
|
200
|
-
when :bar, :baz__mutant__
|
201
|
-
:barbaz
|
202
|
-
else
|
203
|
-
:else
|
204
|
-
end
|
205
|
-
RUBY
|
206
|
-
mutations << <<-RUBY
|
207
|
-
case :condition
|
208
|
-
when :foo
|
209
|
-
when :baz
|
210
|
-
:barbaz
|
211
|
-
else
|
212
|
-
:else
|
213
|
-
end
|
214
|
-
RUBY
|
215
|
-
mutations << <<-RUBY
|
216
|
-
case :condition
|
217
|
-
when :foo
|
218
|
-
when :bar
|
219
|
-
:barbaz
|
220
|
-
else
|
221
|
-
:else
|
222
|
-
end
|
223
|
-
RUBY
|
224
|
-
|
225
|
-
mutations << 'nil'
|
226
|
-
end
|
227
|
-
|
228
|
-
it_should_behave_like 'a mutator'
|
229
|
-
end
|
230
|
-
|
231
|
-
context 'with one when branch' do
|
232
|
-
let(:source) do
|
233
|
-
<<-RUBY
|
234
|
-
case :condition
|
235
|
-
when :foo
|
236
|
-
:foo
|
237
|
-
else
|
238
|
-
:else
|
239
|
-
end
|
240
|
-
RUBY
|
241
|
-
end
|
242
|
-
|
243
|
-
let(:mutations) do
|
244
|
-
mutations = []
|
245
|
-
|
246
|
-
# Presence of branches
|
247
|
-
mutations << <<-RUBY
|
248
|
-
case :condition
|
249
|
-
when :foo
|
250
|
-
:foo
|
251
|
-
end
|
252
|
-
RUBY
|
253
|
-
|
254
|
-
# Mutations of condition
|
255
|
-
mutations << <<-RUBY
|
256
|
-
case nil
|
257
|
-
when :foo
|
258
|
-
:foo
|
259
|
-
else
|
260
|
-
:else
|
261
|
-
end
|
262
|
-
RUBY
|
263
|
-
mutations << <<-RUBY
|
264
|
-
case :condition__mutant__
|
265
|
-
when :foo
|
266
|
-
:foo
|
267
|
-
else
|
268
|
-
:else
|
269
|
-
end
|
270
|
-
RUBY
|
271
|
-
|
272
|
-
# Mutations of branch bodies
|
273
|
-
mutations << <<-RUBY
|
274
|
-
case :condition
|
275
|
-
when :foo
|
276
|
-
nil
|
277
|
-
else
|
278
|
-
:else
|
279
|
-
end
|
280
|
-
RUBY
|
281
|
-
mutations << <<-RUBY
|
282
|
-
case :condition
|
283
|
-
when :foo
|
284
|
-
:foo__mutant__
|
285
|
-
else
|
286
|
-
:else
|
287
|
-
end
|
288
|
-
RUBY
|
289
|
-
mutations << <<-RUBY
|
290
|
-
case :condition
|
291
|
-
when :foo
|
292
|
-
:foo
|
293
|
-
else
|
294
|
-
:else__mutant__
|
295
|
-
end
|
296
|
-
RUBY
|
297
|
-
mutations << <<-RUBY
|
298
|
-
case :condition
|
299
|
-
when :foo
|
300
|
-
:foo
|
301
|
-
else
|
302
|
-
nil
|
303
|
-
end
|
304
|
-
RUBY
|
305
|
-
|
306
|
-
# Mutations of when conditions
|
307
|
-
mutations << <<-RUBY
|
308
|
-
case :condition
|
309
|
-
when :foo__mutant__
|
310
|
-
:foo
|
311
|
-
else
|
312
|
-
:else
|
313
|
-
end
|
314
|
-
RUBY
|
315
|
-
mutations << <<-RUBY
|
316
|
-
case :condition
|
317
|
-
when nil
|
318
|
-
:foo
|
319
|
-
else
|
320
|
-
:else
|
321
|
-
end
|
322
|
-
RUBY
|
323
|
-
|
324
|
-
mutations << 'nil'
|
325
|
-
end
|
326
|
-
|
327
|
-
it_should_behave_like 'a mutator'
|
328
|
-
end
|
329
|
-
end
|