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
@@ -1,4 +1,4 @@
1
- Mutant::Meta::Example.add do
1
+ Mutant::Meta::Example.add :int do
2
2
  source '10'
3
3
 
4
4
  singleton_mutations
@@ -1,4 +1,4 @@
1
- Mutant::Meta::Example.add do
1
+ Mutant::Meta::Example.add :ivar do
2
2
  source '@foo'
3
3
 
4
4
  singleton_mutations
@@ -1,4 +1,4 @@
1
- Mutant::Meta::Example.add do
1
+ Mutant::Meta::Example.add :ivasgn do
2
2
  source '@a = true'
3
3
 
4
4
  singleton_mutations
@@ -6,3 +6,16 @@ Mutant::Meta::Example.add do
6
6
  mutation '@a = false'
7
7
  mutation '@a = nil'
8
8
  end
9
+
10
+ Mutant::Meta::Example.add :ivasgn do
11
+ source '@a &&= 1'
12
+
13
+ singleton_mutations
14
+
15
+ mutation '@a__mutant__ &&= 1'
16
+ mutation '@a &&= nil'
17
+ mutation '@a &&= 0'
18
+ mutation '@a &&= -1'
19
+ mutation '@a &&= 2'
20
+ mutation '@a &&= self'
21
+ end
@@ -0,0 +1,8 @@
1
+ Mutant::Meta::Example.add :kwarg do
2
+ source 'def foo(bar:); end'
3
+
4
+ mutation 'def foo; end'
5
+ mutation 'def foo(bar:); raise; end'
6
+ mutation 'remove_method(:foo)'
7
+ mutation 'def foo(_bar:); end'
8
+ end
@@ -1,4 +1,4 @@
1
- Mutant::Meta::Example.add do
1
+ Mutant::Meta::Example.add :kwbegin do
2
2
  source 'begin; true; end'
3
3
 
4
4
  singleton_mutations
@@ -0,0 +1,11 @@
1
+ Mutant::Meta::Example.add :kwarg do
2
+ source 'def foo(bar: baz); end'
3
+
4
+ mutation 'def foo; end'
5
+ mutation 'def foo(bar: baz); raise; end'
6
+ mutation 'remove_method(:foo)'
7
+ mutation 'def foo(bar: nil); end'
8
+ mutation 'def foo(bar: self); end'
9
+ mutation 'def foo(bar:); end'
10
+ mutation 'def foo(_bar: baz); end'
11
+ end
@@ -1,4 +1,4 @@
1
- Mutant::Meta::Example.add do
1
+ Mutant::Meta::Example.add :lvar do
2
2
  source 'a = nil; a'
3
3
 
4
4
  mutation 'a = nil; nil'
@@ -1,4 +1,4 @@
1
- Mutant::Meta::Example.add do
1
+ Mutant::Meta::Example.add :lvasgn do
2
2
  source 'a = true'
3
3
 
4
4
  singleton_mutations
@@ -1,4 +1,4 @@
1
- Mutant::Meta::Example.add do
1
+ Mutant::Meta::Example.add :masgn do
2
2
  source 'a, b = c, d'
3
3
 
4
4
  singleton_mutations
@@ -1,4 +1,4 @@
1
- Mutant::Meta::Example.add do
1
+ Mutant::Meta::Example.add :match_current_line do
2
2
  source 'true if /foo/'
3
3
 
4
4
  singleton_mutations
@@ -8,6 +8,6 @@ Mutant::Meta::Example.add do
8
8
  mutation 'true if true'
9
9
  mutation 'true if false'
10
10
  mutation 'true if nil'
11
- mutation 'true if /a\A/'
11
+ mutation 'true if /nomatch\A/'
12
12
  mutation 'true'
13
13
  end
@@ -1,4 +1,4 @@
1
- Mutant::Meta::Example.add do
1
+ Mutant::Meta::Example.add :next do
2
2
  source 'next true'
3
3
 
4
4
  singleton_mutations
@@ -1,3 +1,3 @@
1
- Mutant::Meta::Example.add do
1
+ Mutant::Meta::Example.add :nil do
2
2
  source 'nil'
