mutant 0.8.10 → 0.8.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (247) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -4
  3. data/Changelog.md +8 -0
  4. data/README.md +112 -43
  5. data/Rakefile +2 -16
  6. data/circle.yml +1 -1
  7. data/config/flay.yml +2 -2
  8. data/config/flog.yml +1 -1
  9. data/config/reek.yml +3 -4
  10. data/config/rubocop.yml +53 -16
  11. data/lib/mutant.rb +27 -6
  12. data/lib/mutant/ast/meta/const.rb +2 -0
  13. data/lib/mutant/ast/meta/optarg.rb +2 -0
  14. data/lib/mutant/ast/meta/resbody.rb +2 -0
  15. data/lib/mutant/ast/meta/restarg.rb +2 -0
  16. data/lib/mutant/ast/meta/send.rb +4 -0
  17. data/lib/mutant/ast/meta/symbol.rb +2 -0
  18. data/lib/mutant/ast/named_children.rb +14 -4
  19. data/lib/mutant/ast/nodes.rb +3 -1
  20. data/lib/mutant/ast/regexp.rb +53 -0
  21. data/lib/mutant/ast/regexp/transformer.rb +185 -0
  22. data/lib/mutant/ast/regexp/transformer/alternative.rb +39 -0
  23. data/lib/mutant/ast/regexp/transformer/character_set.rb +46 -0
  24. data/lib/mutant/ast/regexp/transformer/direct.rb +99 -0
  25. data/lib/mutant/ast/regexp/transformer/options_group.rb +66 -0
  26. data/lib/mutant/ast/regexp/transformer/quantifier.rb +112 -0
  27. data/lib/mutant/ast/regexp/transformer/recursive.rb +50 -0
  28. data/lib/mutant/ast/regexp/transformer/root.rb +29 -0
  29. data/lib/mutant/ast/regexp/transformer/text.rb +55 -0
  30. data/lib/mutant/ast/types.rb +92 -5
  31. data/lib/mutant/cli.rb +2 -14
  32. data/lib/mutant/color.rb +1 -1
  33. data/lib/mutant/config.rb +1 -3
  34. data/lib/mutant/expression/methods.rb +1 -1
  35. data/lib/mutant/expression/namespace.rb +2 -2
  36. data/lib/mutant/expression/parser.rb +1 -1
  37. data/lib/mutant/integration.rb +10 -28
  38. data/lib/mutant/isolation.rb +9 -60
  39. data/lib/mutant/isolation/fork.rb +72 -0
  40. data/lib/mutant/isolation/none.rb +25 -0
  41. data/lib/mutant/matcher/config.rb +2 -0
  42. data/lib/mutant/matcher/method/singleton.rb +5 -4
  43. data/lib/mutant/meta.rb +11 -4
  44. data/lib/mutant/meta/example.rb +2 -116
  45. data/lib/mutant/meta/example/dsl.rb +22 -19
  46. data/lib/mutant/meta/example/verification.rb +86 -0
  47. data/lib/mutant/mutator.rb +22 -49
  48. data/lib/mutant/mutator/node.rb +15 -19
  49. data/lib/mutant/mutator/node/and_asgn.rb +1 -1
  50. data/lib/mutant/mutator/node/argument.rb +10 -5
  51. data/lib/mutant/mutator/node/arguments.rb +5 -9
  52. data/lib/mutant/mutator/node/begin.rb +4 -17
  53. data/lib/mutant/mutator/node/block.rb +1 -1
  54. data/lib/mutant/mutator/node/break.rb +1 -1
  55. data/lib/mutant/mutator/node/class.rb +21 -0
  56. data/lib/mutant/mutator/node/conditional_loop.rb +1 -1
  57. data/lib/mutant/mutator/node/define.rb +1 -1
  58. data/lib/mutant/mutator/node/defined.rb +1 -1
  59. data/lib/mutant/mutator/node/dstr.rb +1 -1
  60. data/lib/mutant/mutator/node/dsym.rb +1 -1
  61. data/lib/mutant/mutator/node/generic.rb +3 -3
  62. data/lib/mutant/mutator/node/kwbegin.rb +1 -1
  63. data/lib/mutant/mutator/node/literal.rb +9 -0
  64. data/lib/mutant/mutator/node/literal/boolean.rb +1 -1
  65. data/lib/mutant/mutator/node/literal/fixnum.rb +2 -2
  66. data/lib/mutant/mutator/node/literal/float.rb +4 -6
  67. data/lib/mutant/mutator/node/literal/hash.rb +1 -1
  68. data/lib/mutant/mutator/node/literal/nil.rb +1 -1
  69. data/lib/mutant/mutator/node/literal/range.rb +2 -19
  70. data/lib/mutant/mutator/node/literal/regex.rb +43 -3
  71. data/lib/mutant/mutator/node/literal/string.rb +1 -1
  72. data/lib/mutant/mutator/node/literal/symbol.rb +2 -4
  73. data/lib/mutant/mutator/node/masgn.rb +1 -1
  74. data/lib/mutant/mutator/node/match_current_line.rb +1 -1
  75. data/lib/mutant/mutator/node/mlhs.rb +2 -3
  76. data/lib/mutant/mutator/node/named_value/access.rb +2 -2
  77. data/lib/mutant/mutator/node/named_value/constant_assignment.rb +4 -3
  78. data/lib/mutant/mutator/node/named_value/variable_assignment.rb +4 -4
  79. data/lib/mutant/mutator/node/next.rb +1 -1
  80. data/lib/mutant/mutator/node/nthref.rb +1 -1
  81. data/lib/mutant/mutator/node/or_asgn.rb +1 -1
  82. data/lib/mutant/mutator/node/regexp.rb +44 -0
  83. data/lib/mutant/mutator/node/regopt.rb +31 -0
  84. data/lib/mutant/mutator/node/resbody.rb +1 -1
  85. data/lib/mutant/mutator/node/rescue.rb +1 -3
  86. data/lib/mutant/mutator/node/return.rb +1 -1
  87. data/lib/mutant/mutator/node/send.rb +43 -3
  88. data/lib/mutant/mutator/node/send/attribute_assignment.rb +4 -1
  89. data/lib/mutant/mutator/node/send/conditional.rb +23 -0
  90. data/lib/mutant/mutator/node/send/index.rb +1 -1
  91. data/lib/mutant/mutator/node/splat.rb +1 -1
  92. data/lib/mutant/mutator/node/when.rb +1 -1
  93. data/lib/mutant/mutator/node/yield.rb +1 -1
  94. data/lib/mutant/mutator/util.rb +0 -30
  95. data/lib/mutant/mutator/util/array.rb +4 -16
  96. data/lib/mutant/parallel.rb +1 -1
  97. data/lib/mutant/parallel/worker.rb +1 -1
  98. data/lib/mutant/registry.rb +44 -0
  99. data/lib/mutant/reporter/cli/format.rb +2 -0
  100. data/lib/mutant/reporter/cli/printer.rb +2 -2
  101. data/lib/mutant/reporter/cli/printer/config.rb +0 -1
  102. data/lib/mutant/reporter/cli/printer/env_progress.rb +1 -11
  103. data/lib/mutant/reporter/cli/printer/mutation_progress_result.rb +1 -1
  104. data/lib/mutant/reporter/cli/printer/mutation_result.rb +2 -0
  105. data/lib/mutant/reporter/cli/tput.rb +1 -1
  106. data/lib/mutant/reporter/sequence.rb +3 -0
  107. data/lib/mutant/require_highjack.rb +6 -2
  108. data/lib/mutant/result.rb +1 -1
  109. data/lib/mutant/subject.rb +5 -5
  110. data/lib/mutant/subject/method/instance.rb +1 -2
  111. data/lib/mutant/util.rb +18 -0
  112. data/lib/mutant/version.rb +1 -1
  113. data/lib/mutant/zombifier.rb +5 -3
  114. data/meta/and.rb +1 -1
  115. data/meta/and_asgn.rb +1 -1
  116. data/meta/array.rb +2 -2
  117. data/meta/begin.rb +2 -2
  118. data/meta/block.rb +7 -7
  119. data/meta/block_pass.rb +1 -1
  120. data/meta/blockarg.rb +1 -1
  121. data/meta/break.rb +1 -1
  122. data/meta/case.rb +2 -2
  123. data/meta/casgn.rb +11 -2
  124. data/meta/cbase.rb +1 -1
  125. data/meta/class.rb +10 -0
  126. data/meta/const.rb +9 -1
  127. data/meta/csend.rb +8 -0
  128. data/meta/cvar.rb +1 -1
  129. data/meta/cvasgn.rb +1 -1
  130. data/meta/date.rb +4 -4
  131. data/meta/def.rb +14 -14
  132. data/meta/defined.rb +1 -1
  133. data/meta/dstr.rb +1 -1
  134. data/meta/dsym.rb +1 -1
  135. data/meta/ensure.rb +1 -1
  136. data/meta/false.rb +1 -1
  137. data/meta/float.rb +3 -3
  138. data/meta/gvar.rb +1 -1
  139. data/meta/gvasgn.rb +1 -1
  140. data/meta/hash.rb +1 -1
  141. data/meta/if.rb +17 -3
  142. data/meta/int.rb +1 -1
  143. data/meta/ivar.rb +1 -1
  144. data/meta/ivasgn.rb +14 -1
  145. data/meta/kwarg.rb +8 -0
  146. data/meta/kwbegin.rb +1 -1
  147. data/meta/kwoptarg.rb +11 -0
  148. data/meta/lvar.rb +1 -1
  149. data/meta/lvasgn.rb +1 -1
  150. data/meta/masgn.rb +1 -1
  151. data/meta/match_current_line.rb +2 -2
  152. data/meta/next.rb +1 -1
  153. data/meta/nil.rb +1 -1
  154. data/meta/nthref.rb +5 -5
  155. data/meta/op_assgn.rb +1 -1
  156. data/meta/or.rb +1 -1
  157. data/meta/or_asgn.rb +5 -5
  158. data/meta/range.rb +2 -8
  159. data/meta/redo.rb +1 -1
  160. data/meta/regexp.rb +106 -0
  161. data/meta/regexp/regexp_bol_anchor.rb +13 -0
  162. data/meta/regexp/regexp_bos_anchor.rb +26 -0
  163. data/meta/regexp/regexp_root_expression.rb +13 -0
  164. data/meta/regopt.rb +8 -0
  165. data/meta/rescue.rb +49 -4
  166. data/meta/restarg.rb +6 -9
  167. data/meta/return.rb +2 -2
  168. data/meta/self.rb +1 -1
  169. data/meta/send.rb +228 -55
  170. data/meta/str.rb +1 -1
  171. data/meta/super.rb +3 -3
  172. data/meta/{symbol.rb → sym.rb} +1 -1
  173. data/meta/true.rb +1 -1
  174. data/meta/until.rb +1 -1
  175. data/meta/while.rb +2 -2
  176. data/meta/yield.rb +1 -1
  177. data/mutant-rspec.gemspec +2 -2
  178. data/mutant.gemspec +6 -5
  179. data/spec/integration/mutant/isolation/fork_spec.rb +8 -0
  180. data/spec/integration/mutant/rspec_spec.rb +1 -1
  181. data/spec/integration/mutant/test_mutator_handles_types_spec.rb +1 -2
  182. data/spec/integrations.yml +93 -24
  183. data/spec/spec_helper.rb +12 -7
  184. data/spec/support/compress_helper.rb +1 -1
  185. data/spec/support/corpus.rb +115 -50
  186. data/spec/support/fake_actor.rb +5 -5
  187. data/spec/support/file_system.rb +1 -1
  188. data/spec/support/ice_nine_config.rb +3 -3
  189. data/spec/support/ruby_vm.rb +11 -12
  190. data/spec/support/shared_context.rb +22 -13
  191. data/spec/support/test_app.rb +1 -1
  192. data/spec/support/warning.rb +64 -0
  193. data/spec/support/warnings.yml +4 -0
  194. data/spec/support/xspec.rb +177 -0
  195. data/spec/unit/mutant/actor/env_spec.rb +2 -2
  196. data/spec/unit/mutant/actor/sender_spec.rb +1 -1
  197. data/spec/unit/mutant/ast/meta/send_spec.rb +1 -1
  198. data/spec/unit/mutant/ast/named_children_spec.rb +26 -0
  199. data/spec/unit/mutant/ast/regexp/parse_spec.rb +7 -0
  200. data/spec/unit/mutant/ast/regexp/supported_predicate_spec.rb +14 -0
  201. data/spec/unit/mutant/ast/regexp/transformer/lookup_table/table_spec.rb +19 -0
  202. data/spec/unit/mutant/ast/regexp/transformer/lookup_table_spec.rb +33 -0
  203. data/spec/unit/mutant/ast/regexp/transformer_spec.rb +19 -0
  204. data/spec/unit/mutant/ast/regexp_spec.rb +617 -0
  205. data/spec/unit/mutant/cli_spec.rb +7 -45
  206. data/spec/unit/mutant/context_spec.rb +4 -7
  207. data/spec/unit/mutant/env/{boostrap_spec.rb → bootstrap_spec.rb} +2 -2
  208. data/spec/unit/mutant/env_spec.rb +13 -16
  209. data/spec/unit/mutant/expression/namespace/{flat_spec.rb → exact_spec.rb} +0 -0
  210. data/spec/unit/mutant/integration/rspec_spec.rb +2 -2
  211. data/spec/unit/mutant/integration_spec.rb +14 -0
  212. data/spec/unit/mutant/isolation/fork_spec.rb +155 -0
  213. data/spec/unit/mutant/isolation/none_spec.rb +16 -0
  214. data/spec/unit/mutant/loader_spec.rb +1 -1
  215. data/spec/unit/mutant/matcher/methods/instance_spec.rb +2 -4
  216. data/spec/unit/mutant/meta/example/dsl_spec.rb +106 -0
  217. data/spec/unit/mutant/meta/example/verification_spec.rb +120 -0
  218. data/spec/unit/mutant/meta/example_spec.rb +32 -0
  219. data/spec/unit/mutant/mutator/node_spec.rb +37 -4
  220. data/spec/unit/mutant/mutator_spec.rb +21 -0
  221. data/spec/unit/mutant/{runner → parallel}/driver_spec.rb +0 -0
  222. data/spec/unit/mutant/parallel/master_spec.rb +13 -13
  223. data/spec/unit/mutant/registry_spec.rb +47 -0
  224. data/spec/unit/mutant/reporter/cli/printer/config_spec.rb +0 -4
  225. data/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb +0 -8
  226. data/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb +0 -2
  227. data/spec/unit/mutant/reporter/cli/printer/status_progressive_spec.rb +0 -8
  228. data/spec/unit/mutant/reporter/cli/printer/status_spec.rb +0 -34
  229. data/spec/unit/mutant/reporter/cli_spec.rb +0 -22
  230. data/spec/unit/mutant/repository/diff_spec.rb +6 -6
  231. data/spec/unit/mutant/require_highjack_spec.rb +38 -14
  232. data/spec/unit/mutant/result/env_spec.rb +1 -4
  233. data/spec/unit/mutant/runner_spec.rb +1 -1
  234. data/spec/unit/mutant/subject/method/instance_spec.rb +1 -1
  235. data/spec/unit/mutant/subject_spec.rb +3 -3
  236. data/spec/unit/mutant/util/one_spec.rb +20 -0
  237. data/spec/unit/mutant/zombifier_spec.rb +18 -18
  238. data/test_app/{Gemfile.rspec3.3 → Gemfile.rspec3.5} +2 -2
  239. metadata +94 -24
  240. data/TODO +0 -21
  241. data/lib/mutant/mutator/node/blockarg.rb +0 -13
  242. data/lib/mutant/mutator/node/restarg.rb +0 -13
  243. data/lib/mutant/mutator/registry.rb +0 -49
  244. data/meta/boolean.rb +0 -13
  245. data/meta/regex.rb +0 -19
  246. data/spec/unit/mutant/isolation_spec.rb +0 -104
  247. data/spec/unit/mutant/mutator/registry_spec.rb +0 -57
