mutant 0.3.0.rc1 → 0.3.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +0 -1
  3. data/.travis.yml +5 -4
  4. data/Gemfile.devtools +4 -4
  5. data/Guardfile +7 -5
  6. data/README.md +8 -8
  7. data/config/flay.yml +2 -2
  8. data/config/reek.yml +1 -0
  9. data/config/rubocop.yml +0 -4
  10. data/lib/mutant/cli/builder.rb +177 -0
  11. data/lib/mutant/cli/classifier/method.rb +10 -14
  12. data/lib/mutant/cli/classifier/namespace.rb +7 -9
  13. data/lib/mutant/cli/classifier.rb +29 -31
  14. data/lib/mutant/cli.rb +34 -96
  15. data/lib/mutant/color.rb +1 -1
  16. data/lib/mutant/config.rb +9 -3
  17. data/lib/mutant/constants.rb +1 -1
  18. data/lib/mutant/context/scope.rb +2 -2
  19. data/lib/mutant/differ.rb +0 -1
  20. data/lib/mutant/killer/rspec.rb +3 -8
  21. data/lib/mutant/killer.rb +1 -22
  22. data/lib/mutant/matcher/chain.rb +2 -2
  23. data/lib/mutant/matcher/filter.rb +32 -0
  24. data/lib/mutant/matcher/method/instance.rb +2 -2
  25. data/lib/mutant/matcher/method.rb +3 -3
  26. data/lib/mutant/matcher/methods.rb +1 -1
  27. data/lib/mutant/matcher.rb +1 -0
  28. data/lib/mutant/mutation/evil.rb +0 -10
  29. data/lib/mutant/mutation/neutral.rb +0 -23
  30. data/lib/mutant/mutation.rb +13 -23
  31. data/lib/mutant/mutator/node/begin.rb +12 -10
  32. data/lib/mutant/mutator/node/block.rb +1 -0
  33. data/lib/mutant/mutator/node/blockarg.rb +15 -0
  34. data/lib/mutant/mutator/node/case.rb +1 -0
  35. data/lib/mutant/mutator/node/connective/binary.rb +2 -2
  36. data/lib/mutant/mutator/node/const.rb +2 -1
  37. data/lib/mutant/mutator/node/dstr.rb +28 -0
  38. data/lib/mutant/mutator/node/dsym.rb +28 -0
  39. data/lib/mutant/mutator/node/generic.rb +3 -4
  40. data/lib/mutant/mutator/node/if.rb +1 -0
  41. data/lib/mutant/mutator/node/literal/boolean.rb +2 -2
  42. data/lib/mutant/mutator/node/literal/range.rb +8 -6
  43. data/lib/mutant/mutator/node/literal.rb +0 -17
  44. data/lib/mutant/mutator/node/masgn.rb +1 -1
  45. data/lib/mutant/mutator/node/named_value/variable_assignment.rb +5 -4
  46. data/lib/mutant/mutator/node/op_asgn.rb +30 -0
  47. data/lib/mutant/mutator/node/restarg.rb +15 -0
  48. data/lib/mutant/mutator/node/return.rb +1 -2
  49. data/lib/mutant/mutator/node/send.rb +6 -5
  50. data/lib/mutant/mutator/node/super.rb +1 -0
  51. data/lib/mutant/mutator/node/while.rb +1 -0
  52. data/lib/mutant/mutator/node.rb +11 -1
  53. data/lib/mutant/node_helpers.rb +3 -3
  54. data/lib/mutant/predicate/attribute.rb +85 -0
  55. data/lib/mutant/predicate/blacklist.rb +27 -0
  56. data/lib/mutant/predicate/matcher.rb +36 -0
  57. data/lib/mutant/predicate/whitelist.rb +28 -0
  58. data/lib/mutant/predicate.rb +91 -0
  59. data/lib/mutant/reporter/cli/printer/config.rb +3 -3
  60. data/lib/mutant/reporter/cli/printer/killer.rb +1 -1
  61. data/lib/mutant/reporter/cli/printer/mutation.rb +12 -14
  62. data/lib/mutant/reporter/cli/printer/subject.rb +1 -3
  63. data/lib/mutant/reporter/cli/printer.rb +31 -7
  64. data/lib/mutant/runner/mutation.rb +9 -1
  65. data/lib/mutant/runner/subject.rb +9 -1
  66. data/lib/mutant/runner.rb +5 -6
  67. data/lib/mutant/strategy/rspec.rb +4 -4
  68. data/lib/mutant/strategy.rb +2 -0
  69. data/lib/mutant/support/method_object.rb +0 -1
  70. data/lib/mutant/version.rb +1 -2
  71. data/lib/mutant/zombifier.rb +6 -3
  72. data/lib/mutant.rb +12 -4
  73. data/mutant.gemspec +7 -7
  74. data/spec/integration/mutant/rspec_spec.rb +12 -5
  75. data/spec/shared/mutator_behavior.rb +2 -1
  76. data/spec/spec_helper.rb +11 -9
  77. data/spec/unit/mutant/cli/builder/rspec_spec.rb +38 -0
  78. data/spec/unit/mutant/cli/classifier/{method/each_spec.rb → method_spec.rb} +2 -14
  79. data/spec/unit/mutant/cli/classifier/namespace/{flat/each_spec.rb → flat_spec.rb} +1 -1
  80. data/spec/unit/mutant/cli/classifier/namespace/{recursive/each_spec.rb → recursive_spec.rb} +1 -1
  81. data/spec/unit/mutant/cli/classifier_spec.rb +59 -0
  82. data/spec/unit/mutant/{cli/class_methods/new_spec.rb → cli_new_spec.rb} +22 -23
  83. data/spec/unit/mutant/{cli/class_methods/run_spec.rb → cli_run_spec.rb} +8 -8
  84. data/spec/unit/mutant/killer/rspec/class_methods/new_spec.rb +6 -6
  85. data/spec/unit/mutant/killer/success_predicate_spec.rb +5 -5
  86. data/spec/unit/mutant/loader/eval/class_methods/run_spec.rb +1 -1
  87. data/spec/unit/mutant/matcher/filter_spec.rb +19 -0
  88. data/spec/unit/mutant/matcher/namespace/each_spec.rb +5 -5
  89. data/spec/unit/mutant/mutation_spec.rb +42 -0
  90. data/spec/unit/mutant/mutator/each_spec.rb +1 -1
  91. data/spec/unit/mutant/mutator/node/and_asgn/mutation_spec.rb +3 -2
  92. data/spec/unit/mutant/mutator/node/block/mutation_spec.rb +7 -2
  93. data/spec/unit/mutant/mutator/node/block_pass/mutation_spec.rb +1 -0
  94. data/spec/unit/mutant/mutator/node/blockarg/mutation_spec.rb +17 -0
  95. data/spec/unit/mutant/mutator/node/case/mutation_spec.rb +5 -1
  96. data/spec/unit/mutant/mutator/node/cbase/mutation_spec.rb +1 -0
  97. data/spec/unit/mutant/mutator/node/const/mutation_spec.rb +3 -2
  98. data/spec/unit/mutant/mutator/node/define/mutation_spec.rb +3 -3
  99. data/spec/unit/mutant/mutator/node/defined_predicate/mutation_spec.rb +6 -2
  100. data/spec/unit/mutant/mutator/node/dstr/mutation_spec.rb +4 -2
  101. data/spec/unit/mutant/mutator/node/dsym/mutation_spec.rb +4 -2
  102. data/spec/unit/mutant/mutator/node/if/mutation_spec.rb +6 -1
  103. data/spec/unit/mutant/mutator/node/literal/fixnum_spec.rb +1 -1
  104. data/spec/unit/mutant/mutator/node/literal/float_spec.rb +1 -1
  105. data/spec/unit/mutant/mutator/node/literal/range_spec.rb +31 -0
  106. data/spec/unit/mutant/mutator/node/literal/regex_spec.rb +4 -2
  107. data/spec/unit/mutant/mutator/node/literal/string_spec.rb +1 -1
  108. data/spec/unit/mutant/mutator/node/literal/symbol_spec.rb +1 -1
  109. data/spec/unit/mutant/mutator/node/masgn/mutation_spec.rb +6 -2
  110. data/spec/unit/mutant/mutator/node/match_current_line/mutation_spec.rb +1 -0
  111. data/spec/unit/mutant/mutator/node/named_value/access/mutation_spec.rb +5 -1
  112. data/spec/unit/mutant/mutator/node/named_value/constant_assignment/mutation_spec.rb +1 -2
  113. data/spec/unit/mutant/mutator/node/named_value/variable_assignment/mutation_spec.rb +5 -5
  114. data/spec/unit/mutant/mutator/node/op_assgn/mutation_spec.rb +3 -2
  115. data/spec/unit/mutant/mutator/node/or_asgn/mutation_spec.rb +3 -2
  116. data/spec/unit/mutant/mutator/node/rescue/mutation_spec.rb +1 -1
  117. data/spec/unit/mutant/mutator/node/restarg/mutation_spec.rb +3 -1
  118. data/spec/unit/mutant/mutator/node/return/mutation_spec.rb +7 -3
  119. data/spec/unit/mutant/mutator/node/send/mutation_spec.rb +37 -2
  120. data/spec/unit/mutant/mutator/node/super/mutation_spec.rb +4 -0
  121. data/spec/unit/mutant/mutator/node/while/mutation_spec.rb +3 -0
  122. data/spec/unit/mutant/predicate_spec.rb +135 -0
  123. data/spec/unit/mutant/runner/config/subjects_spec.rb +11 -11
  124. data/spec/unit/mutant/runner/config/success_predicate_spec.rb +6 -6
  125. data/spec/unit/mutant/runner/mutation/killer_spec.rb +11 -11
  126. data/spec/unit/mutant/runner/subject/success_predicate_spec.rb +9 -9
  127. data/spec/unit/mutant/strategy_spec.rb +21 -0
  128. data/spec/unit/mutant/subject_spec.rb +39 -0
  129. data/test_app/spec/shared/method_filter_parse_behavior.rb +1 -1
  130. metadata +54 -36
  131. data/lib/mutant/cli/classifier/scope.rb +0 -37
  132. data/lib/mutant/mutation/filter/code.rb +0 -49
  133. data/lib/mutant/mutation/filter/regexp.rb +0 -29
  134. data/lib/mutant/mutation/filter/whitelist.rb +0 -52
  135. data/lib/mutant/mutation/filter.rb +0 -78
  136. data/lib/mutant/strategy/static.rb +0 -20
  137. data/spec/unit/mutant/cli/classifier/class_methods/build_spec.rb +0 -48
  138. data/spec/unit/mutant/cli/classifier/scope/each_spec.rb +0 -33