3
3
  end
@@ -1,12 +1,12 @@
1
- Mutant::Meta::Example.add do
1
+ Mutant::Meta::Example.add :nth_ref do
2
2
  source '$1'
3
3
 
4
4
  mutation '$2'
5
5
  end
6
6
 
7
- Mutant::Meta::Example.add do
8
- source '$2'
7
+ Mutant::Meta::Example.add :nth_ref do
8
+ source '$3'
9
9
 
10
- mutation '$3'
11
- mutation '$1'
10
+ mutation '$2'
11
+ mutation '$4'
12
12
  end
@@ -1,4 +1,4 @@
1
- Mutant::Meta::Example.add do
1
+ Mutant::Meta::Example.add :op_asgn do
2
2
  source '@a.b += 1'
3
3
 
4
4
  singleton_mutations
data/meta/or.rb CHANGED
@@ -1,4 +1,4 @@
1
- Mutant::Meta::Example.add do
1
+ Mutant::Meta::Example.add :or do
2
2
  source 'true or false'
3
3
 
4
4
  singleton_mutations
@@ -1,4 +1,4 @@
1
- Mutant::Meta::Example.add do
1
+ Mutant::Meta::Example.add :or_asgn do
2
2
  source 'a ||= 1'
3
3
 
4
4
  singleton_mutations
@@ -10,7 +10,7 @@ Mutant::Meta::Example.add do
10
10
  mutation 'a ||= 2'
11
11
  end
12
12
 
13
- Mutant::Meta::Example.add do
13
+ Mutant::Meta::Example.add :or_asgn do
14
14
  source '@a ||= 1'
15
15
 
16
16
  singleton_mutations
@@ -21,13 +21,13 @@ Mutant::Meta::Example.add do
21
21
  mutation '@a ||= 2'
22
22
  end
23
23
 
24
- Mutant::Meta::Example.add do
24
+ Mutant::Meta::Example.add :or_asgn do
25
25
  source 'Foo ||= nil'
26
26
 
27
27
  singleton_mutations
28
28
  end
29
29
 
30
- Mutant::Meta::Example.add do
30
+ Mutant::Meta::Example.add :or_asgn do
31
31
  source '@a ||= self.bar'
32
32
 
33
33
  singleton_mutations
@@ -36,7 +36,7 @@ Mutant::Meta::Example.add do
36
36
  mutation '@a ||= bar'
37
37
  end
38
38
 
39
- Mutant::Meta::Example.add do
39
+ Mutant::Meta::Example.add :or_asgn do
40
40
  source 'foo[:bar] ||= 1'
41
41
 
42
42
  singleton_mutations
@@ -1,11 +1,8 @@
1
- Mutant::Meta::Example.add do
1
+ Mutant::Meta::Example.add :irange do
2
2
  source '1..100'
3
3
 
4
4
  singleton_mutations
5
5
  mutation '1...100'
6
- mutation '(0.0 / 0.0)..100'
7
- mutation '1..(1.0 / 0.0)'
8
- mutation '1..(0.0 / 0.0)'
9
6
  mutation '-1..100'
10
7
  mutation '0..100'
11
8
  mutation '2..100'
@@ -20,14 +17,11 @@ Mutant::Meta::Example.add do
20
17
  mutation '1..-100'
21
18
  end
22
19
 
23
- Mutant::Meta::Example.add do
20
+ Mutant::Meta::Example.add :erange do
24
21
  source '1...100'
25
22
 
26
23
  singleton_mutations
27
24
  mutation '1..100'
28
- mutation '(0.0 / 0.0)...100'
29
- mutation '1...(1.0 / 0.0)'
30
- mutation '1...(0.0 / 0.0)'
31
25
  mutation '-1...100'
32
26
  mutation '0...100'
33
27
  mutation '2...100'
@@ -1,3 +1,3 @@
1
- Mutant::Meta::Example.add do
1
+ Mutant::Meta::Example.add :redo do
2
2
  source 'redo'
3
3
  end
