mutant 0.9.4 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +121 -0
  3. data/Changelog.md +26 -0
  4. data/Gemfile +0 -15
  5. data/Gemfile.lock +47 -58
  6. data/Gemfile.shared +7 -0
  7. data/LICENSE +1 -1
  8. data/README.md +72 -23
  9. data/config/reek.yml +1 -0
  10. data/config/rubocop.yml +10 -3
  11. data/docs/commercial-support.md +14 -0
  12. data/lib/mutant.rb +5 -1
  13. data/lib/mutant/ast.rb +0 -9
  14. data/lib/mutant/ast/find_metaclass_containing.rb +48 -0
  15. data/lib/mutant/ast/meta/send.rb +0 -6
  16. data/lib/mutant/bootstrap.rb +0 -36
  17. data/lib/mutant/cli.rb +6 -50
  18. data/lib/mutant/color.rb +0 -3
  19. data/lib/mutant/config.rb +0 -8
  20. data/lib/mutant/context.rb +0 -3
  21. data/lib/mutant/diff.rb +0 -17
  22. data/lib/mutant/env.rb +0 -6
  23. data/lib/mutant/expression/method.rb +6 -6
  24. data/lib/mutant/expression/methods.rb +6 -6
  25. data/lib/mutant/expression/parser.rb +0 -6
  26. data/lib/mutant/integration.rb +0 -18
  27. data/lib/mutant/isolation/fork.rb +0 -22
  28. data/lib/mutant/license.rb +12 -1
  29. data/lib/mutant/matcher.rb +0 -14
  30. data/lib/mutant/matcher/config.rb +0 -11
  31. data/lib/mutant/matcher/method.rb +0 -31
  32. data/lib/mutant/matcher/method/instance.rb +0 -8
  33. data/lib/mutant/matcher/method/metaclass.rb +86 -0
  34. data/lib/mutant/matcher/method/singleton.rb +0 -25
  35. data/lib/mutant/matcher/methods.rb +17 -28
  36. data/lib/mutant/matcher/namespace.rb +0 -10
  37. data/lib/mutant/matcher/scope.rb +2 -4
  38. data/lib/mutant/meta.rb +1 -3
  39. data/lib/mutant/meta/example/dsl.rb +0 -21
  40. data/lib/mutant/meta/example/verification.rb +1 -21
  41. data/lib/mutant/mutation.rb +0 -3
  42. data/lib/mutant/mutator.rb +1 -29
  43. data/lib/mutant/mutator/node.rb +1 -66
  44. data/lib/mutant/mutator/node/and_asgn.rb +0 -3
  45. data/lib/mutant/mutator/node/argument.rb +0 -15
  46. data/lib/mutant/mutator/node/arguments.rb +0 -20
  47. data/lib/mutant/mutator/node/begin.rb +0 -3
  48. data/lib/mutant/mutator/node/binary.rb +0 -23
  49. data/lib/mutant/mutator/node/block.rb +0 -15
  50. data/lib/mutant/mutator/node/break.rb +0 -3
  51. data/lib/mutant/mutator/node/case.rb +0 -9
  52. data/lib/mutant/mutator/node/class.rb +0 -3
  53. data/lib/mutant/mutator/node/conditional_loop.rb +0 -3
  54. data/lib/mutant/mutator/node/const.rb +0 -3
  55. data/lib/mutant/mutator/node/define.rb +0 -11
  56. data/lib/mutant/mutator/node/defined.rb +0 -3
  57. data/lib/mutant/mutator/node/dstr.rb +0 -3
  58. data/lib/mutant/mutator/node/dsym.rb +0 -3
  59. data/lib/mutant/mutator/node/generic.rb +0 -51
  60. data/lib/mutant/mutator/node/if.rb +0 -12
  61. data/lib/mutant/mutator/node/index.rb +0 -27
  62. data/lib/mutant/mutator/node/kwbegin.rb +0 -3
  63. data/lib/mutant/mutator/node/literal.rb +0 -3
  64. data/lib/mutant/mutator/node/literal/array.rb +0 -6
  65. data/lib/mutant/mutator/node/literal/boolean.rb +0 -4
  66. data/lib/mutant/mutator/node/literal/float.rb +0 -9
  67. data/lib/mutant/mutator/node/literal/hash.rb +0 -9
  68. data/lib/mutant/mutator/node/literal/integer.rb +0 -9
  69. data/lib/mutant/mutator/node/literal/nil.rb +0 -3
  70. data/lib/mutant/mutator/node/literal/range.rb +0 -6
  71. data/lib/mutant/mutator/node/literal/regex.rb +0 -6
  72. data/lib/mutant/mutator/node/literal/string.rb +0 -3
  73. data/lib/mutant/mutator/node/literal/symbol.rb +0 -3
  74. data/lib/mutant/mutator/node/masgn.rb +0 -3
  75. data/lib/mutant/mutator/node/match_current_line.rb +0 -3
  76. data/lib/mutant/mutator/node/mlhs.rb +0 -3
  77. data/lib/mutant/mutator/node/named_value/access.rb +2 -14
  78. data/lib/mutant/mutator/node/named_value/constant_assignment.rb +0 -9
  79. data/lib/mutant/mutator/node/named_value/variable_assignment.rb +0 -6
  80. data/lib/mutant/mutator/node/next.rb +0 -3
  81. data/lib/mutant/mutator/node/noop.rb +0 -3
  82. data/lib/mutant/mutator/node/nthref.rb +0 -3
  83. data/lib/mutant/mutator/node/op_asgn.rb +0 -3
  84. data/lib/mutant/mutator/node/or_asgn.rb +0 -3
  85. data/lib/mutant/mutator/node/procarg_zero.rb +0 -3
  86. data/lib/mutant/mutator/node/regopt.rb +0 -6
  87. data/lib/mutant/mutator/node/resbody.rb +0 -6
  88. data/lib/mutant/mutator/node/rescue.rb +2 -19
  89. data/lib/mutant/mutator/node/return.rb +0 -3
  90. data/lib/mutant/mutator/node/sclass.rb +20 -0
  91. data/lib/mutant/mutator/node/send.rb +3 -62
  92. data/lib/mutant/mutator/node/send/attribute_assignment.rb +0 -9
  93. data/lib/mutant/mutator/node/send/binary.rb +0 -11
  94. data/lib/mutant/mutator/node/send/conditional.rb +0 -3
  95. data/lib/mutant/mutator/node/splat.rb +0 -3
  96. data/lib/mutant/mutator/node/super.rb +0 -3
  97. data/lib/mutant/mutator/node/when.rb +0 -19
  98. data/lib/mutant/mutator/node/yield.rb +0 -3
  99. data/lib/mutant/mutator/node/zsuper.rb +0 -3
  100. data/lib/mutant/mutator/util/array.rb +0 -6
  101. data/lib/mutant/mutator/util/symbol.rb +0 -3
  102. data/lib/mutant/parallel.rb +0 -13
  103. data/lib/mutant/parallel/driver.rb +0 -10
  104. data/lib/mutant/parallel/worker.rb +0 -22
  105. data/lib/mutant/registry.rb +2 -7
  106. data/lib/mutant/reporter/cli.rb +0 -5
  107. data/lib/mutant/reporter/cli/format.rb +1 -10
  108. data/lib/mutant/reporter/cli/printer.rb +0 -40
  109. data/lib/mutant/reporter/cli/printer/env_progress.rb +0 -15
  110. data/lib/mutant/reporter/cli/printer/isolation_result.rb +0 -18
  111. data/lib/mutant/reporter/cli/printer/mutation_progress_result.rb +0 -5
  112. data/lib/mutant/reporter/cli/printer/mutation_result.rb +0 -21
  113. data/lib/mutant/reporter/cli/printer/status_progressive.rb +0 -8
  114. data/lib/mutant/reporter/cli/printer/subject_progress.rb +0 -9
  115. data/lib/mutant/repository/diff.rb +1 -13
  116. data/lib/mutant/repository/diff/ranges.rb +0 -11
  117. data/lib/mutant/result.rb +0 -3
  118. data/lib/mutant/runner.rb +0 -18
  119. data/lib/mutant/runner/sink.rb +0 -5
  120. data/lib/mutant/subject.rb +0 -8
  121. data/lib/mutant/subject/method.rb +0 -3
  122. data/lib/mutant/subject/method/instance.rb +0 -5
  123. data/lib/mutant/subject/method/metaclass.rb +30 -0
  124. data/lib/mutant/transform.rb +0 -92
  125. data/lib/mutant/version.rb +1 -1
  126. data/lib/mutant/warnings.rb +0 -6
  127. data/lib/mutant/zombifier.rb +4 -34
  128. data/meta/and.rb +0 -2
  129. data/meta/array.rb +0 -3
  130. data/meta/begin.rb +0 -3
  131. data/meta/block.rb +0 -3
  132. data/meta/break.rb +0 -1
  133. data/meta/case.rb +0 -6
  134. data/meta/casgn.rb +0 -3
  135. data/meta/cvasgn.rb +0 -1
  136. data/meta/def.rb +0 -7
  137. data/meta/ensure.rb +0 -1
  138. data/meta/false.rb +0 -1
  139. data/meta/gvasgn.rb +0 -1
  140. data/meta/hash.rb +0 -4
  141. data/meta/if.rb +0 -5
  142. data/meta/ivasgn.rb +0 -1
  143. data/meta/kwbegin.rb +0 -1
  144. data/meta/lvasgn.rb +0 -1
  145. data/meta/match_current_line.rb +0 -1
  146. data/meta/next.rb +0 -1
  147. data/meta/or.rb +0 -2
  148. data/meta/regexp.rb +0 -1
  149. data/meta/rescue.rb +0 -6
  150. data/meta/sclass.rb +12 -0
  151. data/meta/send.rb +0 -4
  152. data/meta/true.rb +0 -1
  153. data/meta/until.rb +0 -1
  154. data/meta/while.rb +0 -2
  155. data/meta/yield.rb +0 -1
  156. data/mutant.gemspec +4 -3
  157. data/mutant.sh +12 -0
  158. data/spec/integrations.yml +3 -1
  159. data/spec/support/corpus.rb +3 -3
  160. data/spec/support/ruby_vm.rb +1 -2
  161. data/spec/support/shared_context.rb +3 -3
  162. data/spec/support/xspec.rb +2 -2
  163. data/spec/unit/mutant/ast/find_metaclass_containing_spec.rb +64 -0
  164. data/spec/unit/mutant/expression/methods_spec.rb +7 -2
  165. data/spec/unit/mutant/license_spec.rb +17 -5
  166. data/spec/unit/mutant/matcher/method/metaclass_spec.rb +108 -0
  167. data/spec/unit/mutant/matcher/methods/metaclass_spec.rb +62 -0
  168. data/spec/unit/mutant/matcher/namespace_spec.rb +3 -1
  169. data/spec/unit/mutant/matcher/scope_spec.rb +11 -1
  170. data/spec/unit/mutant/meta/example_spec.rb +3 -3
  171. data/spec/unit/mutant/mutator/node_spec.rb +1 -6
  172. data/spec/unit/mutant/parallel/driver_spec.rb +4 -4
  173. data/spec/unit/mutant/parallel/worker_spec.rb +5 -5
  174. data/spec/unit/mutant/parallel_spec.rb +7 -7
  175. data/spec/unit/mutant/registry_spec.rb +52 -25
  176. data/spec/unit/mutant/repository/diff/ranges_spec.rb +2 -2
  177. data/spec/unit/mutant/subject/method/metaclass_spec.rb +63 -0
  178. data/test_app/lib/test_app.rb +1 -0
  179. data/test_app/lib/test_app/metaclasses.rb +108 -0
  180. metadata +43 -16
  181. data/.circleci/config.yml +0 -53
  182. data/lib/mutant/variable.rb +0 -282
  183. data/spec/unit/mutant/variable_spec.rb +0 -618
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.9.4
4
+ version: 0.9.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-04 00:00:00.000000000 Z
11
+ date: 2020-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: abstract_type
@@ -84,14 +84,14 @@ dependencies:
84
84
  name: diff-lcs
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - '='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.3'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - '='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.3'
97
97
  - !ruby/object:Gem::Dependency
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 2.6.5
159
+ version: 2.7.1
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 2.6.5
166
+ version: 2.7.1
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: procto
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -192,20 +192,34 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: 0.4.6
195
+ - !ruby/object:Gem::Dependency
196
+ name: variable
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: 0.0.1
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: 0.0.1
195
209
  - !ruby/object:Gem::Dependency