@@ -12,7 +12,7 @@ describe Mutant::Mutator::Node::Literal, 'string' do
12
12
  end
13
13
 
14
14
  before do
15
- Mutant::Random.stub(:hex_string => random_string)
15
+ Mutant::Random.stub(hex_string: random_string)
16
16
  end
17
17
 
18
18
  it_should_behave_like 'a mutator'
@@ -12,7 +12,7 @@ describe Mutant::Mutator::Node::Literal, 'symbol' do
12
12
  end
13
13
 
14
14
  before do
15
- Mutant::Random.stub(:hex_string => random_string)
15
+ Mutant::Random.stub(hex_string: random_string)
16
16
  end
17
17
 
18
18
  it_should_behave_like 'a mutator'
@@ -3,8 +3,12 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Mutant::Mutator, 'masgn' do
6
- let(:source) { 'a, b = c, d' }
7
- let(:mutations) { [] }
6
+ let(:source) { 'a, b = c, d' }
7
+
8
+ let(:mutations) do
9
+ mutations = []
10
+ mutations << 'nil'
11
+ end
8
12
 
9
13
  it_should_behave_like 'a mutator'
10
14
  end
@@ -14,6 +14,7 @@ describe Mutant::Mutator::Node::Generic, 'match_current_line' do
14
14
  mutations << 'true if nil'