@@ -0,0 +1,106 @@
1
+ Mutant::Meta::Example.add :regexp do
2
+ source '/foo/'
3
+
4
+ singleton_mutations
5
+
6
+ # match all inputs
7
+ mutation '//'
8
+
9
+ # match no input
10
+ mutation '/nomatch\A/'
11
+ end
12
+
13
+ Mutant::Meta::Example.add :regexp do
14
+ source '/#{foo.bar}n/'
15
+
16
+ singleton_mutations
17
+ mutation '/#{foo}n/'
18
+ mutation '/#{self.bar}n/'
19
+ mutation '/#{nil}n/'
20
+ mutation '/#{self}n/'
21
+
22
+ # match all inputs
23
+ mutation '//'
24
+
25
+ # match no input
26
+ mutation '/nomatch\A/'
27
+ end
28
+
29
+ Mutant::Meta::Example.add :regexp do
30
+ source '/#{foo}/'
31
+
32
+ singleton_mutations
33
+ mutation '/#{self}/'
34
+ mutation '/#{nil}/'
35
+
36
+ # match all inputs
37
+ mutation '//'
38
+
39
+ # match no input
40
+ mutation '/nomatch\A/'
41
+ end
42
+
43
+ Mutant::Meta::Example.add :regexp do
44
+ source '/#{foo}#{nil}/'
45
+
46
+ singleton_mutations
47
+ mutation '/#{nil}#{nil}/'
48
+ mutation '/#{self}#{nil}/'
49
+
50
+ # match all inputs
51
+ mutation '//'
52
+
53
+ # match no input
54
+ mutation '/nomatch\A/'
55
+ end
56
+
57
+ Mutant::Meta::Example.add :regexp do
58
+ source '//'
59
+
60
+ singleton_mutations
61
+
62
+ # match no input
63
+ mutation '/nomatch\A/'
64
+ end
65
+
66
+ Mutant::Meta::Example.add :regexp do
67
+ source 'true if /foo/'
68
+
69
+ singleton_mutations
70
+ mutation 'false if /foo/'
71
+ mutation 'nil if /foo/'
72
+ mutation 'true if true'
73
+ mutation 'true if false'
74
+ mutation 'true if nil'
75
+ mutation 'true'
76
+
77
+ # match all inputs
78
+ mutation 'true if //'
79
+
80
+ # match no input
81
+ mutation 'true if /nomatch\A/'
82
+ end
83
+
84
+ Mutant::Meta::Example.add :regexp do
85
+ source '/(?(1)(foo)(bar))/'
86
+
87
+ singleton_mutations
88
+
89
+ # match all inputs
90
+ mutation '//'
91
+
92
+ # match no input
93
+ mutation '/nomatch\A/'
94
+ end
95
+
96
+ Pathname
97
+ .glob(Pathname.new(__dir__).join('regexp', '*.rb'))
98
+ .sort
99
+ .each(&Kernel.public_method(:require))
100
+
101
+ # Re-register examples for all regular expression nodes for node_type `:regexp`
102
+ Mutant::Meta::Example::ALL.each do |example|
103
+ next unless example.node_type.to_s.start_with?('regexp_')
104
+
105
+ Mutant::Meta::Example::ALL << example.with(node_type: :regexp)
106
+ end
@@ -0,0 +1,13 @@
1
+ Mutant::Meta::Example.add :regexp_bol_anchor do
2
+ source '/^/'
3
+
4
+ singleton_mutations
5
+
6
+ # match all inputs
7
+ mutation '//'
8
+
9
+ # match no input
10
+ mutation '/nomatch\A/'
11
+
12
+ mutation '/\\A/'
13
+ end
@@ -0,0 +1,26 @@
1
+ Mutant::Meta::Example.add :regexp_bos_anchor do
2
+ source '/\A/'
3
+
4
+ singleton_mutations
5
+
6
+ # match all inputs
7
+ mutation '//'
8
+
9
+ # match no input
10
+ mutation '/nomatch\A/'
11
+ end
12
+
13
+ Mutant::Meta::Example.add :regexp_bos_anchor do
14
+ source '/^#{a}/'
15
+
16
+ singleton_mutations
17
+
18
+ mutation '/^#{nil}/'
19
+ mutation '/^#{self}/'
20
+
21
+ # match all inputs
22
+ mutation '//'
23
+
24
+ # match no input
25
+ mutation '/nomatch\A/'
26
+ end
@@ -0,0 +1,13 @@
1
+ Mutant::Meta::Example.add :regexp_root_expression do
2
+ source '/^/'
3
+
4
+ singleton_mutations
5
+
6
+ # match all inputs
7
+ mutation '//'
8
+
9
+ # match no input
10
+ mutation '/nomatch\A/'
11
+
12
+ mutation '/\\A/'
13
+ end
@@ -0,0 +1,8 @@
1
+ Mutant::Meta::Example.add :regopt do
2
+ source '/foo/ixom'
3
+
4
+ singleton_mutations
5
+ mutation '//ixom'
6
+ mutation '/nomatch\\A/ixom'
7
+ mutation '/foo/xom'
8
+ end
@@ -1,4 +1,4 @@
1
- Mutant::Meta::Example.add do
1
+ Mutant::Meta::Example.add :rescue do
2
2
  source 'begin; rescue ExceptionA, ExceptionB => error; true; end'