196
210
  name: devtools
197
211
  requirement: !ruby/object:Gem::Requirement
198
212
  requirements:
199
213
  - - "~>"
200
214
  - !ruby/object:Gem::Version
201
- version: 0.1.23
215
+ version: 0.1.25
202
216
  type: :development
203
217
  prerelease: false
204
218
  version_requirements: !ruby/object:Gem::Requirement
205
219
  requirements:
206
220
  - - "~>"
207
221
  - !ruby/object:Gem::Version
208
- version: 0.1.23
222
+ version: 0.1.25
209
223
  - !ruby/object:Gem::Dependency
210
224
  name: parallel
211
225
  requirement: !ruby/object:Gem::Requirement
@@ -229,7 +243,7 @@ extensions: []
229
243
  extra_rdoc_files:
230
244
  - LICENSE
231
245
  files:
232
- - ".circleci/config.yml"
246
+ - ".github/workflows/ci.yml"
233
247
  - ".gitignore"
234
248
  - ".rspec"
235
249
  - ".rubocop.yml"
@@ -245,6 +259,7 @@ files:
245
259
  - config/reek.yml
246
260
  - config/rubocop.yml
247
261
  - config/yardstick.yml
262
+ - docs/commercial-support.md
248
263
  - docs/concurrency.md
