mutant 0.8.24 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +3 -3
- data/Changelog.md +14 -654
- data/Gemfile +13 -0
- data/Gemfile.lock +59 -64
- data/LICENSE +271 -20
- data/README.md +73 -140
- data/Rakefile +0 -21
- data/bin/mutant +7 -2
- data/config/reek.yml +2 -1
- data/config/rubocop.yml +5 -9
- data/docs/incremental.md +76 -0
- data/docs/known-problems.md +0 -14
- data/docs/mutant-minitest.md +1 -1
- data/docs/mutant-rspec.md +2 -24
- data/lib/mutant.rb +45 -53
- data/lib/mutant/ast/nodes.rb +0 -2
- data/lib/mutant/ast/types.rb +1 -117
- data/lib/mutant/base.rb +192 -0
- data/lib/mutant/bootstrap.rb +145 -0
- data/lib/mutant/cli.rb +68 -54
- data/lib/mutant/config.rb +119 -6
- data/lib/mutant/env.rb +94 -8
- data/lib/mutant/expression.rb +6 -1
- data/lib/mutant/expression/parser.rb +9 -31
- data/lib/mutant/integration.rb +64 -36
- data/lib/mutant/isolation.rb +16 -1
- data/lib/mutant/isolation/fork.rb +105 -40
- data/lib/mutant/license.rb +34 -0
- data/lib/mutant/license/subscription.rb +47 -0
- data/lib/mutant/license/subscription/commercial.rb +57 -0
- data/lib/mutant/license/subscription/opensource.rb +77 -0
- data/lib/mutant/loader.rb +27 -4
- data/lib/mutant/matcher.rb +48 -1
- data/lib/mutant/matcher/chain.rb +1 -1
- data/lib/mutant/matcher/config.rb +0 -2
- data/lib/mutant/matcher/filter.rb +1 -1
- data/lib/mutant/matcher/method.rb +11 -7
- data/lib/mutant/matcher/methods.rb +1 -1
- data/lib/mutant/matcher/namespace.rb +1 -1
- data/lib/mutant/matcher/null.rb +1 -1
- data/lib/mutant/matcher/scope.rb +1 -1
- data/lib/mutant/meta/example/dsl.rb +0 -8
- data/lib/mutant/mutation.rb +1 -2
- data/lib/mutant/mutator/node.rb +2 -9
- data/lib/mutant/mutator/node/arguments.rb +1 -1
- data/lib/mutant/mutator/node/class.rb +0 -8
- data/lib/mutant/mutator/node/define.rb +0 -12
- data/lib/mutant/mutator/node/generic.rb +30 -44
- data/lib/mutant/mutator/node/index.rb +4 -4
- data/lib/mutant/mutator/node/literal/regex.rb +0 -39
- data/lib/mutant/mutator/node/send.rb +13 -12
- data/lib/mutant/parallel.rb +61 -40
- data/lib/mutant/parallel/driver.rb +59 -0
- data/lib/mutant/parallel/source.rb +6 -2
- data/lib/mutant/parallel/worker.rb +63 -45
- data/lib/mutant/range.rb +15 -0
- data/lib/mutant/reporter/cli.rb +5 -11
- data/lib/mutant/reporter/cli/format.rb +3 -46
- data/lib/mutant/reporter/cli/printer/config.rb +5 -6
- data/lib/mutant/reporter/cli/printer/env.rb +40 -0
- data/lib/mutant/reporter/cli/printer/env_progress.rb +13 -17
- data/lib/mutant/reporter/cli/printer/isolation_result.rb +17 -3
- data/lib/mutant/reporter/cli/printer/mutation_result.rb +2 -3
- data/lib/mutant/reporter/cli/printer/status_progressive.rb +19 -10
- data/lib/mutant/repository.rb +0 -65
- data/lib/mutant/repository/diff.rb +104 -0
- data/lib/mutant/repository/diff/ranges.rb +52 -0
- data/lib/mutant/result.rb +16 -7
- data/lib/mutant/runner.rb +38 -47
- data/lib/mutant/runner/sink.rb +1 -1
- data/lib/mutant/selector/null.rb +19 -0
- data/lib/mutant/subject.rb +3 -1
- data/lib/mutant/subject/method/instance.rb +3 -1
- data/lib/mutant/transform.rb +511 -0
- data/lib/mutant/variable.rb +282 -0
- data/lib/mutant/version.rb +1 -1
- data/lib/mutant/warnings.rb +113 -0
- data/meta/case.rb +1 -0
- data/meta/class.rb +0 -9
- data/meta/def.rb +1 -26
- data/meta/regexp.rb +10 -20
- data/meta/send.rb +14 -46
- data/mutant-minitest.gemspec +1 -1
- data/mutant-rspec.gemspec +2 -2
- data/mutant.gemspec +15 -16
- data/mutant.yml +6 -0
- data/spec/integration/mutant/isolation/fork_spec.rb +22 -5
- data/spec/integration/mutant/minitest_spec.rb +3 -2
- data/spec/integration/mutant/rspec_spec.rb +4 -3
- data/spec/integrations.yml +16 -13
- data/spec/shared/base_behavior.rb +45 -0
- data/spec/shared/framework_integration_behavior.rb +43 -14
- data/spec/spec_helper.rb +21 -17
- data/spec/support/corpus.rb +56 -95
- data/spec/support/shared_context.rb +37 -14
- data/spec/support/xspec.rb +7 -3
- data/spec/unit/mutant/bootstrap_spec.rb +216 -0
- data/spec/unit/mutant/cli_spec.rb +173 -117
- data/spec/unit/mutant/config_spec.rb +126 -0
- data/spec/unit/mutant/either_spec.rb +247 -0
- data/spec/unit/mutant/env_spec.rb +162 -40
- data/spec/unit/mutant/expression/method_spec.rb +16 -0
- data/spec/unit/mutant/expression/parser_spec.rb +29 -33
- data/spec/unit/mutant/expression_spec.rb +5 -7
- data/spec/unit/mutant/integration_spec.rb +100 -9
- data/spec/unit/mutant/isolation/fork_spec.rb +125 -67
- data/spec/unit/mutant/isolation/result_spec.rb +33 -1
- data/spec/unit/mutant/license_spec.rb +257 -0
- data/spec/unit/mutant/loader_spec.rb +50 -11
- data/spec/unit/mutant/matcher/compiler_spec.rb +0 -78
- data/spec/unit/mutant/matcher/method/instance_spec.rb +55 -11
- data/spec/unit/mutant/matcher/method/singleton_spec.rb +12 -2
- data/spec/unit/mutant/matcher_spec.rb +102 -0
- data/spec/unit/mutant/maybe_spec.rb +60 -0
- data/spec/unit/mutant/meta/example/dsl_spec.rb +1 -17
- data/spec/unit/mutant/mutation_spec.rb +13 -6
- data/spec/unit/mutant/parallel/driver_spec.rb +112 -14
- data/spec/unit/mutant/parallel/source/array_spec.rb +25 -17
- data/spec/unit/mutant/parallel/worker_spec.rb +182 -44
- data/spec/unit/mutant/parallel_spec.rb +105 -8
- data/spec/unit/mutant/range_spec.rb +141 -0
- data/spec/unit/mutant/reporter/cli/printer/config_spec.rb +7 -21
- data/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb +15 -6
- data/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb +10 -2
- data/spec/unit/mutant/reporter/cli/printer/isolation_result_spec.rb +12 -4
- data/spec/unit/mutant/reporter/cli/printer/mutation_result_spec.rb +31 -2
- data/spec/unit/mutant/reporter/cli/printer/status_progressive_spec.rb +4 -4
- data/spec/unit/mutant/reporter/cli/printer/subject_result_spec.rb +5 -0
- data/spec/unit/mutant/reporter/cli_spec.rb +46 -123
- data/spec/unit/mutant/repository/diff/ranges_spec.rb +180 -0
- data/spec/unit/mutant/repository/diff_spec.rb +84 -71
- data/spec/unit/mutant/require_highjack_spec.rb +1 -1
- data/spec/unit/mutant/result/env_spec.rb +39 -9
- data/spec/unit/mutant/result/test_spec.rb +14 -0
- data/spec/unit/mutant/runner_spec.rb +88 -41
- data/spec/unit/mutant/selector/expression_spec.rb +11 -10
- data/spec/unit/mutant/selector/null_spec.rb +17 -0
- data/spec/unit/mutant/subject/method/instance_spec.rb +44 -5
- data/spec/unit/mutant/subject/method/singleton_spec.rb +9 -2
- data/spec/unit/mutant/subject_spec.rb +9 -1
- data/spec/unit/mutant/transform/array_spec.rb +92 -0
- data/spec/unit/mutant/transform/bool_spec.rb +63 -0
- data/spec/unit/mutant/transform/error_spec.rb +132 -0
- data/spec/unit/mutant/transform/exception_spec.rb +44 -0
- data/spec/unit/mutant/transform/hash_spec.rb +236 -0
- data/spec/unit/mutant/transform/index_spec.rb +92 -0
- data/spec/unit/mutant/transform/named_spec.rb +49 -0
- data/spec/unit/mutant/transform/primitive_spec.rb +56 -0
- data/spec/unit/mutant/transform/sequence_spec.rb +98 -0
- data/spec/unit/mutant/variable_spec.rb +618 -0
- data/spec/unit/mutant/warnings_spec.rb +89 -0
- data/spec/unit/mutant/world_spec.rb +63 -0
- data/test_app/Gemfile.minitest +0 -2
- metadata +79 -113
- data/.gitattributes +0 -1
- data/.ruby-gemset +0 -1
- data/config/triage.yml +0 -2
- data/lib/mutant/actor.rb +0 -57
- data/lib/mutant/actor/env.rb +0 -31
- data/lib/mutant/actor/mailbox.rb +0 -34
- data/lib/mutant/actor/receiver.rb +0 -42
- data/lib/mutant/actor/sender.rb +0 -26
- data/lib/mutant/ast/meta/restarg.rb +0 -19
- data/lib/mutant/ast/regexp.rb +0 -42
- data/lib/mutant/ast/regexp/transformer.rb +0 -187
- data/lib/mutant/ast/regexp/transformer/direct.rb +0 -123
- data/lib/mutant/ast/regexp/transformer/named_group.rb +0 -59
- data/lib/mutant/ast/regexp/transformer/options_group.rb +0 -83
- data/lib/mutant/ast/regexp/transformer/quantifier.rb +0 -114
- data/lib/mutant/ast/regexp/transformer/recursive.rb +0 -58
- data/lib/mutant/ast/regexp/transformer/root.rb +0 -31
- data/lib/mutant/ast/regexp/transformer/text.rb +0 -60
- data/lib/mutant/env/bootstrap.rb +0 -160
- data/lib/mutant/matcher/compiler.rb +0 -60
- data/lib/mutant/mutator/node/regexp.rb +0 -35
- data/lib/mutant/mutator/node/regexp/alternation_meta.rb +0 -23
- data/lib/mutant/mutator/node/regexp/capture_group.rb +0 -28
- data/lib/mutant/mutator/node/regexp/character_type.rb +0 -32
- data/lib/mutant/mutator/node/regexp/end_of_line_anchor.rb +0 -23
- data/lib/mutant/mutator/node/regexp/end_of_string_or_before_end_of_line_anchor.rb +0 -23
- data/lib/mutant/mutator/node/regexp/greedy_zero_or_more.rb +0 -27
- data/lib/mutant/parallel/master.rb +0 -181
- data/lib/mutant/reporter/cli/printer/status.rb +0 -53
- data/lib/mutant/reporter/cli/tput.rb +0 -46
- data/lib/mutant/warning_filter.rb +0 -61
- data/meta/regexp/character_types.rb +0 -23
- data/meta/regexp/regexp_alternation_meta.rb +0 -13
- data/meta/regexp/regexp_bol_anchor.rb +0 -10
- data/meta/regexp/regexp_bos_anchor.rb +0 -18
- data/meta/regexp/regexp_capture_group.rb +0 -19
- data/meta/regexp/regexp_eol_anchor.rb +0 -10
- data/meta/regexp/regexp_eos_anchor.rb +0 -8
- data/meta/regexp/regexp_eos_ob_eol_anchor.rb +0 -10
- data/meta/regexp/regexp_greedy_zero_or_more.rb +0 -12
- data/meta/regexp/regexp_root_expression.rb +0 -10
- data/meta/restarg.rb +0 -10
- data/spec/support/fake_actor.rb +0 -111
- data/spec/support/warning.rb +0 -66
- data/spec/unit/mutant/actor/binding_spec.rb +0 -34
- data/spec/unit/mutant/actor/env_spec.rb +0 -31
- data/spec/unit/mutant/actor/mailbox_spec.rb +0 -28
- data/spec/unit/mutant/actor/message_spec.rb +0 -25
- data/spec/unit/mutant/actor/receiver_spec.rb +0 -58
- data/spec/unit/mutant/actor/sender_spec.rb +0 -24
- data/spec/unit/mutant/ast/regexp/parse_spec.rb +0 -19
- data/spec/unit/mutant/ast/regexp/transformer/lookup_table/table_spec.rb +0 -21
- data/spec/unit/mutant/ast/regexp/transformer/lookup_table_spec.rb +0 -35
- data/spec/unit/mutant/ast/regexp/transformer_spec.rb +0 -21
- data/spec/unit/mutant/ast/regexp_spec.rb +0 -704
- data/spec/unit/mutant/env/bootstrap_spec.rb +0 -188
- data/spec/unit/mutant/matcher/compiler/subject_prefix_spec.rb +0 -26
- data/spec/unit/mutant/parallel/master_spec.rb +0 -338
- data/spec/unit/mutant/reporter/cli/printer/status_spec.rb +0 -121
- data/spec/unit/mutant/reporter/cli/tput_spec.rb +0 -50
- data/spec/unit/mutant/warning_filter_spec.rb +0 -106
- data/spec/unit/mutant_spec.rb +0 -17
- data/test_app/Gemfile.rspec3.7 +0 -7
data/docs/mutant-minitest.md
CHANGED
@@ -63,7 +63,7 @@ bundle exec mutant --include lib --require auom --use minitest -- 'AUOM*'
|
|
63
63
|
This prints a report like:
|
64
64
|
|
65
65
|
```sh
|
66
|
-
Mutant
|
66
|
+
Mutant environment:
|
67
67
|
Matcher: #<Mutant::Matcher::Config match_expressions: [AUOM*]>
|
68
68
|
Integration: Mutant::Integration::Minitest
|
69
69
|
Jobs: 8
|
data/docs/mutant-rspec.md
CHANGED
@@ -17,11 +17,7 @@ To add mutant to your rspec code base you need to:
|
|
17
17
|
gem 'mutant-rspec'
|
18
18
|
```
|
19
19
|
|
20
|
-
2. Run mutant against the rspec integration
|
21
|
-
|
22
|
-
```sh
|
23
|
-
bundle exec mutant --include lib --require 'your_library.rb' --use rspec -- 'YourLibrary*'
|
24
|
-
```
|
20
|
+
2. Run mutant against the rspec integration via the `--use rspec` flag.
|
25
21
|
|
26
22
|
## Run through example
|
27
23
|
|
@@ -41,7 +37,7 @@ bundle exec mutant --include lib --require auom --use rspec -- 'AUOM*'
|
|
41
37
|
This prints a report like:
|
42
38
|
|
43
39
|
```sh
|
44
|
-
Mutant
|
40
|
+
Mutant environment:
|
45
41
|
Matcher: #<Mutant::Matcher::Config match_expressions: [AUOM*]>
|
46
42
|
Integration: Mutant::Integration::Rspec
|
47
43
|
Jobs: 8
|
@@ -129,24 +125,6 @@ description prefixes in `Foo::Bar#baz`, `Foo::Bar` and `Foo`. The order is
|
|
129
125
|
important, so if mutant finds example groups in the current prefix level,
|
130
126
|
these example groups *must* kill the mutation.
|
131
127
|
|
132
|
-
Rails
|
133
|
-
-------
|
134
|
-
|
135
|
-
To mutation test Rails models with rspec, comment out `require 'rspec/autorun'`
|
136
|
-
from your `spec_helper.rb` file. Having done so you should be able to use
|
137
|
-
commands like the following:
|
138
|
-
|
139
128
|
```sh
|
140
129
|
RAILS_ENV=test bundle exec mutant -r ./config/environment --use rspec User
|
141
130
|
```
|
142
|
-
|
143
|
-
Passing in RSpec Options
|
144
|
-
------------------------
|
145
|
-
|
146
|
-
**NOTE: Experimental**
|
147
|
-
|
148
|
-
You can control some aspects of RSpec using the `SPEC_OPTS` environment variable as usual. If you want mutant to only pay attention to specs in a certain directory, you can run
|
149
|
-
|
150
|
-
```sh
|
151
|
-
SPEC_OPTS="--pattern spec/subdir_only/**/*_spec.rb" bundle exec mutant --use rspec SomeClass
|
152
|
-
```
|
data/lib/mutant.rb
CHANGED
@@ -7,19 +7,22 @@ require 'concord'
|
|
7
7
|
require 'diff/lcs'
|
8
8
|
require 'diff/lcs/hunk'
|
9
9
|
require 'digest/sha1'
|
10
|
-
require 'etc'
|
11
10
|
require 'equalizer'
|
11
|
+
require 'etc'
|
12
12
|
require 'ice_nine'
|
13
|
-
require '
|
13
|
+
require 'json'
|
14
14
|
require 'open3'
|
15
15
|
require 'optparse'
|
16
16
|
require 'parser'
|
17
17
|
require 'parser/current'
|
18
18
|
require 'pathname'
|
19
|
-
require 'regexp_parser'
|
20
19
|
require 'set'
|
20
|
+
require 'singleton'
|
21
21
|
require 'stringio'
|
22
22
|
require 'unparser'
|
23
|
+
require 'yaml'
|
24
|
+
|
25
|
+
gem 'mutant-license'
|
23
26
|
|
24
27
|
# This setting is done to make errors within the parallel
|
25
28
|
# reporter / execution visible in the main thread.
|
@@ -33,18 +36,12 @@ module Mutant
|
|
33
36
|
EMPTY_ARRAY = [].freeze
|
34
37
|
EMPTY_HASH = {}.freeze
|
35
38
|
SCOPE_OPERATOR = '::'
|
36
|
-
|
37
|
-
# Test if CI is detected via environment
|
38
|
-
#
|
39
|
-
# @return [Boolean]
|
40
|
-
def self.ci?
|
41
|
-
ENV.key?('CI')
|
42
|
-
end
|
43
39
|
end # Mutant
|
44
40
|
|
41
|
+
require 'mutant/base'
|
42
|
+
require 'mutant/bootstrap'
|
45
43
|
require 'mutant/version'
|
46
44
|
require 'mutant/env'
|
47
|
-
require 'mutant/env/bootstrap'
|
48
45
|
require 'mutant/util'
|
49
46
|
require 'mutant/registry'
|
50
47
|
require 'mutant/ast'
|
@@ -53,36 +50,20 @@ require 'mutant/ast/types'
|
|
53
50
|
require 'mutant/ast/nodes'
|
54
51
|
require 'mutant/ast/named_children'
|
55
52
|
require 'mutant/ast/node_predicates'
|
56
|
-
require 'mutant/ast/regexp'
|
57
|
-
require 'mutant/ast/regexp/transformer'
|
58
|
-
require 'mutant/ast/regexp/transformer/direct'
|
59
|
-
require 'mutant/ast/regexp/transformer/named_group'
|
60
|
-
require 'mutant/ast/regexp/transformer/options_group'
|
61
|
-
require 'mutant/ast/regexp/transformer/quantifier'
|
62
|
-
require 'mutant/ast/regexp/transformer/recursive'
|
63
|
-
require 'mutant/ast/regexp/transformer/root'
|
64
|
-
require 'mutant/ast/regexp/transformer/text'
|
65
53
|
require 'mutant/ast/meta'
|
66
54
|
require 'mutant/ast/meta/send'
|
67
55
|
require 'mutant/ast/meta/const'
|
68
56
|
require 'mutant/ast/meta/symbol'
|
69
57
|
require 'mutant/ast/meta/optarg'
|
70
58
|
require 'mutant/ast/meta/resbody'
|
71
|
-
require 'mutant/ast/meta/restarg'
|
72
|
-
require 'mutant/actor'
|
73
|
-
require 'mutant/actor/receiver'
|
74
|
-
require 'mutant/actor/sender'
|
75
|
-
require 'mutant/actor/mailbox'
|
76
|
-
require 'mutant/actor/env'
|
77
59
|
require 'mutant/parser'
|
78
60
|
require 'mutant/isolation'
|
79
61
|
require 'mutant/isolation/none'
|
80
62
|
require 'mutant/isolation/fork'
|
81
63
|
require 'mutant/parallel'
|
82
|
-
require 'mutant/parallel/
|
83
|
-
require 'mutant/parallel/worker'
|
64
|
+
require 'mutant/parallel/driver'
|
84
65
|
require 'mutant/parallel/source'
|
85
|
-
require 'mutant/
|
66
|
+
require 'mutant/parallel/worker'
|
86
67
|
require 'mutant/require_highjack'
|
87
68
|
require 'mutant/mutation'
|
88
69
|
require 'mutant/mutator'
|
@@ -91,13 +72,6 @@ require 'mutant/mutator/util/array'
|
|
91
72
|
require 'mutant/mutator/util/symbol'
|
92
73
|
require 'mutant/mutator/node'
|
93
74
|
require 'mutant/mutator/node/generic'
|
94
|
-
require 'mutant/mutator/node/regexp'
|
95
|
-
require 'mutant/mutator/node/regexp/alternation_meta'
|
96
|
-
require 'mutant/mutator/node/regexp/capture_group'
|
97
|
-
require 'mutant/mutator/node/regexp/character_type'
|
98
|
-
require 'mutant/mutator/node/regexp/end_of_line_anchor'
|
99
|
-
require 'mutant/mutator/node/regexp/end_of_string_or_before_end_of_line_anchor'
|
100
|
-
require 'mutant/mutator/node/regexp/greedy_zero_or_more'
|
101
75
|
require 'mutant/mutator/node/literal'
|
102
76
|
require 'mutant/mutator/node/literal/boolean'
|
103
77
|
require 'mutant/mutator/node/literal/range'
|
@@ -161,7 +135,6 @@ require 'mutant/subject/method/instance'
|
|
161
135
|
require 'mutant/subject/method/singleton'
|
162
136
|
require 'mutant/matcher'
|
163
137
|
require 'mutant/matcher/config'
|
164
|
-
require 'mutant/matcher/compiler'
|
165
138
|
require 'mutant/matcher/chain'
|
166
139
|
require 'mutant/matcher/method'
|
167
140
|
require 'mutant/matcher/method/singleton'
|
@@ -179,9 +152,12 @@ require 'mutant/expression/methods'
|
|
179
152
|
require 'mutant/expression/namespace'
|
180
153
|
require 'mutant/test'
|
181
154
|
require 'mutant/timer'
|
155
|
+
require 'mutant/transform'
|
182
156
|
require 'mutant/integration'
|
157
|
+
require 'mutant/integration/null'
|
183
158
|
require 'mutant/selector'
|
184
159
|
require 'mutant/selector/expression'
|
160
|
+
require 'mutant/selector/null'
|
185
161
|
require 'mutant/config'
|
186
162
|
require 'mutant/cli'
|
187
163
|
require 'mutant/color'
|
@@ -195,22 +171,49 @@ require 'mutant/reporter/sequence'
|
|
195
171
|
require 'mutant/reporter/cli'
|
196
172
|
require 'mutant/reporter/cli/printer'
|
197
173
|
require 'mutant/reporter/cli/printer/config'
|
174
|
+
require 'mutant/reporter/cli/printer/env'
|
198
175
|
require 'mutant/reporter/cli/printer/env_progress'
|
199
176
|
require 'mutant/reporter/cli/printer/env_result'
|
200
177
|
require 'mutant/reporter/cli/printer/isolation_result'
|
201
178
|
require 'mutant/reporter/cli/printer/mutation_progress_result'
|
202
179
|
require 'mutant/reporter/cli/printer/mutation_result'
|
203
|
-
require 'mutant/reporter/cli/printer/status'
|
204
180
|
require 'mutant/reporter/cli/printer/status_progressive'
|
205
181
|
require 'mutant/reporter/cli/printer/subject_progress'
|
206
182
|
require 'mutant/reporter/cli/printer/subject_result'
|
207
183
|
require 'mutant/reporter/cli/printer/test_result'
|
208
|
-
require 'mutant/reporter/cli/tput'
|
209
184
|
require 'mutant/reporter/cli/format'
|
210
185
|
require 'mutant/repository'
|
186
|
+
require 'mutant/repository/diff'
|
187
|
+
require 'mutant/repository/diff/ranges'
|
188
|
+
require 'mutant/variable'
|
189
|
+
require 'mutant/warnings'
|
211
190
|
require 'mutant/zombifier'
|
191
|
+
require 'mutant/range'
|
192
|
+
require 'mutant/license'
|
193
|
+
require 'mutant/license/subscription'
|
194
|
+
require 'mutant/license/subscription/opensource'
|
195
|
+
require 'mutant/license/subscription/commercial'
|
212
196
|
|
213
197
|
module Mutant
|
198
|
+
WORLD = World.new(
|
199
|
+
condition_variable: ConditionVariable,
|
200
|
+
gem: Gem,
|
201
|
+
io: IO,
|
202
|
+
json: JSON,
|
203
|
+
kernel: Kernel,
|
204
|
+
load_path: $LOAD_PATH,
|
205
|
+
marshal: Marshal,
|
206
|
+
mutex: Mutex,
|
207
|
+
object_space: ObjectSpace,
|
208
|
+
open3: Open3,
|
209
|
+
pathname: Pathname,
|
210
|
+
process: Process,
|
211
|
+
stderr: STDERR,
|
212
|
+
stdout: STDOUT,
|
213
|
+
thread: Thread,
|
214
|
+
warnings: Warnings.new(Warning)
|
215
|
+
)
|
216
|
+
|
214
217
|
# Reopen class to initialize constant to avoid dep circle
|
215
218
|
class Config
|
216
219
|
DEFAULT = new(
|
@@ -222,23 +225,12 @@ module Mutant
|
|
222
225
|
]),
|
223
226
|
fail_fast: false,
|
224
227
|
includes: EMPTY_ARRAY,
|
225
|
-
integration:
|
226
|
-
isolation: Mutant::Isolation::Fork.new(
|
227
|
-
devnull: ->(&block) { File.open(File::NULL, File::WRONLY, &block) },
|
228
|
-
stdout: $stdout,
|
229
|
-
stderr: $stderr,
|
230
|
-
io: IO,
|
231
|
-
marshal: Marshal,
|
232
|
-
process: Process
|
233
|
-
),
|
228
|
+
integration: 'null',
|
229
|
+
isolation: Mutant::Isolation::Fork.new(WORLD),
|
234
230
|
jobs: Etc.nprocessors,
|
235
|
-
kernel: Kernel,
|
236
|
-
load_path: $LOAD_PATH,
|
237
231
|
matcher: Matcher::Config::DEFAULT,
|
238
|
-
|
239
|
-
pathname: Pathname,
|
232
|
+
reporter: Reporter::CLI.build(WORLD.stdout),
|
240
233
|
requires: EMPTY_ARRAY,
|
241
|
-
reporter: Reporter::CLI.build($stdout),
|
242
234
|
zombie: false
|
243
235
|
)
|
244
236
|
end # Config
|
data/lib/mutant/ast/nodes.rb
CHANGED
data/lib/mutant/ast/types.rb
CHANGED
@@ -3,9 +3,6 @@
|
|
3
3
|
module Mutant
|
4
4
|
module AST
|
5
5
|
# Groups of node types
|
6
|
-
#
|
7
|
-
# :reek:TooManyConstants
|
8
|
-
# rubocop:disable Metrics/ModuleLength
|
9
6
|
module Types
|
10
7
|
ASSIGNABLE_VARIABLES = Set.new(%i[ivasgn lvasgn cvasgn gvasgn]).freeze
|
11
8
|
|
@@ -66,119 +63,6 @@ module Mutant
|
|
66
63
|
#
|
67
64
|
BLACKLIST = Set.new(%i[not]).freeze
|
68
65
|
|
69
|
-
# Nodes generated by regular expression body parsing
|
70
|
-
REGEXP = Set.new(%i[
|
71
|
-
regexp_alnum_posixclass
|
72
|
-
regexp_alpha_posixclass
|
73
|
-
regexp_alpha_property
|
74
|
-
regexp_alternation_escape
|
75
|
-
regexp_alternation_meta
|
76
|
-
regexp_arabic_property
|
77
|
-
regexp_ascii_posixclass
|
78
|
-
regexp_atomic_group
|
79
|
-
regexp_backslash_escape
|
80
|
-
regexp_backspace_escape
|
81
|
-
regexp_bell_escape
|
82
|
-
regexp_blank_posixclass
|
83
|
-
regexp_bol_anchor
|
84
|
-
regexp_bol_escape
|
85
|
-
regexp_bos_anchor
|
86
|
-
regexp_capture_group
|
87
|
-
regexp_carriage_escape
|
88
|
-
regexp_character_set
|
89
|
-
regexp_cntrl_posixclass
|
90
|
-
regexp_codepoint_escape
|
91
|
-
regexp_codepoint_list_escape
|
92
|
-
regexp_comment_free_space
|
93
|
-
regexp_comment_group
|
94
|
-
regexp_condition_conditional
|
95
|
-
regexp_control_escape
|
96
|
-
regexp_digit_posixclass
|
97
|
-
regexp_digit_type
|
98
|
-
regexp_dot_escape
|
99
|
-
regexp_dot_meta
|
100
|
-
regexp_eol_anchor
|
101
|
-
regexp_eol_escape
|
102
|
-
regexp_eos_anchor
|
103
|
-
regexp_eos_ob_eol_anchor
|
104
|
-
regexp_escape_escape
|
105
|
-
regexp_form_feed_escape
|
106
|
-
regexp_graph_posixclass
|
107
|
-
regexp_greedy_interval
|
108
|
-
regexp_greedy_one_or_more
|
109
|
-
regexp_greedy_zero_or_more
|
110
|
-
regexp_greedy_zero_or_one
|
111
|
-
regexp_group_close_escape
|
112
|
-
regexp_group_open_escape
|
113
|
-
regexp_han_property
|
114
|
-
regexp_hangul_property
|
115
|
-
regexp_hex_escape
|
116
|
-
regexp_hex_type
|
117
|
-
regexp_hiragana_property
|
118
|
-
regexp_intersection_set
|
119
|
-
regexp_interval_close_escape
|
120
|
-
regexp_interval_open_escape
|
121
|
-
regexp_katakana_property
|
122
|
-
regexp_letter_property
|
123
|
-
regexp_linebreak_type
|
124
|
-
regexp_literal_escape
|
125
|
-
regexp_literal_literal
|
126
|
-
regexp_lookahead_assertion
|
127
|
-
regexp_lookbehind_assertion
|
128
|
-
regexp_lower_posixclass
|
129
|
-
regexp_mark_keep
|
130
|
-
regexp_match_start_anchor
|
131
|
-
regexp_meta_sequence_escape
|
132
|
-
regexp_name_call_backref
|
133
|
-
regexp_named_group
|
134
|
-
regexp_newline_escape
|
135
|
-
regexp_nlookahead_assertion
|
136
|
-
regexp_nlookbehind_assertion
|
137
|
-
regexp_nondigit_type
|
138
|
-
regexp_nonhex_type
|
139
|
-
regexp_nonspace_type
|
140
|
-
regexp_nonword_boundary_anchor
|
141
|
-
regexp_nonword_type
|
142
|
-
regexp_number_backref
|
143
|
-
regexp_octal_escape
|
144
|
-
regexp_one_or_more_escape
|
145
|
-
regexp_open_conditional
|
146
|
-
regexp_options_group
|
147
|
-
regexp_options_switch_group
|
148
|
-
regexp_passive_group
|
149
|
-
regexp_possessive_interval
|
150
|
-
regexp_possessive_one_or_more
|
151
|
-
regexp_possessive_zero_or_more
|
152
|
-
regexp_possessive_zero_or_one
|
153
|
-
regexp_print_nonposixclass
|
154
|
-
regexp_print_nonproperty
|
155
|
-
regexp_print_posixclass
|
156
|
-
regexp_print_posixclass
|
157
|
-
regexp_print_property
|
158
|
-
regexp_punct_posixclass
|
159
|
-
regexp_range_set
|
160
|
-
regexp_reluctant_interval
|
161
|
-
regexp_reluctant_one_or_more
|
162
|
-
regexp_reluctant_zero_or_more
|
163
|
-
regexp_root_expression
|
164
|
-
regexp_sequence_expression
|
165
|
-
regexp_set_close_escape
|
166
|
-
regexp_set_open_escape
|
167
|
-
regexp_space_posixclass
|
168
|
-
regexp_space_type
|
169
|
-
regexp_tab_escape
|
170
|
-
regexp_upper_posixclass
|
171
|
-
regexp_vertical_tab_escape
|
172
|
-
regexp_whitespace_free_space
|
173
|
-
regexp_word_boundary_anchor
|
174
|
-
regexp_word_posixclass
|
175
|
-
regexp_word_type
|
176
|
-
regexp_xdigit_posixclass
|
177
|
-
regexp_xgrapheme_type
|
178
|
-
regexp_zero_or_more_escape
|
179
|
-
regexp_zero_or_one_escape
|
180
|
-
]).freeze
|
181
|
-
|
182
66
|
# Nodes that are NOT generated by parser but used by mutant / unparser.
|
183
67
|
GENERATED = Set.new(%i[empty]).freeze
|
184
68
|
|
@@ -186,7 +70,7 @@ module Mutant
|
|
186
70
|
MISSING = Set.new(%i[index indexasgn lambda procarg0]).freeze
|
187
71
|
|
188
72
|
ALL = Set.new(
|
189
|
-
(Parser::Meta::NODE_TYPES + GENERATED +
|
73
|
+
(Parser::Meta::NODE_TYPES + GENERATED + MISSING) - BLACKLIST
|
190
74
|
).freeze
|
191
75
|
end # Types
|
192
76
|
end # AST
|
data/lib/mutant/base.rb
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mutant
|
4
|
+
module Functor
|
5
|
+
include AbstractType
|
6
|
+
|
7
|
+
abstract_method :fmap
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
# Raise error unless block is provided
|
12
|
+
#
|
13
|
+
# @raise [MissingBlockError]
|
14
|
+
# if no block is given
|
15
|
+
#
|
16
|
+
# @return [self]
|
17
|
+
def require_block
|
18
|
+
fail LocalJumpError unless block_given?
|
19
|
+
self
|
20
|
+
end
|
21
|
+
end # Functor
|
22
|
+
|
23
|
+
class Maybe
|
24
|
+
include(
|
25
|
+
AbstractType,
|
26
|
+
Adamantium::Flat,
|
27
|
+
Functor
|
28
|
+
)
|
29
|
+
|
30
|
+
class Nothing < self
|
31
|
+
instance = new
|
32
|
+
|
33
|
+
define_method(:new) { instance }
|
34
|
+
|
35
|
+
# Evaluate functor block
|
36
|
+
#
|
37
|
+
# @return [Maybe::Nothing]
|
38
|
+
def fmap(&block)
|
39
|
+
require_block(&block)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Evaluate applicative block
|
43
|
+
#
|
44
|
+
# @return [Maybe::Nothing]
|
45
|
+
def apply(&block)
|
46
|
+
require_block(&block)
|
47
|
+
end
|
48
|
+
end # Nothing
|
49
|
+
|
50
|
+
class Just < self
|
51
|
+
include Concord.new(:value)
|
52
|
+
|
53
|
+
# Evalute functor block
|
54
|
+
#
|
55
|
+
# @return [Maybe::Just<Object>]
|
56
|
+
def fmap
|
57
|
+
Just.new(yield(value))
|
58
|
+
end
|
59
|
+
|
60
|
+
# Evalute applicative block
|
61
|
+
#
|
62
|
+
# @return [Maybe]
|
63
|
+
def apply
|
64
|
+
yield(value)
|
65
|
+
end
|
66
|
+
end # Just
|
67
|
+
end # Maybe
|
68
|
+
|
69
|
+
class Either
|
70
|
+
include(
|
71
|
+
AbstractType,
|
72
|
+
Adamantium::Flat,
|
73
|
+
Concord.new(:value),
|
74
|
+
Functor
|
75
|
+
)
|
76
|
+
|
77
|
+
# Execute block and wrap error in left
|
78
|
+
#
|
79
|
+
# @param [Class:Exception] error
|
80
|
+
#
|
81
|
+
# @return [Either<Exception, Object>]
|
82
|
+
def self.wrap_error(error)
|
83
|
+
Right.new(yield)
|
84
|
+
rescue error => exception
|
85
|
+
Left.new(exception)
|
86
|
+
end
|
87
|
+
|
88
|
+
class Left < self
|
89
|
+
# Evaluate functor block
|
90
|
+
#
|
91
|
+
# @return [Either::Left<Object>]
|
92
|
+
def fmap(&block)
|
93
|
+
require_block(&block)
|
94
|
+
end
|
95
|
+
|
96
|
+
# Evaluate applicative block
|
97
|
+
#
|
98
|
+
# @return [Either::Left<Object>]
|
99
|
+
def apply(&block)
|
100
|
+
require_block(&block)
|
101
|
+
end
|
102
|
+
|
103
|
+
# Unwrap value from left
|
104
|
+
#
|
105
|
+
# @return [Object]
|
106
|
+
def from_left
|
107
|
+
value
|
108
|
+
end
|
109
|
+
|
110
|
+
# Unwrap value from right
|
111
|
+
#
|
112
|
+
# @return [Object]
|
113
|
+
#
|
114
|
+
# rubocop:disable Style/GuardClause
|
115
|
+
def from_right
|
116
|
+
if block_given?
|
117
|
+
yield(value)
|
118
|
+
else
|
119
|
+
fail "Expected right value, got #{inspect}"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
# rubocop:enable Style/GuardClause
|
123
|
+
|
124
|
+
# Map over left value
|
125
|
+
#
|
126
|
+
# @return [Either::Right<Object>]
|
127
|
+
def lmap
|
128
|
+
Left.new(yield(value))
|
129
|
+
end
|
130
|
+
|
131
|
+
# Evaluate left side of branch
|
132
|
+
#
|
133
|
+
# @param [#call] left
|
134
|
+
# @param [#call] _right
|
135
|
+
def either(left, _right)
|
136
|
+
left.call(value)
|
137
|
+
end
|
138
|
+
end # Left
|
139
|
+
|
140
|
+
class Right < self
|
141
|
+
# Evaluate functor block
|
142
|
+
#
|
143
|
+
# @return [Either::Right<Object>]
|
144
|
+
def fmap
|
145
|
+
Right.new(yield(value))
|
146
|
+
end
|
147
|
+
|
148
|
+
# Evaluate applicative block
|
149
|
+
#
|
150
|
+
# @return [Either<Object>]
|
151
|
+
def apply
|
152
|
+
yield(value)
|
153
|
+
end
|
154
|
+
|
155
|
+
# Unwrap value from left
|
156
|
+
#
|
157
|
+
# @return [Object]
|
158
|
+
#
|
159
|
+
# rubocop:disable Style/GuardClause
|
160
|
+
def from_left
|
161
|
+
if block_given?
|
162
|
+
yield(value)
|
163
|
+
else
|
164
|
+
fail "Expected left value, got #{inspect}"
|
165
|
+
end
|
166
|
+
end
|
167
|
+
# rubocop:enable Style/GuardClause
|
168
|
+
|
169
|
+
# Unwrap value from right
|
170
|
+
#
|
171
|
+
# @return [Object]
|
172
|
+
def from_right
|
173
|
+
value
|
174
|
+
end
|
175
|
+
|
176
|
+
# Map over left value
|
177
|
+
#
|
178
|
+
# @return [Either::Right<Object>]
|
179
|
+
def lmap(&block)
|
180
|
+
require_block(&block)
|
181
|
+
end
|
182
|
+
|
183
|
+
# Evaluate right side of branch
|
184
|
+
#
|
185
|
+
# @param [#call] _left
|
186
|
+
# @param [#call] right
|
187
|
+
def either(_left, right)
|
188
|
+
right.call(value)
|
189
|
+
end
|
190
|
+
end # Right
|
191
|
+
end # Either
|
192
|
+
end # Mutant
|