@@ -0,0 +1,120 @@
1
+ RSpec.describe Mutant::Meta::Example::Verification do
2
+ let(:object) { described_class.new(example, mutations) }
3
+
4
+ let(:example) do
5
+ Mutant::Meta::Example.new(
6
+ file: 'foo.rb',
7
+ node: s(:true),
8
+ node_type: :true,
9
+ expected: expected_nodes
10
+ )
11
+ end
12
+
13
+ let(:mutations) do
14
+ generated_nodes.map do |node|
15
+ Mutant::Mutation::Evil.new(example, node)
16
+ end
17
+ end
18
+
19
+ let(:generated_nodes) { [] }
20
+ let(:expected_nodes) { [] }
21
+
22
+ describe '#success?' do
23
+ subject { object.success? }
24
+
25
+ context 'when generated nodes equal expected nodes' do
26
+ it { should be(true) }
27
+ end
28
+
29
+ context 'when expected node is missing' do
30
+ let(:expected_nodes) { [s(:false)] }
31
+
32
+ it { should be(false) }
33
+ end
34
+
35
+ context 'when there is extra generated node' do
36
+ let(:generated_nodes) { [s(:false)] }
37
+
38
+ it { should be(false) }
39
+ end
40
+
41
+ context 'when there is no diff to original source' do
42
+ let(:expected_nodes) { [s(:true)] }
43
+ let(:generated_nodes) { [s(:true)] }
44
+
45
+ it { should be(false) }
46
+ end
47
+ end
48
+
49
+ describe '#error_report' do
50
+ subject { object.error_report }
51
+
52
+ context 'on success' do
53
+ specify do
54
+ expect { subject }.to raise_error(
55
+ RuntimeError,
56
+ 'no error report on successful validation'
57
+ )
58
+ end
59
+ end
60
+
61
+ context 'when expected node is missing' do
62
+ let(:expected_nodes) { [s(:false), s(:nil)] }
63
+
64
+ specify do
65
+ should eql(strip_indent(<<-'REPORT'))
66
+ ---
67
+ file: foo.rb
68
+ original_ast: s(:true)
69
+ original_source: 'true'
70
+ missing:
71
+ - node: s(:false)
72
+ source: 'false'
73
+ - node: s(:nil)
74
+ source: nil
75
+ unexpected: []
76
+ no_diff: []
77
+ REPORT
78
+ end
79
+ end
80
+
81
+ context 'when there is extra generated node' do
82
+ let(:generated_nodes) { [s(:false), s(:nil)] }
83
+
84
+ specify do
85
+ should eql(strip_indent(<<-'REPORT'))
86
+ ---
87
+ file: foo.rb
88
+ original_ast: s(:true)
89
+ original_source: 'true'
90
+ missing: []
91
+ unexpected:
92
+ - node: s(:false)
93
+ source: 'false'
94
+ - node: s(:nil)
95
+ source: nil
96
+ no_diff: []
97
+ REPORT
98
+ end
99
+ end
100
+
101
+ context 'when there is no diff to original source' do
102
+ let(:expected_nodes) { [s(:true)] }
103
+ let(:generated_nodes) { [s(:true)] }
104
+
105
+ specify do
106
+ should eql(strip_indent(<<-'REPORT'))
107
+ ---
108
+ file: foo.rb
109
+ original_ast: s(:true)
110
+ original_source: 'true'
111
+ missing: []
112
+ unexpected: []
113
+ no_diff:
114
+ - node: s(:true)
115
+ source: 'true'
116
+ REPORT
117
+ end
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,32 @@
1
+ RSpec.describe Mutant::Meta::Example do
2
+ let(:object) do
3
+ described_class.new(
4
+ file: file,
5
+ node: node,
6
+ node_type: node.type,
7
+ expected: mutation_nodes
8
+ )
9
+ end
10
+
11
+ let(:file) { 'foo/bar.rb' }
12
+ let(:node) { s(:true) }
13
+ let(:mutation_nodes) { [s(:nil), s(:false)] }
14
+
15
+ let(:mutations) do
16
+ mutation_nodes.map do |node|
17
+ Mutant::Mutation::Evil.new(object, node)
18
+ end
19
+ end
20
+
21
+ describe '#source' do
22
+ subject { object.source }
23
+
24
+ it { should eql('true') }
25
+ end
26
+
27
+ describe '#verification' do
28
+ subject { object.verification }
29
+
30
+ it { should eql(Mutant::Meta::Example::Verification.new(object, mutations)) }
31
+ end
32
+ end
@@ -1,7 +1,9 @@
1
- RSpec.describe Mutant::Mutator::Node do
2
- Mutant::Meta::Example::ALL.each do |example|
3
- context "on #{example.node.type.inspect}" do
4
- it 'generates the correct mutations' do
1
+ Mutant::Meta::Example::ALL.each.group_by(&:node_type).each do |type, examples|
2
+ RSpec.describe Mutant::Mutator::REGISTRY.lookup(type) do
3
+ toplevel_nodes = examples.map { |example| example.node.type }.uniq
4
+
5
+ it "generates the correct mutations on #{toplevel_nodes} toplevel examples" do
6
+ examples.each do |example|
5
7
  verification = example.verification