249
264
  - docs/incremental.md
250
265
  - docs/known-problems.md
@@ -255,6 +270,7 @@ files:
255
270
  - docs/reading-reports.md
256
271
  - lib/mutant.rb
257
272
  - lib/mutant/ast.rb
273
+ - lib/mutant/ast/find_metaclass_containing.rb
258
274
  - lib/mutant/ast/meta.rb
259
275
  - lib/mutant/ast/meta/const.rb
260
276
  - lib/mutant/ast/meta/optarg.rb
@@ -294,6 +310,7 @@ files:
294
310
  - lib/mutant/matcher/filter.rb
295
311
  - lib/mutant/matcher/method.rb
296
312
  - lib/mutant/matcher/method/instance.rb
313
+ - lib/mutant/matcher/method/metaclass.rb
297
314
  - lib/mutant/matcher/method/singleton.rb
298
315
  - lib/mutant/matcher/methods.rb
299
316
  - lib/mutant/matcher/namespace.rb
@@ -353,6 +370,7 @@ files:
353
370
  - lib/mutant/mutator/node/resbody.rb
354
371
  - lib/mutant/mutator/node/rescue.rb
355
372
  - lib/mutant/mutator/node/return.rb
373
+ - lib/mutant/mutator/node/sclass.rb
356
374
  - lib/mutant/mutator/node/send.rb