15
15
  mutations << 'true if !//'
16
16
  mutations << 'true if /a\A/'
17
+ mutations << 'nil'
17
18
  end
18
19
 
19
20
  it_should_behave_like 'a mutator'
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
6
6
  before do
7
- Mutant::Random.stub(:hex_string => 'random')
7
+ Mutant::Random.stub(hex_string: 'random')
8
8
  end
9
9
 
10
10
  context 'global variable' do
@@ -17,6 +17,7 @@ describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
17
17
  mutants << '$a'
18
18
  mutants << '$a = ::Object.new; $a'
19
19
  mutants << '$srandom = nil; $a'
20
+ mutants << 'nil; $a'
20
21
  end
21
22
 
22
23
  it_should_behave_like 'a mutator'
@@ -32,6 +33,7 @@ describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
32
33
  mutants << '@@a'
33
34
  mutants << '@@a = ::Object.new; @@a'
34
35
  mutants << '@@srandom = nil; @@a'
36
+ mutants << 'nil; @@a'
35
37
  end
36
38
  end
37
39
 
@@ -45,6 +47,7 @@ describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
45
47
  mutants << '@a'
46
48
  mutants << '@a = ::Object.new; @a'
47
49
  mutants << '@srandom = nil; @a'
50
+ mutants << 'nil; @a'
48
51
  end
