mutant 0.8.8 → 0.8.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +9 -0
  3. data/README.md +1 -1
  4. data/Rakefile +12 -8
  5. data/bin/mutant +5 -1
  6. data/config/flay.yml +1 -1
  7. data/lib/mutant.rb +18 -17
  8. data/lib/mutant/actor.rb +1 -7
  9. data/lib/mutant/actor/env.rb +0 -4
  10. data/lib/mutant/actor/mailbox.rb +0 -4
  11. data/lib/mutant/actor/receiver.rb +0 -4
  12. data/lib/mutant/actor/sender.rb +0 -2
  13. data/lib/mutant/ast.rb +1 -5
  14. data/lib/mutant/ast/meta/const.rb +0 -2
  15. data/lib/mutant/ast/meta/optarg.rb +0 -2
  16. data/lib/mutant/ast/meta/send.rb +0 -12
  17. data/lib/mutant/ast/named_children.rb +0 -10
  18. data/lib/mutant/ast/sexp.rb +1 -5
  19. data/lib/mutant/cli.rb +19 -38
  20. data/lib/mutant/color.rb +1 -7
  21. data/lib/mutant/config.rb +11 -7
  22. data/lib/mutant/context.rb +0 -4
  23. data/lib/mutant/context/scope.rb +0 -18
  24. data/lib/mutant/delegator.rb +0 -6
  25. data/lib/mutant/diff.rb +0 -18
  26. data/lib/mutant/env.rb +8 -24
  27. data/lib/mutant/env/bootstrap.rb +18 -41
  28. data/lib/mutant/expression.rb +0 -8
  29. data/lib/mutant/expression/method.rb +6 -7
  30. data/lib/mutant/expression/methods.rb +5 -9
  31. data/lib/mutant/expression/namespace.rb +0 -13
  32. data/lib/mutant/expression/parser.rb +0 -6
  33. data/lib/mutant/integration.rb +2 -20
  34. data/lib/mutant/isolation.rb +0 -4
  35. data/lib/mutant/loader.rb +20 -35
  36. data/lib/mutant/matcher.rb +1 -1
  37. data/lib/mutant/matcher/chain.rb +1 -3
  38. data/lib/mutant/matcher/compiler.rb +0 -8
  39. data/lib/mutant/matcher/config.rb +2 -10
  40. data/lib/mutant/matcher/filter.rb +1 -3
  41. data/lib/mutant/matcher/method.rb +4 -26
  42. data/lib/mutant/matcher/method/instance.rb +1 -7
  43. data/lib/mutant/matcher/method/singleton.rb +0 -12
  44. data/lib/mutant/matcher/methods.rb +1 -19
  45. data/lib/mutant/matcher/namespace.rb +1 -7
  46. data/lib/mutant/matcher/null.rb +1 -3
  47. data/lib/mutant/matcher/scope.rb +1 -5
  48. data/lib/mutant/matcher/static.rb +0 -2
  49. data/lib/mutant/meta.rb +0 -2
  50. data/lib/mutant/meta/example.rb +0 -28
  51. data/lib/mutant/meta/example/dsl.rb +2 -16
  52. data/lib/mutant/mutation.rb +9 -18
  53. data/lib/mutant/mutator.rb +0 -24
  54. data/lib/mutant/mutator/node.rb +1 -33
  55. data/lib/mutant/mutator/node/and_asgn.rb +0 -2
  56. data/lib/mutant/mutator/node/argument.rb +0 -10
  57. data/lib/mutant/mutator/node/arguments.rb +0 -12
  58. data/lib/mutant/mutator/node/begin.rb +0 -4
  59. data/lib/mutant/mutator/node/binary.rb +2 -11
  60. data/lib/mutant/mutator/node/block.rb +0 -6
  61. data/lib/mutant/mutator/node/break.rb +0 -2
  62. data/lib/mutant/mutator/node/case.rb +0 -6
  63. data/lib/mutant/mutator/node/conditional_loop.rb +0 -2
  64. data/lib/mutant/mutator/node/const.rb +1 -3
  65. data/lib/mutant/mutator/node/define.rb +4 -11
  66. data/lib/mutant/mutator/node/defined.rb +0 -2
  67. data/lib/mutant/mutator/node/dstr.rb +0 -2
  68. data/lib/mutant/mutator/node/dsym.rb +0 -2
  69. data/lib/mutant/mutator/node/generic.rb +1 -3
  70. data/lib/mutant/mutator/node/if.rb +0 -8
  71. data/lib/mutant/mutator/node/kwbegin.rb +0 -2
  72. data/lib/mutant/mutator/node/literal/array.rb +0 -4
  73. data/lib/mutant/mutator/node/literal/boolean.rb +0 -2
  74. data/lib/mutant/mutator/node/literal/fixnum.rb +0 -6
  75. data/lib/mutant/mutator/node/literal/float.rb +0 -6
  76. data/lib/mutant/mutator/node/literal/hash.rb +0 -6
  77. data/lib/mutant/mutator/node/literal/nil.rb +0 -2
  78. data/lib/mutant/mutator/node/literal/range.rb +0 -8
  79. data/lib/mutant/mutator/node/literal/regex.rb +0 -4
  80. data/lib/mutant/mutator/node/literal/string.rb +0 -2
  81. data/lib/mutant/mutator/node/literal/symbol.rb +0 -2
  82. data/lib/mutant/mutator/node/masgn.rb +0 -2
  83. data/lib/mutant/mutator/node/match_current_line.rb +0 -2
  84. data/lib/mutant/mutator/node/mlhs.rb +0 -2
  85. data/lib/mutant/mutator/node/named_value/access.rb +0 -8
  86. data/lib/mutant/mutator/node/named_value/constant_assignment.rb +1 -7
  87. data/lib/mutant/mutator/node/named_value/variable_assignment.rb +0 -4
  88. data/lib/mutant/mutator/node/next.rb +0 -2
  89. data/lib/mutant/mutator/node/noop.rb +0 -2
  90. data/lib/mutant/mutator/node/nthref.rb +0 -2
  91. data/lib/mutant/mutator/node/op_asgn.rb +0 -2
  92. data/lib/mutant/mutator/node/or_asgn.rb +0 -2
  93. data/lib/mutant/mutator/node/resbody.rb +0 -4
  94. data/lib/mutant/mutator/node/rescue.rb +0 -10
  95. data/lib/mutant/mutator/node/return.rb +0 -2
  96. data/lib/mutant/mutator/node/send.rb +4 -32
  97. data/lib/mutant/mutator/node/send/attribute_assignment.rb +0 -6
  98. data/lib/mutant/mutator/node/send/binary.rb +0 -6
  99. data/lib/mutant/mutator/node/send/index.rb +0 -6
  100. data/lib/mutant/mutator/node/splat.rb +0 -2
  101. data/lib/mutant/mutator/node/super.rb +0 -2
  102. data/lib/mutant/mutator/node/when.rb +0 -10
  103. data/lib/mutant/mutator/node/yield.rb +0 -2
  104. data/lib/mutant/mutator/node/zsuper.rb +0 -2
  105. data/lib/mutant/mutator/registry.rb +0 -6
  106. data/lib/mutant/mutator/util.rb +0 -4
  107. data/lib/mutant/mutator/util/array.rb +0 -6
  108. data/lib/mutant/mutator/util/symbol.rb +0 -2
  109. data/lib/mutant/parallel.rb +21 -17
  110. data/lib/mutant/parallel/master.rb +0 -28
  111. data/lib/mutant/parallel/source.rb +0 -10
  112. data/lib/mutant/parallel/worker.rb +15 -10
  113. data/lib/mutant/parser.rb +23 -0
  114. data/lib/mutant/reporter.rb +5 -8
  115. data/lib/mutant/reporter/cli.rb +1 -15
  116. data/lib/mutant/reporter/cli/format.rb +3 -25
  117. data/lib/mutant/reporter/cli/printer.rb +0 -18
  118. data/lib/mutant/reporter/cli/printer/config.rb +0 -2
  119. data/lib/mutant/reporter/cli/printer/env_progress.rb +0 -2
  120. data/lib/mutant/reporter/cli/printer/env_result.rb +0 -2
  121. data/lib/mutant/reporter/cli/printer/mutation_progress_result.rb +0 -4
  122. data/lib/mutant/reporter/cli/printer/mutation_result.rb +0 -16
  123. data/lib/mutant/reporter/cli/printer/status.rb +0 -6
  124. data/lib/mutant/reporter/cli/printer/status_progressive.rb +0 -4
  125. data/lib/mutant/reporter/cli/printer/subject_progress.rb +0 -8
  126. data/lib/mutant/reporter/cli/printer/subject_result.rb +0 -2
  127. data/lib/mutant/reporter/cli/printer/test_result.rb +0 -2
  128. data/lib/mutant/reporter/cli/tput.rb +0 -4
  129. data/lib/mutant/repository.rb +4 -22
  130. data/lib/mutant/require_highjack.rb +0 -2
  131. data/lib/mutant/result.rb +23 -43
  132. data/lib/mutant/runner.rb +7 -20
  133. data/lib/mutant/runner/sink.rb +43 -86
  134. data/lib/mutant/selector.rb +0 -2
  135. data/lib/mutant/selector/expression.rb +0 -2
  136. data/lib/mutant/subject.rb +0 -22
  137. data/lib/mutant/subject/method.rb +2 -10
  138. data/lib/mutant/subject/method/instance.rb +0 -6
  139. data/lib/mutant/subject/method/singleton.rb +0 -2
  140. data/lib/mutant/test.rb +4 -3
  141. data/lib/mutant/version.rb +1 -1
  142. data/lib/mutant/warning_filter.rb +0 -10
  143. data/lib/mutant/zombifier.rb +5 -20
  144. data/meta/or_asgn.rb +6 -0
  145. data/meta/send.rb +29 -0
  146. data/mutant-rspec.gemspec +1 -1
  147. data/spec/integration/mutant/rspec_spec.rb +1 -1
  148. data/spec/integrations.yml +2 -3
  149. data/spec/shared/method_matcher_behavior.rb +7 -7
  150. data/spec/spec_helper.rb +2 -9
  151. data/spec/support/corpus.rb +37 -30
  152. data/spec/support/rb_bug.rb +1 -2
  153. data/spec/support/ruby_vm.rb +6 -3
  154. data/spec/support/shared_context.rb +19 -20
  155. data/spec/unit/mutant/actor/binding_spec.rb +6 -6
  156. data/spec/unit/mutant/actor/env_spec.rb +2 -2
  157. data/spec/unit/mutant/actor/mailbox_spec.rb +6 -6
  158. data/spec/unit/mutant/actor/message_spec.rb +2 -2
  159. data/spec/unit/mutant/actor/receiver_spec.rb +4 -4
  160. data/spec/unit/mutant/actor/sender_spec.rb +6 -6
  161. data/spec/unit/mutant/ast_spec.rb +9 -0
  162. data/spec/unit/mutant/cli_spec.rb +16 -10
  163. data/spec/unit/mutant/context/scope/root_spec.rb +1 -1
  164. data/spec/unit/mutant/context/scope/unqualified_name_spec.rb +1 -1
  165. data/spec/unit/mutant/context/scope_spec.rb +3 -3
  166. data/spec/unit/mutant/context_spec.rb +0 -22
  167. data/spec/unit/mutant/env/boostrap_spec.rb +34 -41
  168. data/spec/unit/mutant/env_spec.rb +74 -32
  169. data/spec/unit/mutant/integration/rspec_spec.rb +23 -17
  170. data/spec/unit/mutant/integration_spec.rb +4 -4
  171. data/spec/unit/mutant/isolation_spec.rb +4 -4
  172. data/spec/unit/mutant/loader_spec.rb +42 -0
  173. data/spec/unit/mutant/matcher/compiler_spec.rb +3 -3
  174. data/spec/unit/mutant/matcher/config_spec.rb +1 -1
  175. data/spec/unit/mutant/matcher/method/instance_spec.rb +8 -1
  176. data/spec/unit/mutant/matcher/method/singleton_spec.rb +8 -1
  177. data/spec/unit/mutant/matcher/namespace_spec.rb +7 -8
  178. data/spec/unit/mutant/matcher/null_spec.rb +3 -2
  179. data/spec/unit/mutant/mutation_spec.rb +11 -5
  180. data/spec/unit/mutant/mutator/registry_spec.rb +1 -1
  181. data/spec/unit/mutant/parallel/master_spec.rb +9 -9
  182. data/spec/unit/mutant/parallel/source/array_spec.rb +3 -3
  183. data/spec/unit/mutant/parallel/worker_spec.rb +5 -5
  184. data/spec/unit/mutant/parallel_spec.rb +4 -4
  185. data/spec/unit/mutant/parser_spec.rb +24 -0
  186. data/spec/unit/mutant/reporter/cli/printer_spec.rb +3 -3
  187. data/spec/unit/mutant/reporter/cli/tput_spec.rb +2 -2
  188. data/spec/unit/mutant/reporter/cli_spec.rb +7 -7
  189. data/spec/unit/mutant/reporter/null_spec.rb +5 -4
  190. data/spec/unit/mutant/repository/diff_spec.rb +30 -18
  191. data/spec/unit/mutant/repository/subject_filter_spec.rb +5 -5
  192. data/spec/unit/mutant/require_highjack_spec.rb +1 -1
  193. data/spec/unit/mutant/result/env_spec.rb +9 -9
  194. data/spec/unit/mutant/result/subject_spec.rb +5 -5
  195. data/spec/unit/mutant/runner/driver_spec.rb +4 -4
  196. data/spec/unit/mutant/runner/{sink/mutation_spec.rb → sink_spec.rb} +16 -4
  197. data/spec/unit/mutant/runner_spec.rb +31 -31
  198. data/spec/unit/mutant/selector/expression_spec.rb +8 -8
  199. data/spec/unit/mutant/subject/method/instance_spec.rb +9 -3
  200. data/spec/unit/mutant/subject/method/singleton_spec.rb +1 -1
  201. data/spec/unit/mutant/subject_spec.rb +1 -5
  202. data/spec/unit/mutant_spec.rb +3 -3
  203. metadata +9 -15
  204. data/config/mutant.yml +0 -14
  205. data/lib/mutant/cache.rb +0 -29
  206. data/lib/mutant/reporter/trace.rb +0 -36
  207. data/spec/support/rspec.rb +0 -21
  208. data/spec/unit/mutant/cache_spec.rb +0 -22
  209. data/spec/unit/mutant/loader/eval_spec.rb +0 -44
  210. data/spec/unit/mutant/reporter/trace_spec.rb +0 -21
  211. data/test_app/Gemfile.rspec3.2 +0 -7