6
8
  unless verification.success?
7
9
  fail verification.error_report
@@ -10,3 +12,34 @@ RSpec.describe Mutant::Mutator::Node do
10
12
  end
11
13
  end
12
14
  end
15
+
16
+ RSpec.describe Mutant::Mutator::Node do
17
+ describe 'internal DSL' do
18
+ let(:klass) do
19
+ Class.new(described_class) do
20
+ children(:left, :right)
21
+
22
+ def dispatch
23
+ left
24
+ emit_left(s(:nil))
25
+ emit_right_mutations do |node|
26
+ node.eql?(s(:nil))
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ def apply
33
+ klass.call(s(:and, s(:true), s(:true)))
34
+ end
35
+
36
+ specify do
37
+ expect(apply).to eql(
38
+ [
39
+ s(:and, s(:nil), s(:true)),
40
+ s(:and, s(:true), s(:nil))
41
+ ].to_set
42
+ )
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,21 @@
1
+ RSpec.describe Mutant::Mutator do
2
+ describe '.handle' do
3
+ let(:object) { described_class }
4
+
5
+ subject do
6
+ Class.new(described_class) do
7
+ const_set(:REGISTRY, Mutant::Registry.new)
8
+
9
+ handle :send
10
+
11
+ def dispatch
12
+ emit(parent)
13
+ end
14
+ end
15
+ end
16
+
17
+ it 'should register mutator' do
18
+ expect(subject.mutate(s(:send), s(:parent))).to eql([s(:parent)].to_set)
19
+ end
20
+ end
21
+ end
@@ -68,13 +68,13 @@ RSpec.describe Mutant::Parallel::Master do
68
68
  def stop?