49
52
 
50
53
  it_should_behave_like 'a mutator'
@@ -60,6 +63,7 @@ describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
60
63
  mutants << 'a'
61
64
  mutants << 'a = ::Object.new; a'
62
65
  mutants << 'srandom = nil; a'
66
+ mutants << 'nil; a'
63
67
  end
64
68
 
65
69
  it_should_behave_like 'a mutator'
@@ -4,14 +4,13 @@ require 'spec_helper'
4
4
 
5
5
  describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
6
6
  before do
7
- Mutant::Random.stub(:hex_string => 'random')
7
+ Mutant::Random.stub(hex_string: 'random')
8
8
  end
9
9
 
10
10
  let(:source) { 'A = true' }
11
11
 
12
12
  let(:mutations) do
13
13
  mutations = []
14
-
15
14
  mutations << 'SRANDOM = true'
16
15
  mutations << 'A = false'
17
16
  mutations << 'A = nil'
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
6
6
  before do
7
- Mutant::Random.stub(:hex_string => 'random')
7
+ Mutant::Random.stub(hex_string: 'random')
8
8
  end
9
9
 
10
10
  context 'global variable' do
@@ -12,10 +12,10 @@ describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
12
12
 
13
13
  let(:mutations) do
14
14
  mutations = []
15
-
16
15
  mutations << '$srandom = true'
17
16
  mutations << '$a = false'
18
17
  mutations << '$a = nil'
18
+ mutations << 'nil'
19
19
  end
20
20
 
21
21
  it_should_behave_like 'a mutator'
@@ -26,10 +26,10 @@ describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
26
26
 
27
27
  let(:mutations) do
28
28
  mutations = []
29
-
30
29
  mutations << '@@srandom = true'
31
30
  mutations << '@@a = false'
32
31
  mutations << '@@a = nil'
32
+ mutations << 'nil'
33
33
  end
34
34
 
35
35
  it_should_behave_like 'a mutator'
@@ -40,10 +40,10 @@ describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
40
40
 
41
41
  let(:mutations) do
42
42
  mutations = []
43
-
44
43
  mutations << '@srandom = true'
45
44
  mutations << '@a = false'
46
45
  mutations << '@a = nil'
46
+ mutations << 'nil'
47
47
  end
48
48
 
49
49
  it_should_behave_like 'a mutator'
@@ -54,10 +54,10 @@ describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
54
54
 
55
55
  let(:mutations) do
56
56
  mutations = []
57
-
58
57
  mutations << 'srandom = true'
59
58
  mutations << 'a = false'
60
59
  mutations << 'a = nil'
60
+ mutations << 'nil'
61
61
  end
62
62
 
63
63
  it_should_behave_like 'a mutator'
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe Mutant::Mutator::Node::Generic, 'op_asgn' do
6
6
  let(:random_fixnum) { 5 }
7
7
 
8
- let(:source) { '@a.b += 1' }
8
+ let(:source) { '@a.b += 1' }
9
9
 
10
10
  let(:mutations) do
11
11
  mutations = []
@@ -16,10 +16,11 @@ describe Mutant::Mutator::Node::Generic, 'op_asgn' do
16
16
  mutations << '@a += 1'
17
17
  mutations << '@a.b += 5'
18
18
  mutations << 'nil.b += 1'
19
+ mutations << 'nil'
19
20
  end
20
21
 
21
22
  before do
22
- Mutant::Random.stub(:fixnum => random_fixnum)
23
+ Mutant::Random.stub(fixnum: random_fixnum)
23
24
  end
24
25
 
25
26
  it_should_behave_like 'a mutator'
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Mutant::Mutator::Node::Generic, 'or_asgn' do
5
+ describe Mutant::Mutator::Node::OpAsgn, 'or_asgn' do
6
6
  let(:random_fixnum) { 5 }
7
7
  let(:random_string) { 'random' }
8
8
 
@@ -16,10 +16,11 @@ describe Mutant::Mutator::Node::Generic, 'or_asgn' do
16
16
  mutations << 'a ||= -1'
17
17
  mutations << 'a ||= 2'
18
18
  mutations << 'a ||= 5'
19
+ mutations << 'nil'
19
20
  end
20
21
 
21
22
  before do
22
- Mutant::Random.stub(:fixnum => random_fixnum, :hex_string => random_string)
23
+ Mutant::Random.stub(fixnum: random_fixnum, hex_string: random_string)
23
24
  end