@@ -8,10 +8,8 @@ module Mutant
8
8
  # @param [String] text
9
9
  #
10
10
  # @return [String]
11
- #
12
- # @api private
13
11
  def format(text)
14
- "\e[#{@code}m#{text}\e[0m"
12
+ "\e[#{code}m#{text}\e[0m"
15
13
  end
16
14
 
17
15
  NONE = Class.new(self) do
@@ -22,8 +20,6 @@ module Mutant
22
20
  #
23
21
  # @return [String]
24
22
  # the argument string
25
- #
26
- # @api private
27
23
  def format(text)
28
24
  text
29
25
  end
@@ -33,8 +29,6 @@ module Mutant
33
29
  # Initialize null color
34
30
  #
35
31
  # @return [undefined]
36
- #
37
- # @api private
38
32
  def initialize
39
33
  end
40
34
 
@@ -6,17 +6,21 @@ module Mutant
6
6
  class Config
7
7
  include Adamantium::Flat, Anima.new(
8
8
  :debug,
9
+ :expected_coverage,
10
+ :expression_parser,
11
+ :fail_fast,
9
12
  :integration,
10
- :matcher,
11
13
  :includes,
12
- :requires,
13
- :reporter,
14
14
  :isolation,
15
- :fail_fast,
16
15
  :jobs,
17
- :zombie,
18
- :expected_coverage,
19
- :expression_parser
16
+ :kernel,
17
+ :load_path,
18
+ :matcher,
19
+ :open3,
20
+ :pathname,
21
+ :requires,
22
+ :reporter,
23
+ :zombie
20
24
  )