69
69
  @stop
70
70
  end
71
- end
71
+ end # FakeSink
72
72
 
73
73
  # Needed because of rubies undefined-ivar-read-is-nil stuff
74
74
  describe 'object initialization' do
75
- let(:object) { described_class.send(:new, config, actor_env.mailbox(:master)) }
75
+ let(:object) { described_class.__send__(:new, config, actor_env.mailbox(:master)) }
76
76
 
77
- it 'initializes falsy ivars'do
77
+ it 'initializes falsy ivars' do
78
78
  expect(object.instance_variable_get(:@stop)).to be(false)
79
79
  end
80
80
  end
@@ -104,13 +104,13 @@ RSpec.describe Mutant::Parallel::Master do
104
104
 
105
105
  sink.stop
106
106
 
107
- message_sequence.add(:master, :ready, worker_a)
107
+ message_sequence.add(:master, :ready, worker_a)
108
108
  message_sequence.add(:worker_a, :stop)
109
109
 
110
- message_sequence.add(:master, :ready, worker_b)
110
+ message_sequence.add(:master, :ready, worker_b)
111
111
  message_sequence.add(:worker_b, :stop)
112
112
 
113
- message_sequence.add(:master, :stop, parent)
113
+ message_sequence.add(:master, :stop, parent)
114
114
  message_sequence.add(:parent, :stop)