24
25
 
25
26
  it_should_behave_like 'a mutator'
@@ -15,7 +15,7 @@ describe Mutant::Mutator::Node::Generic, 'rescue' do
15
15
  end
16
16
 
17
17
  before do
18
- Mutant::Random.stub(:hex_string => 'random')
18
+ Mutant::Random.stub(hex_string: 'random')
19
19
  end
20
20
 
21
21
  pending do
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Mutant::Mutator::Node::Generic, 'restarg' do
5
+ describe Mutant::Mutator::Node::Restarg, 'restarg' do
6
6
  let(:source) { 'foo(*bar)' }
7
7
 
8
8
  let(:mutations) do
@@ -10,6 +10,8 @@ describe Mutant::Mutator::Node::Generic, 'restarg' do
10
10
  mutants << 'foo'
11
11
  mutants << 'foo(nil)'
12
12
  mutants << 'foo(bar)'
13
+ mutants << 'foo(*nil)'
14
+ mutants << 'nil'
13
15
  end
14
16
 
15
17
  it_should_behave_like 'a mutator'
@@ -7,18 +7,22 @@ describe Mutant::Mutator, 'return' do
7
7
  context 'return without value' do
8
8
  let(:source) { 'return' }
9
9
 
10
- let(:mutations) { ['nil'] }
10
+ let(:mutations) do
11
+ mutations = []
12
+ mutations << 'nil'
13
+ end
11
14
 
12
15
  it_should_behave_like 'a mutator'
13
16
  end
14
17
 
15
18
  context 'return with value' do
16
- let(:source) { 'return nil' }
19
+ let(:source) { 'return foo' }
17
20
 
18
21
  let(:mutations) do
19
22
  mutations = []
23
+ mutations << 'foo'
24
+ mutations << 'return nil'
20
25
  mutations << 'nil'
21
- mutations << 'return ::Object.new'
22
26
  end
23
27
 
24
28
  it_should_behave_like 'a mutator'
@@ -15,6 +15,10 @@ describe Mutant::Mutator, 'send' do
15
15
  mutations << 'foo.gsub(b)'
16
16
  mutations << 'foo.gsub'
17
17
  mutations << 'foo.sub(a, b)'
18
+ mutations << 'foo.gsub(a, nil)'
19
+ mutations << 'foo.gsub(nil, b)'
20
+ mutations << 'nil.gsub(a, b)'
21
+ mutations << 'nil'
18
22
  end
19
23
 
20
24
  it_should_behave_like 'a mutator'
@@ -29,6 +33,9 @@ describe Mutant::Mutator, 'send' do
29
33
  mutations << 'foo.public_send(bar)'
30
34
  mutations << 'bar'
31
35
  mutations << 'foo'
36
+ mutations << 'foo.send(nil)'
37
+ mutations << 'nil.send(bar)'
38
+ mutations << 'nil'
32
39
  end
33
40
 
34
41
  it_should_behave_like 'a mutator'
@@ -40,7 +47,9 @@ describe Mutant::Mutator, 'send' do
40
47
  let(:mutations) do
41
48
  mutations = []
42
49
  mutations << 'foo ||= expression'
50
+ mutations << 'self.foo ||= nil'
43
51
  mutations << 'nil.foo ||= expression'
52
+ mutations << 'nil'
44
53
  end
45
54
 
46
55
  it_should_behave_like 'a mutator'
@@ -52,6 +61,7 @@ describe Mutant::Mutator, 'send' do
52
61
  let(:mutations) do
53
62
  mutations = []
54
63
  mutations << 'foo'
64
+ mutations << 'nil'
55
65
  end
56
66
 
57
67
  it_should_behave_like 'a mutator'
@@ -65,6 +75,8 @@ describe Mutant::Mutator, 'send' do
65
75
  mutations << 'foo'
66
76
  mutations << 'foo(nil)'
67
77
  mutations << 'foo(bar)'
78
+ mutations << 'foo(*nil)'
79
+ mutations << 'nil'
68
80
  end
69
81
 
70
82
  it_should_behave_like 'a mutator'
@@ -76,6 +88,7 @@ describe Mutant::Mutator, 'send' do
76
88
  let(:mutations) do
77
89
  mutations = []
78
90
  mutations << 'foo'
91
+ mutations << 'nil'
79
92
  end
80
93
 
81
94
  it_should_behave_like 'a mutator'