357
375
  - lib/mutant/mutator/node/send/attribute_assignment.rb
358
376
  - lib/mutant/mutator/node/send/binary.rb
@@ -403,12 +421,12 @@ files:
403
421
  - lib/mutant/subject.rb
404
422
  - lib/mutant/subject/method.rb
405
423
  - lib/mutant/subject/method/instance.rb
424
+ - lib/mutant/subject/method/metaclass.rb
406
425
  - lib/mutant/subject/method/singleton.rb
407
426
  - lib/mutant/test.rb
408
427
  - lib/mutant/timer.rb
409
428
  - lib/mutant/transform.rb
410
429
  - lib/mutant/util.rb
411
- - lib/mutant/variable.rb
412
430
  - lib/mutant/version.rb
413
431
  - lib/mutant/warnings.rb
414
432
  - lib/mutant/zombifier.rb
@@ -467,6 +485,7 @@ files:
467
485
  - meta/regopt.rb
468
486
  - meta/rescue.rb
469
487
  - meta/return.rb
488
+ - meta/sclass.rb
470
489
  - meta/self.rb
471
490
  - meta/send.rb
472
491
  - meta/str.rb
@@ -479,6 +498,7 @@ files:
479
498
  - mutant-minitest.gemspec
480
499
  - mutant-rspec.gemspec