3
3
 
4
4
  singleton_mutations
@@ -11,7 +11,7 @@ Mutant::Meta::Example.add do
11
11
 
12
12
  end
13
13
 
14
- Mutant::Meta::Example.add do
14
+ Mutant::Meta::Example.add :rescue do
15
15
  source 'begin; rescue SomeException => error; true; end'
16
16
 
17
17
  singleton_mutations
@@ -22,7 +22,7 @@ Mutant::Meta::Example.add do
22
22
  mutation 'begin; true; end'
23
23
  end
24
24
 
25
- Mutant::Meta::Example.add do
25
+ Mutant::Meta::Example.add :rescue do
26
26
  source 'begin; rescue => error; true end'
27
27
 
28
28
  singleton_mutations
@@ -32,7 +32,7 @@ Mutant::Meta::Example.add do
32
32
  mutation 'begin; true; end'
33
33
  end
34
34
 
35
- Mutant::Meta::Example.add do
35
+ Mutant::Meta::Example.add :rescue do
36
36
  source 'begin; rescue; true end'
37
37
 
38
38
  singleton_mutations
@@ -40,3 +40,48 @@ Mutant::Meta::Example.add do
40
40
  mutation 'begin; rescue; nil; end'
41
41
  mutation 'begin; true end'
42
42
  end
43
+
44
+ Mutant::Meta::Example.add :rescue do
45
+ source 'begin; true; end'
46
+
47
+ singleton_mutations
48
+ mutation 'begin; false; end'
49
+ mutation 'begin; nil; end'
50
+ end
51
+
52
+ Mutant::Meta::Example.add :rescue do
53
+ source 'def a; foo; rescue; bar; else; baz; end'
54
+
55
+ # Mutate all bodies
56
+ mutation 'def a; nil; rescue; bar; else; baz; end'
57
+ mutation 'def a; self; rescue; bar; else; baz; end'
58
+ mutation 'def a; foo; rescue; nil; else; baz; end'
59
+ mutation 'def a; foo; rescue; self; else; baz; end'
60
+ mutation 'def a; foo; rescue; bar; else; nil; end'
61
+ mutation 'def a; foo; rescue; bar; else; self; end'
62
+
63
+ # Promote and concat rescue resbody bodies
64
+ mutation 'def a; foo; bar; end'
65
+
66
+ # Promote and concat else body
67
+ mutation 'def a; foo; baz; end'
68
+
69
+ # Promote rescue body
70
+ mutation 'def a; foo; end'
71
+
72
+ # Empty body
73
+ mutation 'def a; end'
74
+
75
+ # Failing body
76
+ mutation 'def a; raise; end'
77
+
78
+ mutation 'remove_method :a'
79
+ end
80
+
81
+ Mutant::Meta::Example.add :rescue do
82
+ source 'begin; rescue; ensure; true; end'
83
+
84
+ singleton_mutations
85
+ mutation 'begin; rescue; ensure; false; end'
86
+ mutation 'begin; rescue; ensure; nil; end'
87
+ end