@@ -87,6 +100,7 @@ describe Mutant::Mutator, 'send' do
87
100
  let(:mutations) do
88
101
  mutations = []
89
102
  mutations << 'foo'
103
+ mutations << 'nil'
90
104
  end
91
105
 
92
106
  it_should_behave_like 'a mutator'
@@ -96,7 +110,12 @@ describe Mutant::Mutator, 'send' do
96
110
  context 'implicit' do
97
111
  let(:source) { 'foo' }
98
112
 
99
- it_should_behave_like 'a noop mutator'
113
+ let(:mutations) do
114
+ mutations = []
115
+ mutations << 'nil'
116
+ end
117
+
118
+ it_should_behave_like 'a mutator'
100
119
  end
101
120
 
102
121
  context 'explict receiver' do
@@ -107,6 +126,7 @@ describe Mutant::Mutator, 'send' do
107
126
  mutations << 'foo'
108
127
  mutations << 'self'
109
128
  mutations << 'nil.foo'
129
+ mutations << 'nil'
110
130
  end
111
131
 
112
132
  it_should_behave_like 'a mutator'
@@ -132,6 +152,8 @@ describe Mutant::Mutator, 'send' do
132
152
  let(:mutations) do
133
153
  mutations = []
134
154
  mutations << 'foo'
155
+ mutations << 'nil.bar'
156
+ mutations << 'nil'
135
157
  end
136
158
 
137
159
  it_should_behave_like 'a mutator'
@@ -145,6 +167,8 @@ describe Mutant::Mutator, 'send' do
145
167
  mutations << 'self.class'
146
168
  mutations << 'self.foo'
147
169
  mutations << 'nil.class.foo'
170
+ mutations << 'nil.foo'
171
+ mutations << 'nil'
148
172
  end
149
173
 
150
174
  it_should_behave_like 'a mutator'
@@ -191,8 +215,9 @@ describe Mutant::Mutator, 'send' do
191
215
  mutations = []
192
216
  mutations << "foo.#{keyword}"
193
217
  mutations << 'foo'
194
- mutations << 'nil'
195
218
  mutations << "foo.#{keyword}(::Object.new)"
219
+ mutations << "nil.#{keyword}(nil)"
220
+ mutations << 'nil'
196
221
  end
197
222
 
198
223
  it_should_behave_like 'a mutator'
@@ -209,6 +234,7 @@ describe Mutant::Mutator, 'send' do
209
234
  mutations << 'foo(nil)'
210
235
  mutations << 'foo(::Object.new, nil)'
211
236
  mutations << 'foo(nil, ::Object.new)'
237
+ mutations << 'nil'
212
238
  end
213
239
 
214
240
  it_should_behave_like 'a mutator'
@@ -224,6 +250,11 @@ describe Mutant::Mutator, 'send' do
224
250
  mutations << '(left - right)'
225
251
  mutations << 'left / foo'
226
252
  mutations << 'right / foo'
253
+ mutations << '(left - right) / nil'
254
+ mutations << '(left - nil) / foo'
255
+ mutations << '(nil - right) / foo'
256
+ mutations << 'nil / foo'
257
+ mutations << 'nil'
227
258
  end
228
259
 
229
260
  it_should_behave_like 'a mutator'
@@ -241,6 +272,7 @@ describe Mutant::Mutator, 'send' do
241
272
  mutations << "true #{operator} nil"
242
273
  mutations << 'true'
243
274
  mutations << 'false'
275
+ mutations << 'nil'
244
276
  end
245
277
 
246
278
  it_should_behave_like 'a mutator'
@@ -252,6 +284,9 @@ describe Mutant::Mutator, 'send' do
252
284
  mutations = []
253
285
  mutations << 'left'
254
286
  mutations << 'right'
287
+ mutations << "left #{operator} nil"
288
+ mutations << "nil #{operator} right"
289
+ mutations << 'nil'
255
290
  end
256
291
 
257
292
  it_should_behave_like 'a mutator'
@@ -21,6 +21,7 @@ describe Mutant::Mutator, 'super' do
21
21
  let(:mutations) do
22
22
  mutations = []
23
23
  mutations << 'super'
24
+ mutations << 'nil'
24
25
  end
25
26
 
26
27
  it_should_behave_like 'a mutator'
@@ -35,6 +36,9 @@ describe Mutant::Mutator, 'super' do
35
36
  mutations << 'super()'
36
37
  mutations << 'super(foo)'
37
38
  mutations << 'super(bar)'