115
115
  end
116
116
 
@@ -124,10 +124,10 @@ RSpec.describe Mutant::Parallel::Master do
124
124
  before do
125
125
  sink.stop
126
126
 
127
- message_sequence.add(:master, :ready, worker_a)
127
+ message_sequence.add(:master, :ready, worker_a)
128
128
  message_sequence.add(:worker_a, :stop)
129
129
 
130
- message_sequence.add(:master, :stop, parent)
130
+ message_sequence.add(:master, :stop, parent)
131
131
  message_sequence.add(:parent, :stop)
132
132
  end
133
133
 
@@ -154,7 +154,7 @@ RSpec.describe Mutant::Parallel::Master do
154
154
  message_sequence.add(:master, :ready, worker_a)
155
155
  message_sequence.add(:worker_a, :stop)
156
156
 
157
- message_sequence.add(:master, :stop, parent)
157
+ message_sequence.add(:master, :stop, parent)
158
158
  message_sequence.add(:parent, :stop)
159
159
  end
160
160
 
@@ -182,7 +182,7 @@ RSpec.describe Mutant::Parallel::Master do
182
182
  message_sequence.add(:master, :ready, worker_a)
183
183
  message_sequence.add(:worker_a, :stop)
184
184
 
185
- message_sequence.add(:master, :stop, parent)
185
+ message_sequence.add(:master, :stop, parent)
186
186
  message_sequence.add(:parent, :stop)