21
25
 
22
26
  %i[fail_fast zombie debug].each do |name|
@@ -8,15 +8,11 @@ module Mutant
8
8
  # @param [Parser::AST::Node] node
9
9
  #
10
10
  # @return [Parser::AST::Node]
11
- #
12
- # @api private
13
11
  abstract_method :root
14
12
 
15
13
  # Identification string
16
14
  #
17
15
  # @return [String]
18
- #
19
- # @api private
20
16
  abstract_method :identification
21
17
 
22
18
  end # Context
@@ -10,8 +10,6 @@ module Mutant
10
10
  # Return root node for mutation
11
11
  #
12
12
  # @return [Parser::AST::Node]
13
- #
14
- # @api private
15
13
  def root(node)
16
14
  nesting.reverse.reduce(node) do |current, scope|
17
15
  self.class.wrap(scope, current)
@@ -21,8 +19,6 @@ module Mutant
21
19
  # Identification string
22
20
  #
23
21
  # @return [String]
24
- #
25
- # @api private
26
22
  def identification
27
23
  scope.name
28
24
  end
@@ -37,8 +33,6 @@ module Mutant
37
33
  #
38
34
  # @return [Parser::AST::Module]
39
35
  # if scope is of kind module
40
- #
41
- # @api private
42
36
  def self.wrap(scope, node)