39
+ mutations << 'super(foo, nil)'
40
+ mutations << 'super(nil, bar)'
41
+ mutations << 'nil'
38
42
  end
39
43
 
40
44
  it_should_behave_like 'a mutator'
@@ -14,6 +14,9 @@ describe Mutant::Mutator::Node::While do
14
14
  mutations << 'while true; end'
15
15
  mutations << 'while false; foo; bar; end'
16
16
  mutations << 'while nil; foo; bar; end'
17
+ mutations << 'while true; foo; nil; end'
18
+ mutations << 'while true; nil; bar; end'
19
+ mutations << 'nil'
17
20
  end
18
21
 
19
22
  it_should_behave_like 'a mutator'
@@ -0,0 +1,135 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ filter_helpers = proc do
6
+ let(:input_a) { double('Input A', foo: 'bar') }
7
+ let(:input_b) { double('Input B', foo: 'baz') }
8
+
9
+ let(:filter_a) do
10
+ input_a = self.input_a
11
+ Module.new do
12
+ define_singleton_method(:match?) do |input|
13
+ input == input_a
14
+ end
15
+ end
16
+ end
17
+
18
+ subject { object.match?(input) }
19
+ end
20
+
21
+ describe Mutant::Predicate::Whitelist do
22
+ instance_eval(&filter_helpers)
23
+
24
+ let(:object) { described_class.new(whitelist) }
25
+
26
+ describe '#match?' do
27
+
28
+ context 'with empty whitelist' do
29
+ let(:whitelist) { [] }
30
+
31
+ it 'accepts all inputs' do
32
+ expect(object.match?(input_a)).to be(false)
33
+ expect(object.match?(input_b)).to be(false)
34
+ end
35
+ end
36
+
37
+ context 'with non empty whitelist' do
38
+ let(:whitelist) { [filter_a] }
39
+
40
+ context 'with whitelisted input' do
41
+ let(:input) { input_a }
42
+
43
+ it { should be(true) }
44
+ end
45
+
46
+ context 'with non whitelisted input' do
47
+ let(:input) { input_b }
48
+
49
+ it { should be(false) }
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ describe Mutant::Predicate::Blacklist do
56
+ instance_eval(&filter_helpers)
57
+
58
+ let(:object) { described_class.new(whitelist) }
59
+
60
+ describe '#match?' do
61
+
62
+ context 'with empty whitelist' do
63
+ let(:whitelist) { [] }
64
+
65
+ it 'accepts all inputs' do
66
+ expect(object.match?(input_a)).to be(true)
67
+ expect(object.match?(input_b)).to be(true)
68
+ end
69
+ end
70
+
71
+ context 'with non empty whitelist' do
72
+ let(:whitelist) { [filter_a] }
73
+
74
+ context 'with whitelisted input' do
75
+ let(:input) { input_a }
76
+
77
+ it { should be(false) }
78
+ end
79
+
80
+ context 'with non whitelisted input' do
81
+ let(:input) { input_b }
82
+
83
+ it { should be(true) }
84
+ end
85
+ end
86
+ end
87
+ end
88
+
89
+ describe Mutant::Predicate::Attribute::Equality do
90
+ instance_eval(&filter_helpers)
91
+
92
+ let(:object) { described_class.new(attribute_name, expected_value) }
93
+ let(:input) { double('Input', attribute_name => actual_value) }
94
+
95
+ let(:attribute_name) { :foo }
96
+ let(:expected_value) { 'value' }
97
+
98
+ describe '#match?' do
99
+
100
+ context 'not matching' do
101
+ let(:actual_value) { 'other-value' }
102
+ it { should be(false) }
103
+ end
104
+
105
+ context 'matching' do
106
+ let(:actual_value) { 'value' }
107
+ it { should be(true) }
108
+ end
109
+
110
+ end
111
+ end
112
+
113
+ describe Mutant::Predicate::Attribute::Regexp do
114
+ instance_eval(&filter_helpers)
115
+
116
+ let(:object) { described_class.new(attribute_name, expectation) }
117
+ let(:input) { double('Input', attribute_name => actual_value) }
118
+
119
+ let(:attribute_name) { :foo }
120
+ let(:expectation) { /\Avalue\z/ }
121
+
122
+ describe '#match?' do
123
+
124
+ context 'not matching' do
125
+ let(:actual_value) { 'other-value' }
126
+ it { should be(false) }
127
+ end
128
+
129
+ context 'matching' do
130
+ let(:actual_value) { 'value' }
131
+ it { should be(true) }
132
+ end
133
+
134
+ end
135
+ end
@@ -10,24 +10,24 @@ describe Mutant::Runner::Config, '#subjects' do
10
10
  let(:config) do