481
500
  - mutant.gemspec
501
+ - mutant.sh
482
502
  - mutant.yml
483
503
  - spec/integration/mutant/corpus_spec.rb
484
504
  - spec/integration/mutant/isolation/fork_spec.rb
@@ -499,6 +519,7 @@ files:
499
519
  - spec/support/test_app.rb
500
520
  - spec/support/warnings.yml
501
521
  - spec/support/xspec.rb
522
+ - spec/unit/mutant/ast/find_metaclass_containing_spec.rb
502
523
  - spec/unit/mutant/ast/meta/optarg_spec.rb
503
524
  - spec/unit/mutant/ast/meta/send/proc_predicate_spec.rb
504
525
  - spec/unit/mutant/ast/meta/send/receiver_possible_top_level_const_predicate_spec.rb
@@ -531,8 +552,10 @@ files:
531
552
  - spec/unit/mutant/matcher/config_spec.rb
532
553
  - spec/unit/mutant/matcher/filter_spec.rb
533
554
  - spec/unit/mutant/matcher/method/instance_spec.rb
555
+ - spec/unit/mutant/matcher/method/metaclass_spec.rb
534
556
  - spec/unit/mutant/matcher/method/singleton_spec.rb
535
557
  - spec/unit/mutant/matcher/methods/instance_spec.rb
558
+ - spec/unit/mutant/matcher/methods/metaclass_spec.rb
536
559
  - spec/unit/mutant/matcher/methods/singleton_spec.rb
537
560
  - spec/unit/mutant/matcher/namespace_spec.rb
538
561
  - spec/unit/mutant/matcher/null_spec.rb
@@ -581,6 +604,7 @@ files:
581
604
  - spec/unit/mutant/selector/expression_spec.rb
582
605
  - spec/unit/mutant/selector/null_spec.rb
583
606
  - spec/unit/mutant/subject/method/instance_spec.rb
607
+ - spec/unit/mutant/subject/method/metaclass_spec.rb
584
608
  - spec/unit/mutant/subject/method/singleton_spec.rb
585
609
  - spec/unit/mutant/subject_spec.rb
586
610
  - spec/unit/mutant/transform/array_spec.rb
@@ -593,7 +617,6 @@ files:
593
617
  - spec/unit/mutant/transform/primitive_spec.rb
594
618
  - spec/unit/mutant/transform/sequence_spec.rb
595
619
  - spec/unit/mutant/util/one_spec.rb
596
- - spec/unit/mutant/variable_spec.rb
597
620
  - spec/unit/mutant/warnings_spec.rb
598
621
  - spec/unit/mutant/world_spec.rb
599
622
  - spec/unit/mutant/zombifier_spec.rb
@@ -602,6 +625,7 @@ files:
602
625
  - test_app/Gemfile.rspec3.8
603
626
  - test_app/lib/test_app.rb
604
627
  - test_app/lib/test_app/literal.rb