187
187
  end
188
188
 
@@ -244,7 +244,7 @@ RSpec.describe Mutant::Parallel::Master do
244
244
  message_sequence.add(:parent, :status, expected_status) do |message|
245
245
  expect(message.payload.active_jobs.frozen?).to be(true)
246
246
  end
247
- message_sequence.add(:master, :stop, parent)
247
+ message_sequence.add(:master, :stop, parent)
248
248
  message_sequence.add(:parent, :stop)
249
249
  end
250
250
 
@@ -275,7 +275,7 @@ RSpec.describe Mutant::Parallel::Master do
275
275
  message_sequence.add(:master, :ready, worker_a)
276
276
  message_sequence.add(:worker_a, :stop)
277
277
 
278
- message_sequence.add(:master, :stop, parent)
278
+ message_sequence.add(:master, :stop, parent)
279
279
  message_sequence.add(:parent, :stop)
280
280
  end
281
281
 
@@ -302,7 +302,7 @@ RSpec.describe Mutant::Parallel::Master do
302
302
  message_sequence.add(:master, :ready, worker_a)
303
303
  message_sequence.add(:worker_a, :stop)
304
304
 
305
- message_sequence.add(:master, :stop, parent)
305
+ message_sequence.add(:master, :stop, parent)
306
306
  message_sequence.add(:parent, :stop)