11
11
  double(
12
12
  'Config',
13
- :class => Mutant::Config,
14
- :subjects => [subject_a, subject_b],
15
- :strategy => strategy,
16
- :reporter => reporter
13
+ class: Mutant::Config,
14
+ subjects: [subject_a, subject_b],
15
+ strategy: strategy,
16
+ reporter: reporter
17
17
  )
18
18
  end
19
19
 
20
- let(:reporter) { double('Reporter') }
21
- let(:strategy) { double('Strategy') }
22
- let(:subject_a) { double('Subject A') }
23
- let(:subject_b) { double('Subject B') }
24
- let(:runner_a) { double('Runner A', :stop? => stop_a) }
25
- let(:runner_b) { double('Runner B', :stop? => stop_b) }
20
+ let(:reporter) { double('Reporter') }
21
+ let(:strategy) { double('Strategy') }
22
+ let(:subject_a) { double('Subject A') }
23
+ let(:subject_b) { double('Subject B') }
24
+ let(:runner_a) { double('Runner A', stop?: stop_a) }
25
+ let(:runner_b) { double('Runner B', stop?: stop_b) }
26
26
 
27
27
  before do
28
28
  strategy.stub(:setup)
29
29
  strategy.stub(:teardown)
30
- reporter.stub(:report => reporter)
30
+ reporter.stub(report: reporter)
31
31
  Mutant::Runner.stub(:run).with(config, subject_a).and_return(runner_a)
32
32
  Mutant::Runner.stub(:run).with(config, subject_b).and_return(runner_b)
33
33
  end
@@ -10,9 +10,9 @@ describe Mutant::Runner::Config, '#success?' do
10
10
  let(:config) do
11
11
  double(
12
12
  'Config',
13
- :reporter => reporter,
14
- :strategy => strategy,
15
- :subjects => [subject_a, subject_b]
13
+ reporter: reporter,
14
+ strategy: strategy,
15
+ subjects: [subject_a, subject_b]
16
16
  )
17
17
  end
18
18
 
@@ -22,15 +22,15 @@ describe Mutant::Runner::Config, '#success?' do
22
22
  let(:subject_b) { double('Subject B') }
23
23
 
24
24
  let(:runner_a) do
25
- double('Runner A', :stop? => stop_a, :success? => success_a)
25
+ double('Runner A', stop?: stop_a, success?: success_a)
26
26
  end
27
27
 
28
28
  let(:runner_b) do
29
- double('Runner B', :stop? => stop_b, :success? => success_b)
29
+ double('Runner B', stop?: stop_b, success?: success_b)
30
30
  end
31
31
 
32
32
  before do
33
- reporter.stub(:report => reporter)
33
+ reporter.stub(report: reporter)
34
34
  strategy.stub(:setup)
35
35
  strategy.stub(:teardown)
36
36
  Mutant::Runner.stub(:run).with(config, subject_a).and_return(runner_a)
@@ -8,24 +8,24 @@ describe Mutant::Runner::Mutation, '#killer' do
8
8
  let(:config) do
9
9
  double(
10
10
  'Config',
11
- :fail_fast => fail_fast,
12
- :reporter => reporter,
13
- :strategy => strategy
11
+ fail_fast: fail_fast,
12
+ reporter: reporter,
13
+ strategy: strategy
14
14
  )
15
15
  end
16
16
 
17
- let(:reporter) { double('Reporter') }
18
- let(:mutation) { double('Mutation', :class => Mutant::Mutation) }
19
- let(:strategy) { double('Strategy') }
20
- let(:killer) { double('Killer', :success? => success) }
21
- let(:fail_fast) { false }
22
- let(:success) { false }
17
+ let(:reporter) { double('Reporter') }
18
+ let(:mutation) { double('Mutation', class: Mutant::Mutation) }
19
+ let(:strategy) { double('Strategy') }
20
+ let(:killer) { double('Killer', success?: success) }
21
+ let(:fail_fast) { false }
22
+ let(:success) { false }
23
23
 
24
24
  subject { object.killer }
25
25
 
26
26
  before do
27
- reporter.stub(:report => reporter)
28
- strategy.stub(:kill => killer)
27
+ reporter.stub(report: reporter)
28
+ strategy.stub(kill: killer)
29
29
  end
30
30
 
31
31
  it 'should call configuration to identify strategy' do