628
+ - test_app/lib/test_app/metaclasses.rb
605
629
  - test_app/spec/spec_helper.rb
606
630
  - test_app/spec/unit/test_app/literal_spec.rb
607
631
  - test_app/test/unit/test_app/literal_test.rb
@@ -609,7 +633,7 @@ homepage: https://github.com/mbj/mutant
609
633
  licenses:
610
634
  - Nonstandard
611
635
  metadata: {}
612
- post_install_message:
636
+ post_install_message:
613
637
  rdoc_options: []
614
638
  require_paths:
615
639
  - lib
@@ -624,8 +648,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
624
648
  - !ruby/object:Gem::Version
625
649
  version: '0'
626
650
  requirements: []
627
- rubygems_version: 3.0.6
628
- signing_key:
651
+ rubygems_version: 3.1.2
652
+ signing_key:
629
653
  specification_version: 4
630
654
  summary: ''
631
655
  test_files:
@@ -635,6 +659,7 @@ test_files:
635
659
  - spec/integration/mutant/null_spec.rb
636
660
  - spec/integration/mutant/rspec_spec.rb
637
661
  - spec/integration/mutant/test_mutator_handles_types_spec.rb
662
+ - spec/unit/mutant/ast/find_metaclass_containing_spec.rb
638
663
  - spec/unit/mutant/ast/meta/optarg_spec.rb
639
664
  - spec/unit/mutant/ast/meta/send/proc_predicate_spec.rb
640
665
  - spec/unit/mutant/ast/meta/send/receiver_possible_top_level_const_predicate_spec.rb
@@ -667,8 +692,10 @@ test_files:
667
692
  - spec/unit/mutant/matcher/config_spec.rb
668
693
  - spec/unit/mutant/matcher/filter_spec.rb
669
694
  - spec/unit/mutant/matcher/method/instance_spec.rb
695
+ - spec/unit/mutant/matcher/method/metaclass_spec.rb
670
696
  - spec/unit/mutant/matcher/method/singleton_spec.rb
671
697
  - spec/unit/mutant/matcher/methods/instance_spec.rb
698
+ - spec/unit/mutant/matcher/methods/metaclass_spec.rb
672
699
  - spec/unit/mutant/matcher/methods/singleton_spec.rb
673
700
  - spec/unit/mutant/matcher/namespace_spec.rb
674
701
  - spec/unit/mutant/matcher/null_spec.rb
@@ -717,6 +744,7 @@ test_files:
717
744
  - spec/unit/mutant/selector/expression_spec.rb
718
745
  - spec/unit/mutant/selector/null_spec.rb
719
746
  - spec/unit/mutant/subject/method/instance_spec.rb
747
+ - spec/unit/mutant/subject/method/metaclass_spec.rb
720
748
  - spec/unit/mutant/subject/method/singleton_spec.rb
721
749
  - spec/unit/mutant/subject_spec.rb
722
750
  - spec/unit/mutant/transform/array_spec.rb
@@ -729,7 +757,6 @@ test_files:
729
757
  - spec/unit/mutant/transform/primitive_spec.rb
730
758
  - spec/unit/mutant/transform/sequence_spec.rb
731
759
  - spec/unit/mutant/util/one_spec.rb
732
- - spec/unit/mutant/variable_spec.rb
733
760
  - spec/unit/mutant/warnings_spec.rb
734
761
  - spec/unit/mutant/world_spec.rb
735
762
  - spec/unit/mutant/zombifier_spec.rb