307
307
  end
308
308
 
@@ -0,0 +1,47 @@
1
+ RSpec.describe Mutant::Registry do
2
+ let(:lookup) { object.lookup(type) }
3
+ let(:object) { described_class.new }
4
+ let(:mutator) { class_double(Mutant::Mutator) }
5
+ let(:node) { s(:true) }
6
+ let(:expected_arguments) { [node, nil] }
7
+
8
+ def register_mutator
9
+ object.register(type, mutator)
10
+ end
11
+
12
+ context 'on registered type' do
13
+ subject { register_mutator }
14
+
15
+ let(:type) { :true }
16
+
17
+ before { subject }
18
+
19
+ it 'returns registered mutator' do
20
+ expect(lookup).to be(mutator)
21
+ end
22
+
23
+ it_behaves_like 'a command method'
24
+
25
+ context 'when registered twice' do
26
+ it 'fails upon registration' do
27
+ expect { register_mutator }.to raise_error(described_class::RegistryError, 'Duplicate type registration: :true')
28
+ end
29
+ end
30
+ end
31
+
32
+ context 'on unknown type' do
33
+ let(:type) { :unknown }
34
+
35
+ it 'raises error' do
36
+ expect { lookup }.to raise_error(described_class::RegistryError, 'No entry for: :unknown')
37
+ end
38
+ end
39
+
40
+ context 'when registering an invalid node type' do
41
+ let(:type) { :invalid }
42
+
43
+ it 'raises error' do
44
+ expect { register_mutator }.to raise_error(described_class::RegistryError, 'Invalid type registration: :invalid')
45
+ end
46
+ end
47
+ end
@@ -9,7 +9,6 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Config do
9
9
  Mutant configuration:
10
10
  Matcher: #<Mutant::Matcher::Config empty>
11
11
  Integration: Mutant::Integration::Null
12
- Expect Coverage: 100.00%
13
12
  Jobs: 1
14
13
  Includes: []
15
14
  Requires: []
@@ -17,13 +16,10 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Config do
17
16
  end
18
17
 
19
18
  context 'with non default coverage expectation' do
20
- with(:config) { { expected_coverage: 0.1r } }
21
-
22
19
  it_reports(<<-REPORT)
23
20
  Mutant configuration:
24
21
  Matcher: #<Mutant::Matcher::Config empty>
25
22
  Integration: Mutant::Integration::Null
26
- Expect Coverage: 10.00%
27
23
  Jobs: 1
28
24
  Includes: []
29
25
  Requires: []
@@ -1,8 +1,6 @@
1
1
  RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do
2
2
  setup_shared_context
3
3
 
4
- with(:config) { { expected_coverage: 0.1r } }
5
-
6
4
  let(:reportable) { env_result }
7
5
 
8
6
  describe '.call' do
@@ -13,7 +11,6 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do
13
11
  Mutant configuration:
14
12
  Matcher: #<Mutant::Matcher::Config empty>
15
13
  Integration: Mutant::Integration::Null
16
- Expect Coverage: 10.00%
17
14
  Jobs: 1
18
15
  Includes: []
19
16
  Requires: []
@@ -27,7 +24,6 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do
27
24
  Overhead: Inf%
28
25
  Mutations/s: 0.00
29
26
  Coverage: 100.00%
30
- Expected: 10.00%
31
27
  STR
32
28
  end
33
29
 
@@ -36,7 +32,6 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do
36
32
  Mutant configuration:
37
33
  Matcher: #<Mutant::Matcher::Config empty>
38
34
  Integration: Mutant::Integration::Null
39
- Expect Coverage: 10.00%
40
35
  Jobs: 1
41
36
  Includes: []
42
37
  Requires: []
@@ -50,7 +45,6 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do
50
45
  Overhead: 100.00%
51
46
  Mutations/s: 0.50
52
47
  Coverage: 100.00%
53
- Expected: 10.00%
54
48
  STR
55
49
  end
56
50
 
@@ -61,7 +55,6 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do
61
55
  Mutant configuration:
62
56
  Matcher: #<Mutant::Matcher::Config empty>
63
57
  Integration: Mutant::Integration::Null
64
- Expect Coverage: 10.00%
65
58
  Jobs: 1
66
59
  Includes: []
67
60
  Requires: []
@@ -75,7 +68,6 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do
75
68
  Overhead: 100.00%
76
69
  Mutations/s: 0.50
77
70
  Coverage: 50.00%
78
- Expected: 10.00%
79
71
  STR
80
72
  end
81
73
  end
@@ -17,7 +17,6 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvResult do
17
17
  Mutant configuration:
18
18
  Matcher: #<Mutant::Matcher::Config empty>
19
19
  Integration: Mutant::Integration::Null
20
- Expect Coverage: 100.00%
21
20
  Jobs: 1
22
21
  Includes: []
23
22
  Requires: []
@@ -31,7 +30,6 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvResult do
31
30
  Overhead: 100.00%
32
31
  Mutations/s: 0.50
33
32
  Coverage: 50.00%
34
- Expected: 100.00%
35
33
  STR
36
34
  end
37
35
  end