43
37
  name = s(:const, nil, scope.name.split(NAMESPACE_DELIMITER).last.to_sym)
44
38
  case scope
@@ -46,16 +40,12 @@ module Mutant
46
40
  s(:class, name, nil, node)
47
41
  when Module
48
42
  s(:module, name, node)
49
- else
50
- fail "Cannot wrap scope: #{scope.inspect}"
51
43
  end
52
44
  end
53
45
 
54
46
  # Nesting of scope
55
47
  #
56
48
  # @return [Enumerable<Class,Module>]
57
- #
58
- # @api private
59
49
  def nesting
60
50
  const = ::Object
61
51
  name_nesting.each_with_object([]) do |name, nesting|
@@ -68,8 +58,6 @@ module Mutant
68
58
  # Unqualified name of scope
69
59
  #
70
60
  # @return [String]
71
- #
72
- # @api private
73
61
  def unqualified_name
74
62
  name_nesting.last
75
63
  end
@@ -77,8 +65,6 @@ module Mutant
77
65
  # Match expressions for scope
78
66
  #
79
67
  # @return [Enumerable<Expression>]
80
- #
81
- # @api private
82
68
  def match_expressions
83
69
  name_nesting.each_index.reverse_each.map do |index|
84
70
  Expression::Namespace::Recursive.new(
@@ -91,8 +77,6 @@ module Mutant
91
77
  # Scope wrapped by context
92
78
  #
93
79
  # @return [::Module|::Class]
94
- #
95
- # @api private
96
80
  attr_reader :scope
97
81
 
98
82
  private
@@ -100,8 +84,6 @@ module Mutant
100
84
  # Nesting of names in scope
101
85
  #
102
86
  # @return [Array<String>]
103
- #
104
- # @api private
105
87
  def name_nesting
106
88
  scope.name.split(NAMESPACE_DELIMITER)
107
89
  end
@@ -9,8 +9,6 @@ module Mutant
9
9
  # Create delegators to object
10
10
  #
11
11
  # @return [undefined]
12
- #
13
- # @api private
14
12
  def delegate(*names)
15
13
  names.each(&method(:define_delegator))
16
14
  end
@@ -20,8 +18,6 @@ module Mutant
20
18
  # @param [Symbol] name
21
19
  #
22
20
  # @return [undefined]
23
- #
24
- # @api private
25
21
  def define_delegator(name)
26
22
  fail "method #{name} already defined" if instance_methods.include?(name)
27
23
  define_method(name) do
@@ -37,8 +33,6 @@ module Mutant
37
33
  # @param [Class,Module] host
38
34
  #
39
35
  # @return [undefined]
40
- #
41
- # @api private
42
36
  def self.included(host)
43
37
  super
44
38
 
@@ -14,8 +14,6 @@ module Mutant
14
14
  #
15
15
  # @return [nil]
16
16
  # otherwise
17
- #
18
- # @api private
19
17
  def diff
20
18
  return if diffs.empty?
21
19
 
@@ -32,8 +30,6 @@ module Mutant
32
30
  #
33
31
  # @return [nil]
34
32
  # otherwise
35
- #
36
- # @api private
37
33
  def colorized_diff
38
34
  return unless diff
39
35
  diff.lines.map(&self.class.method(:colorize_line)).join
@@ -46,8 +42,6 @@ module Mutant
46
42
  # @param [String] new
47
43
  #
48
44
  # @return [Diff]
49
- #
50
- # @api private
51
45
  def self.build(old, new)
52
46
  new(lines(old), lines(new))
53
47
  end
@@ -57,8 +51,6 @@ module Mutant
57
51
  # @param [String] source
58
52
  #
59
53
  # @return [Array<String>]
60
- #
61
- # @api private
62
54
  def self.lines(source)
63
55
  source.lines.map(&:chomp)
64
56
  end
@@ -69,8 +61,6 @@ module Mutant
69
61
  # Diffs between old and new
70
62
  #
71
63
  # @return [Array<Array>]
72
- #
73
- # @api private
74
64
  def diffs
75
65
  ::Diff::LCS.diff(old, new)
76
66
  end
@@ -78,8 +68,6 @@ module Mutant
78
68
  # Raw diff-lcs hunks
79
69
  #
80
70
  # @return [Array<Diff::LCS::Hunk>]
81
- #
82
- # @api private
83
71
  def hunks
84
72
  diffs.map do |diff|
85
73
  ::Diff::LCS::Hunk.new(old, new, diff, max_length, 0)
@@ -89,8 +77,6 @@ module Mutant
89
77
  # Minimized hunks
90
78
  #
91
79
  # @return [Array<Diff::LCS::Hunk>]
92
- #
93
- # @api private
94
80
  def minimized_hunks
95
81
  head, *tail = hunks
96
82
 
@@ -107,8 +93,6 @@ module Mutant
107
93
  # Max length of source line in new and old
108
94
  #
109
95
  # @return [Fixnum]
110
- #
111
- # @api private
112
96
  def max_length
113
97
  [old, new].map(&:length).max
114
98
  end
@@ -118,8 +102,6 @@ module Mutant
118
102
  # @param [String] line
119
103
  #
120
104
  # @return [String]
121
- #
122
- # @api private
123
105
  def self.colorize_line(line)
124
106
  case line[0]
125
107
  when ADDITION
@@ -2,39 +2,25 @@ module Mutant
2
2
  # Abstract base class for mutant environments
3
3
  class Env
4
4
  include Adamantium::Flat, Anima.new(
5
- :config,
6
5
  :actor_env,
7
- :cache,
8
- :subjects,
9
- :matchable_scopes,
6
+ :config,
10
7
  :integration,
8
+ :matchable_scopes,
9
+ :mutations,
10
+ :parser,
11
11
  :selector,
12
- :mutations
12
+ :subjects
13
13
  )
14
14
 
15
15
  SEMANTICS_MESSAGE =
16
16
  "Fix your lib to follow normal ruby semantics!\n" \
17
17
  '{Module,Class}#name should return resolvable constant name as String or nil'.freeze
18
18
 
19
- # Print warning message
20
- #
21
- # @param [String]
22
- #
23
- # @return [self]
24
- #
25
- # @api private
26
- def warn(message)
27
- config.reporter.warn(message)
28
- self
29
- end
30
-
31
19
  # Kill mutation
32
20
  #
33
21
  # @param [Mutation] mutation
34
22
  #
35
23
  # @return [Result::Mutation]
36
- #
37
- # @api private
38
24
  def kill(mutation)
39
25
  test_result = run_mutation_tests(mutation)
40
26
  Result::Mutation.new(
@@ -53,22 +39,20 @@ module Mutant
53
39
  # @return [Result::Test]
54
40
  #
55
41
  # rubocop:disable MethodLength
56
- #
57
- # @api private
58
42
  def run_mutation_tests(mutation)
59
43
  start = Time.now
60
44
  tests = selector.call(mutation.subject)
61
45
 
62
46
  config.isolation.call do
63
- mutation.insert
47
+ mutation.insert(config.kernel)
64
48
  integration.call(tests)
65
49
  end
66
50
  rescue Isolation::Error => error
67
51
  Result::Test.new(
68
- tests: tests,
69
52
  output: error.message,
53
+ passed: false,
70
54
  runtime: Time.now - start,
71
- passed: false
55
+ tests: tests
72
56
  )
73
57
  end
74
58
 
@@ -1,8 +1,8 @@
1
1
  module Mutant
2
2
  class Env
3
- # Boostrap environment
3
+ # Bootstrap environment
4
4
  class Bootstrap
5
- include Adamantium::Flat, Concord::Public.new(:config, :cache), Procto.call(:env)
5
+ include Adamantium::Flat, Concord::Public.new(:config), Procto.call(:env)
6
6
 
7
7
  SEMANTICS_MESSAGE_FORMAT =
8
8
  "%<message>s. Fix your lib to follow normal ruby semantics!\n" \
@@ -19,26 +19,19 @@ module Mutant
19
19
  # Scopes that are eligible for matching
20
20
  #
21
21
  # @return [Enumerable<Matcher::Scope>]
22
- #
23
- # @api private
24
22
  attr_reader :matchable_scopes
25
23
 
26
- # New bootstrap env
27
- #
28
- # @return [Env]
24
+ # Parser for this environment
29
25
  #
30
- # @api private
31
- def self.new(_config, _cache = Cache.new)
32
- super
33
- end
26
+ # @return [Parser]
27
+ attr_reader :parser
34
28
 
35
29
  # Initialize object
36
30
  #
37
31
  # @return [Object]
38
- #
39
- # @api private
40
32
  def initialize(*)
41
33
  super
34
+ @parser = Parser.new
42
35
  infect
43
36
  initialize_matchable_scopes
44
37
  end
@@ -48,8 +41,6 @@ module Mutant
48
41
  # @param [String]
49
42
  #
50
43
  # @return [self]
51
- #
52
- # @api private
53
44
  def warn(message)
54
45
  config.reporter.warn(message)
55
46
  self
@@ -58,8 +49,6 @@ module Mutant
58
49
  # Environment after bootstraping
59
50
  #
60
51
  # @return [Env]
61
- #
62
- # @api private
63
52
  # rubocop:disable MethodLength
64
53
  #
65
54
  def env
@@ -67,18 +56,18 @@ module Mutant
67
56
  Env.new(
68
57
  actor_env: Actor::Env.new(Thread),
69
58
  config: config,
70
- cache: cache,
71
- subjects: subjects,
72
- matchable_scopes: matchable_scopes,
73
59
  integration: @integration,
60
+ matchable_scopes: matchable_scopes,
61
+ mutations: subjects.flat_map(&:mutations),
62
+ parser: parser,
74
63
  selector: Selector::Expression.new(@integration),
75
- mutations: subjects.flat_map(&:mutations)
64
+ subjects: subjects
76
65
  )
77
66
  end
78
67
 
79
68
  private
80
69
 
81
- # Scope name from scopeing object
70
+ # Scope name from scoping object
82
71
  #
83
72
  # @param [Class, Module] scope
84
73
  #
@@ -87,16 +76,14 @@ module Mutant
87
76
  #
88
77
  # @return [nil]
89
78
  # otherwise
90
- #
91
- # @api private
92
79
  def scope_name(scope)
93
80
  scope.name
94
81
  rescue => exception
95
82
  semantics_warning(
96
83
  CLASS_NAME_RAISED_EXCEPTION,
97
- scope_class: scope.class,
84
+ exception: exception.inspect,
98
85
  scope: scope,
99
- exception: exception.inspect
86
+ scope_class: scope.class
100
87
  )
101
88
  nil
102
89
  end
@@ -104,19 +91,15 @@ module Mutant
104
91
  # Infect environment
105
92
  #
106
93
  # @return [undefined]
107
- #
108
- # @api private
109
94
  def infect
110
- config.includes.each(&$LOAD_PATH.method(:<<))
111
- config.requires.each(&Kernel.method(:require))
95
+ config.includes.each(&config.load_path.method(:<<))
96
+ config.requires.each(&config.kernel.method(:require))
112
97
  @integration = config.integration.new(config).setup
113
98
  end
114
99
 
115
100
  # Matched subjects
116
101
  #
117
102
  # @return [Enumerable<Subject>]
118
- #
119
- # @api private
120
103
  def matched_subjects
121
104
  Matcher::Compiler.call(config.matcher).call(self)
122
105
  end
@@ -124,8 +107,6 @@ module Mutant
124
107
  # Initialize matchable scopes
125
108
  #
126
109
  # @return [undefined]
127
- #
128
- # @api private
129
110
  def initialize_matchable_scopes
130
111
  scopes = ObjectSpace.each_object(Module).each_with_object([]) do |scope, aggregate|
131
112
  expression = expression(scope) || next
@@ -144,17 +125,15 @@ module Mutant
144
125
  #
145
126
  # @return [nil]
146
127
  # otherwise
147
- #
148
- # @api private
149
128
  def expression(scope)
150
129
  name = scope_name(scope) or return
151
130
 
152
131
  unless name.instance_of?(String)
153
132
  semantics_warning(
154
133
  CLASS_NAME_TYPE_MISMATCH_FORMAT,
134
+ name: name,
155
135
  scope_class: scope.class,
156
- scope: scope,
157
- name: name
136
+ scope: scope
158
137
  )
159
138
  return
160
139
  end
@@ -165,12 +144,10 @@ module Mutant
165
144
  # Write a semantics warning
166
145
  #
167
146
  # @return [undefined]
168
- #
169
- # @api private
170
147
  def semantics_warning(format, options)
171
148
  message = format % options
172
149
  warn(SEMANTICS_MESSAGE_FORMAT % { message: message })
173
150
  end
174
- end # Boostrap
151
+ end # Bootstrap
175
152
  end # Env
176
153
  end # Mutant