@@ -1,53 +0,0 @@
1
- defaults: &defaults
2
- working_directory: ~/mutant
3
- docker:
4
- - image: circleci/ruby:2.6.0
5
- version: 2
6
- jobs:
7
- unit_specs:
8
- <<: *defaults
9
- steps:
10
- - checkout
11
- - run: bundle install
12
- - run: bundle exec rspec spec/unit spec/integration/mutant/test_mutator_handles_types_spec.rb
13
- integration_minitest:
14
- <<: *defaults
15
- steps:
16
- - checkout
17
- - run: bundle install
18
- - run: bundle exec rspec spec/integration -e minitest
19
- integration_rspec:
20
- <<: *defaults
21
- steps:
22
- - checkout
23
- - run: bundle install
24
- - run: bundle exec rspec spec/integration -e rspec
25
- integration_mutation_generation:
26
- <<: *defaults
27
- steps:
28
- - checkout
29
- - run: bundle install
30
- - run: bundle exec rspec spec/integration -e generation
31
- metrics:
32
- <<: *defaults
33
- steps:
34
- - checkout
35
- - run: bundle install
36
- - run: bundle exec rake metrics:rubocop
37
- - run: bundle exec rake metrics:reek
38
- mutant:
39
- <<: *defaults
40
- steps:
41
- - checkout
42
- - run: bundle install
43
- - run: bundle exec mutant --jobs 4 --since HEAD~1 --zombie -- 'Mutant*'
44
- workflows:
45
- version: 2
46
- test:
47
- jobs:
48
- - unit_specs
49
- - integration_rspec
50
- - integration_minitest
51
- - integration_mutation_generation
52
- - metrics
53
- - mutant
@@ -1,282 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mutant
4
- # Lightweight shared variables
5
- #
6
- # ignore :reek:TooManyMethods
7
- class Variable
8
- EMPTY = Class.new do
9
- const_set(:INSPECT, 'Mutant::Variable::EMPTY')
10
- end.new.freeze
11
-
12
- TIMEOUT = Class.new do
13
- const_set(:INSPECT, 'Mutant::Variable::TIMEOUT')
14
- end.new.freeze
15
-
16
- # Result of operation that may time out
17
- class Result
18
- include AbstractType, Adamantium::Flat
19
-
20
- # Test if take resulted in a timeout
21
- #
22
- # @return [Boolean]
23
- #
24
- # @api private
25
- def timeout?
26
- instance_of?(Timeout)
27
- end
28
-
29
- abstract_method :value
30
-
31
- # Instance returned on timeouts
32
- class Timeout < self
33
- include Equalizer.new
34
-
35
- INSTANCE = new
36
-
37
- # Construct new object
38
- #
39
- # @return [Timeout]
40
- def self.new
41
- INSTANCE
42
- end
43
- end # Timeout
44
-
45
- # Instance returned without timeouts
46
- class Value < self
47
- include Concord::Public.new(:value)
48
- end # Value
49
- end # Result
50
-
51
- private_constant(*constants(false))
52
-
53
- # Initialize object
54
- #
55
- # @param [Object] value
56
- # the initial value
57
- #
58
- # @return [undefined]
59
- def initialize(condition_variable:, mutex:, value: EMPTY)
60
- @full = condition_variable.new
61
- @mutex = mutex.new
62
- @value = value
63
- end
64
-
65
- # Take value from mvar, block on empty
66
- #
67
- # @return [Object]
68
- def take
69
- synchronize do
70
- wait_full
71
- perform_take
72
- end
73
- end
74
-
75
- # Take value from mvar, with timeout
76
- #
77
- # @param [Float] Timeout
78
- #
79
- # @return [Result::Timeout]
80
- # in case take resulted in a timeout
81
- #
82
- # @return [Result::Value]
83
- # in case take resulted in a value
84
- def take_timeout(timeout)
85
- synchronize do
86
- if wait_timeout(@full, timeout, &method(:full?))
87
- Result::Timeout.new
88
- else
89
- Result::Value.new(perform_take)
90
- end
91
- end
92
- end
93
-
94
- # Read value from variable
95
- #
96
- # @return [Object]
97
- # the contents of the mvar
98
- def read
99
- synchronize do
100
- wait_full
101
- @value
102
- end
103
- end
104
-
105
- # Try put value into the variable, non blocking
106
- #
107
- # @param [Object] value
108
- #
109
- # @return [self]
110
- def try_put(value)
111
- synchronize do
112
- perform_put(value) if empty?
113
- end
114
-
115
- self
116
- end
117
-
118
- # Execute block with value, blocking
119
- #
120
- # @yield [Object]
121
- #
122
- # @return [Object]
123
- # the blocks return value
124
- def with
125
- synchronize do
126
- wait_full
127
- yield @value
128
- end
129
- end
130
-
131
- private
132
-
133
- # Perform the put
134
- #
135
- # @param [Object] value
136
- def perform_put(value)
137
- (@value = value).tap { @full.signal }
138
- end
139
-
140
- # Execute block under mutex
141
- #
142
- # @return [self]
143
- def synchronize(&block)
144
- @mutex.synchronize(&block)
145
- end
146
-
147
- # Wait for block predicate
148
- #
149
- # @param [ConditionVariable] event
150
- #
151
- # @return [undefined]
152
- def wait(event)
153
- event.wait(@mutex) until yield
154
- end
155
-
156
- # Wait with timeout for block predicate
157
- #
158
- # @param [ConditionVariable] event
159
- #
160
- # @return [Boolean]
161
- # if wait was terminated due a timeout
162
- #
163
- # @return [undefined]
164
- # otherwise
165
- def wait_timeout(event, timeout)
166
- loop do
167
- break true if timeout <= 0
168
- break if yield
169
- timeout -= Timer.elapsed { event.wait(@mutex, timeout) }
170
- end
171
- end
172
-
173
- # Wait till mvar is full
174
- #
175
- # @return [undefined]
176
- def wait_full
177
- wait(@full, &method(:full?))
178
- end
179
-
180
- # Test if state is full
181
- #
182
- # @return [Boolean]
183
- def full?
184
- !empty?
185
- end
186
-
187
- # Test if state is empty
188
- #
189
- # @return [Boolean]
190
- def empty?
191
- @value.equal?(EMPTY)
192
- end
193
-
194
- # Shared variable that can be written at most once
195
- #
196
- # ignore :reek:InstanceVariableAssumption
197
- class IVar < self
198
-
199
- # Exception raised on ivar errors
200
- class Error < RuntimeError; end
201
-
202
- # Put valie into the mvar, raises if already full
203
- #
204
- # @param [Object] value
205
- #
206
- # @return [self]
207
- #
208
- # @raise Error
209
- # if already full
210
- def put(value)
211
- synchronize do
212
- fail Error, 'is immutable' if full?
213
- perform_put(value)
214
- end
215
-
216
- self
217
- end
218
-
219
- private
220
-
221
- # Perform take operation
222
- #
223
- # @return [Object]
224
- def perform_take
225
- @value
226
- end
227
- end # IVar
228
-
229
- # Shared variable that can be written multiple times
230
- #
231
- # ignore :reek:InstanceVariableAssumption
232
- class MVar < self
233
-
234
- # Initialize object
235
- #
236
- # @param [Object] value
237
- # the initial value
238
- #
239
- # @return [undefined]
240
- def initialize(condition_variable:, mutex:, value: EMPTY)
241
- super
242
- @empty = condition_variable.new
243
- end
244
-
245
- # Put value into mvar, block on full
246
- #
247
- # @param [Object] value
248
- #
249
- # @return [self]
250
- def put(value)
251
- synchronize do
252
- wait(@empty, &method(:empty?))
253
- perform_put(value)
254
- end
255
-
256
- self
257
- end
258
-
259
- # Modify mvar
260
- #
261
- # @return [Object]
262
- def modify
263
- synchronize do
264
- wait_full
265
- perform_put(yield(@value))
266
- end
267
- end
268
-
269
- private
270
-
271
- # Empty the mvar
272
- #
273
- # @return [Object]
274
- def perform_take
275
- @value.tap do
276
- @value = EMPTY
277
- @empty.signal
278
- end
279
- end
280
- end # MVar
281
- end # Variable
282
- end # Mutant