mutant 0.8.8 → 0.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changelog.md +9 -0
- data/README.md +1 -1
- data/Rakefile +12 -8
- data/bin/mutant +5 -1
- data/config/flay.yml +1 -1
- data/lib/mutant.rb +18 -17
- data/lib/mutant/actor.rb +1 -7
- data/lib/mutant/actor/env.rb +0 -4
- data/lib/mutant/actor/mailbox.rb +0 -4
- data/lib/mutant/actor/receiver.rb +0 -4
- data/lib/mutant/actor/sender.rb +0 -2
- data/lib/mutant/ast.rb +1 -5
- data/lib/mutant/ast/meta/const.rb +0 -2
- data/lib/mutant/ast/meta/optarg.rb +0 -2
- data/lib/mutant/ast/meta/send.rb +0 -12
- data/lib/mutant/ast/named_children.rb +0 -10
- data/lib/mutant/ast/sexp.rb +1 -5
- data/lib/mutant/cli.rb +19 -38
- data/lib/mutant/color.rb +1 -7
- data/lib/mutant/config.rb +11 -7
- data/lib/mutant/context.rb +0 -4
- data/lib/mutant/context/scope.rb +0 -18
- data/lib/mutant/delegator.rb +0 -6
- data/lib/mutant/diff.rb +0 -18
- data/lib/mutant/env.rb +8 -24
- data/lib/mutant/env/bootstrap.rb +18 -41
- data/lib/mutant/expression.rb +0 -8
- data/lib/mutant/expression/method.rb +6 -7
- data/lib/mutant/expression/methods.rb +5 -9
- data/lib/mutant/expression/namespace.rb +0 -13
- data/lib/mutant/expression/parser.rb +0 -6
- data/lib/mutant/integration.rb +2 -20
- data/lib/mutant/isolation.rb +0 -4
- data/lib/mutant/loader.rb +20 -35
- data/lib/mutant/matcher.rb +1 -1
- data/lib/mutant/matcher/chain.rb +1 -3
- data/lib/mutant/matcher/compiler.rb +0 -8
- data/lib/mutant/matcher/config.rb +2 -10
- data/lib/mutant/matcher/filter.rb +1 -3
- data/lib/mutant/matcher/method.rb +4 -26
- data/lib/mutant/matcher/method/instance.rb +1 -7
- data/lib/mutant/matcher/method/singleton.rb +0 -12
- data/lib/mutant/matcher/methods.rb +1 -19
- data/lib/mutant/matcher/namespace.rb +1 -7
- data/lib/mutant/matcher/null.rb +1 -3
- data/lib/mutant/matcher/scope.rb +1 -5
- data/lib/mutant/matcher/static.rb +0 -2
- data/lib/mutant/meta.rb +0 -2
- data/lib/mutant/meta/example.rb +0 -28
- data/lib/mutant/meta/example/dsl.rb +2 -16
- data/lib/mutant/mutation.rb +9 -18
- data/lib/mutant/mutator.rb +0 -24
- data/lib/mutant/mutator/node.rb +1 -33
- data/lib/mutant/mutator/node/and_asgn.rb +0 -2
- data/lib/mutant/mutator/node/argument.rb +0 -10
- data/lib/mutant/mutator/node/arguments.rb +0 -12
- data/lib/mutant/mutator/node/begin.rb +0 -4
- data/lib/mutant/mutator/node/binary.rb +2 -11
- data/lib/mutant/mutator/node/block.rb +0 -6
- data/lib/mutant/mutator/node/break.rb +0 -2
- data/lib/mutant/mutator/node/case.rb +0 -6
- data/lib/mutant/mutator/node/conditional_loop.rb +0 -2
- data/lib/mutant/mutator/node/const.rb +1 -3
- data/lib/mutant/mutator/node/define.rb +4 -11
- data/lib/mutant/mutator/node/defined.rb +0 -2
- data/lib/mutant/mutator/node/dstr.rb +0 -2
- data/lib/mutant/mutator/node/dsym.rb +0 -2
- data/lib/mutant/mutator/node/generic.rb +1 -3
- data/lib/mutant/mutator/node/if.rb +0 -8
- data/lib/mutant/mutator/node/kwbegin.rb +0 -2
- data/lib/mutant/mutator/node/literal/array.rb +0 -4
- data/lib/mutant/mutator/node/literal/boolean.rb +0 -2
- data/lib/mutant/mutator/node/literal/fixnum.rb +0 -6
- data/lib/mutant/mutator/node/literal/float.rb +0 -6
- data/lib/mutant/mutator/node/literal/hash.rb +0 -6
- data/lib/mutant/mutator/node/literal/nil.rb +0 -2
- data/lib/mutant/mutator/node/literal/range.rb +0 -8
- data/lib/mutant/mutator/node/literal/regex.rb +0 -4
- data/lib/mutant/mutator/node/literal/string.rb +0 -2
- data/lib/mutant/mutator/node/literal/symbol.rb +0 -2
- data/lib/mutant/mutator/node/masgn.rb +0 -2
- data/lib/mutant/mutator/node/match_current_line.rb +0 -2
- data/lib/mutant/mutator/node/mlhs.rb +0 -2
- data/lib/mutant/mutator/node/named_value/access.rb +0 -8
- data/lib/mutant/mutator/node/named_value/constant_assignment.rb +1 -7
- data/lib/mutant/mutator/node/named_value/variable_assignment.rb +0 -4
- data/lib/mutant/mutator/node/next.rb +0 -2
- data/lib/mutant/mutator/node/noop.rb +0 -2
- data/lib/mutant/mutator/node/nthref.rb +0 -2
- data/lib/mutant/mutator/node/op_asgn.rb +0 -2
- data/lib/mutant/mutator/node/or_asgn.rb +0 -2
- data/lib/mutant/mutator/node/resbody.rb +0 -4
- data/lib/mutant/mutator/node/rescue.rb +0 -10
- data/lib/mutant/mutator/node/return.rb +0 -2
- data/lib/mutant/mutator/node/send.rb +4 -32
- data/lib/mutant/mutator/node/send/attribute_assignment.rb +0 -6
- data/lib/mutant/mutator/node/send/binary.rb +0 -6
- data/lib/mutant/mutator/node/send/index.rb +0 -6
- data/lib/mutant/mutator/node/splat.rb +0 -2
- data/lib/mutant/mutator/node/super.rb +0 -2
- data/lib/mutant/mutator/node/when.rb +0 -10
- data/lib/mutant/mutator/node/yield.rb +0 -2
- data/lib/mutant/mutator/node/zsuper.rb +0 -2
- data/lib/mutant/mutator/registry.rb +0 -6
- data/lib/mutant/mutator/util.rb +0 -4
- data/lib/mutant/mutator/util/array.rb +0 -6
- data/lib/mutant/mutator/util/symbol.rb +0 -2
- data/lib/mutant/parallel.rb +21 -17
- data/lib/mutant/parallel/master.rb +0 -28
- data/lib/mutant/parallel/source.rb +0 -10
- data/lib/mutant/parallel/worker.rb +15 -10
- data/lib/mutant/parser.rb +23 -0
- data/lib/mutant/reporter.rb +5 -8
- data/lib/mutant/reporter/cli.rb +1 -15
- data/lib/mutant/reporter/cli/format.rb +3 -25
- data/lib/mutant/reporter/cli/printer.rb +0 -18
- data/lib/mutant/reporter/cli/printer/config.rb +0 -2
- data/lib/mutant/reporter/cli/printer/env_progress.rb +0 -2
- data/lib/mutant/reporter/cli/printer/env_result.rb +0 -2
- data/lib/mutant/reporter/cli/printer/mutation_progress_result.rb +0 -4
- data/lib/mutant/reporter/cli/printer/mutation_result.rb +0 -16
- data/lib/mutant/reporter/cli/printer/status.rb +0 -6
- data/lib/mutant/reporter/cli/printer/status_progressive.rb +0 -4
- data/lib/mutant/reporter/cli/printer/subject_progress.rb +0 -8
- data/lib/mutant/reporter/cli/printer/subject_result.rb +0 -2
- data/lib/mutant/reporter/cli/printer/test_result.rb +0 -2
- data/lib/mutant/reporter/cli/tput.rb +0 -4
- data/lib/mutant/repository.rb +4 -22
- data/lib/mutant/require_highjack.rb +0 -2
- data/lib/mutant/result.rb +23 -43
- data/lib/mutant/runner.rb +7 -20
- data/lib/mutant/runner/sink.rb +43 -86
- data/lib/mutant/selector.rb +0 -2
- data/lib/mutant/selector/expression.rb +0 -2
- data/lib/mutant/subject.rb +0 -22
- data/lib/mutant/subject/method.rb +2 -10
- data/lib/mutant/subject/method/instance.rb +0 -6
- data/lib/mutant/subject/method/singleton.rb +0 -2
- data/lib/mutant/test.rb +4 -3
- data/lib/mutant/version.rb +1 -1
- data/lib/mutant/warning_filter.rb +0 -10
- data/lib/mutant/zombifier.rb +5 -20
- data/meta/or_asgn.rb +6 -0
- data/meta/send.rb +29 -0
- data/mutant-rspec.gemspec +1 -1
- data/spec/integration/mutant/rspec_spec.rb +1 -1
- data/spec/integrations.yml +2 -3
- data/spec/shared/method_matcher_behavior.rb +7 -7
- data/spec/spec_helper.rb +2 -9
- data/spec/support/corpus.rb +37 -30
- data/spec/support/rb_bug.rb +1 -2
- data/spec/support/ruby_vm.rb +6 -3
- data/spec/support/shared_context.rb +19 -20
- data/spec/unit/mutant/actor/binding_spec.rb +6 -6
- data/spec/unit/mutant/actor/env_spec.rb +2 -2
- data/spec/unit/mutant/actor/mailbox_spec.rb +6 -6
- data/spec/unit/mutant/actor/message_spec.rb +2 -2
- data/spec/unit/mutant/actor/receiver_spec.rb +4 -4
- data/spec/unit/mutant/actor/sender_spec.rb +6 -6
- data/spec/unit/mutant/ast_spec.rb +9 -0
- data/spec/unit/mutant/cli_spec.rb +16 -10
- data/spec/unit/mutant/context/scope/root_spec.rb +1 -1
- data/spec/unit/mutant/context/scope/unqualified_name_spec.rb +1 -1
- data/spec/unit/mutant/context/scope_spec.rb +3 -3
- data/spec/unit/mutant/context_spec.rb +0 -22
- data/spec/unit/mutant/env/boostrap_spec.rb +34 -41
- data/spec/unit/mutant/env_spec.rb +74 -32
- data/spec/unit/mutant/integration/rspec_spec.rb +23 -17
- data/spec/unit/mutant/integration_spec.rb +4 -4
- data/spec/unit/mutant/isolation_spec.rb +4 -4
- data/spec/unit/mutant/loader_spec.rb +42 -0
- data/spec/unit/mutant/matcher/compiler_spec.rb +3 -3
- data/spec/unit/mutant/matcher/config_spec.rb +1 -1
- data/spec/unit/mutant/matcher/method/instance_spec.rb +8 -1
- data/spec/unit/mutant/matcher/method/singleton_spec.rb +8 -1
- data/spec/unit/mutant/matcher/namespace_spec.rb +7 -8
- data/spec/unit/mutant/matcher/null_spec.rb +3 -2
- data/spec/unit/mutant/mutation_spec.rb +11 -5
- data/spec/unit/mutant/mutator/registry_spec.rb +1 -1
- data/spec/unit/mutant/parallel/master_spec.rb +9 -9
- data/spec/unit/mutant/parallel/source/array_spec.rb +3 -3
- data/spec/unit/mutant/parallel/worker_spec.rb +5 -5
- data/spec/unit/mutant/parallel_spec.rb +4 -4
- data/spec/unit/mutant/parser_spec.rb +24 -0
- data/spec/unit/mutant/reporter/cli/printer_spec.rb +3 -3
- data/spec/unit/mutant/reporter/cli/tput_spec.rb +2 -2
- data/spec/unit/mutant/reporter/cli_spec.rb +7 -7
- data/spec/unit/mutant/reporter/null_spec.rb +5 -4
- data/spec/unit/mutant/repository/diff_spec.rb +30 -18
- data/spec/unit/mutant/repository/subject_filter_spec.rb +5 -5
- data/spec/unit/mutant/require_highjack_spec.rb +1 -1
- data/spec/unit/mutant/result/env_spec.rb +9 -9
- data/spec/unit/mutant/result/subject_spec.rb +5 -5
- data/spec/unit/mutant/runner/driver_spec.rb +4 -4
- data/spec/unit/mutant/runner/{sink/mutation_spec.rb → sink_spec.rb} +16 -4
- data/spec/unit/mutant/runner_spec.rb +31 -31
- data/spec/unit/mutant/selector/expression_spec.rb +8 -8
- data/spec/unit/mutant/subject/method/instance_spec.rb +9 -3
- data/spec/unit/mutant/subject/method/singleton_spec.rb +1 -1
- data/spec/unit/mutant/subject_spec.rb +1 -5
- data/spec/unit/mutant_spec.rb +3 -3
- metadata +9 -15
- data/config/mutant.yml +0 -14
- data/lib/mutant/cache.rb +0 -29
- data/lib/mutant/reporter/trace.rb +0 -36
- data/spec/support/rspec.rb +0 -21
- data/spec/unit/mutant/cache_spec.rb +0 -22
- data/spec/unit/mutant/loader/eval_spec.rb +0 -44
- data/spec/unit/mutant/reporter/trace_spec.rb +0 -21
- data/test_app/Gemfile.rspec3.2 +0 -7
@@ -9,8 +9,6 @@ module Mutant
|
|
9
9
|
# Run DSL on block
|
10
10
|
#
|
11
11
|
# @return [Example]
|
12
|
-
#
|
13
|
-
# @api private
|
14
12
|
def self.run(file, block)
|
15
13
|
instance = new(file)
|
16
14
|
instance.instance_eval(&block)
|
@@ -20,8 +18,6 @@ module Mutant
|
|
20
18
|
# Initialize DSL context
|
21
19
|
#
|
22
20
|
# @return [undefined]
|
23
|
-
#
|
24
|
-
# @api private
|
25
21
|
def initialize(file)
|
26
22
|
@file = file
|
27
23
|
@source = nil
|
@@ -34,8 +30,6 @@ module Mutant
|
|
34
30
|
#
|
35
31
|
# @raise [RuntimeError]
|
36
32
|
# in case example cannot be build
|
37
|
-
#
|
38
|
-
# @api private
|
39
33
|
def example
|
40
34
|
fail 'source not defined' unless @source
|
41
35
|
Example.new(@file, @source, @expected)
|
@@ -48,8 +42,6 @@ module Mutant
|
|
48
42
|
# @param [String,Parser::AST::Node] input
|
49
43
|
#
|
50
44
|
# @return [self]
|
51
|
-
#
|
52
|
-
# @api private
|
53
45
|
def source(input)
|
54
46
|
fail 'source already defined' if @source
|
55
47
|
@source = node(input)
|
@@ -62,8 +54,6 @@ module Mutant
|
|
62
54
|
# @param [String,Parser::AST::Node] input
|
63
55
|
#
|
64
56
|
# @return [self]
|
65
|
-
#
|
66
|
-
# @api private
|
67
57
|
def mutation(input)
|
68
58
|
node = node(input)
|
69
59
|
if @expected.include?(node)
|
@@ -77,8 +67,6 @@ module Mutant
|
|
77
67
|
# Add singleton mutations
|
78
68
|
#
|
79
69
|
# @return [undefined]
|
80
|
-
#
|
81
|
-
# @api private
|
82
70
|
def singleton_mutations
|
83
71
|
mutation('nil')
|
84
72
|
mutation('self')
|
@@ -92,13 +80,11 @@ module Mutant
|
|
92
80
|
#
|
93
81
|
# @raise [RuntimeError]
|
94
82
|
# in case input cannot be coerced
|
95
|
-
#
|
96
|
-
# @api private
|
97
83
|
def node(input)
|
98
84
|
case input
|
99
85
|
when String
|
100
|
-
Unparser::Preprocessor.run(Parser::CurrentRuby.parse(input))
|
101
|
-
when Parser::AST::Node
|
86
|
+
Unparser::Preprocessor.run(::Parser::CurrentRuby.parse(input))
|
87
|
+
when ::Parser::AST::Node
|
102
88
|
input
|
103
89
|
else
|
104
90
|
fail "Cannot coerce to node: #{source.inspect}"
|
data/lib/mutant/mutation.rb
CHANGED
@@ -10,8 +10,6 @@ module Mutant
|
|
10
10
|
# Identification string
|
11
11
|
#
|
12
12
|
# @return [String]
|
13
|
-
#
|
14
|
-
# @api private
|
15
13
|
def identification
|
16
14
|
"#{self.class::SYMBOL}:#{subject.identification}:#{code}"
|
17
15
|
end
|
@@ -20,8 +18,6 @@ module Mutant
|
|
20
18
|
# Mutation code
|
21
19
|
#
|
22
20
|
# @return [String]
|
23
|
-
#
|
24
|
-
# @api private
|
25
21
|
def code
|
26
22
|
sha1[CODE_RANGE]
|
27
23
|
end
|
@@ -30,8 +26,6 @@ module Mutant
|
|
30
26
|
# Normalized mutation source
|
31
27
|
#
|
32
28
|
# @return [String]
|
33
|
-
#
|
34
|
-
# @api private
|
35
29
|
def source
|
36
30
|
Unparser.unparse(node)
|
37
31
|
end
|
@@ -40,8 +34,6 @@ module Mutant
|
|
40
34
|
# Normalized original source
|
41
35
|
#
|
42
36
|
# @return [String]
|
43
|
-
#
|
44
|
-
# @api private
|
45
37
|
def original_source
|
46
38
|
subject.source
|
47
39
|
end
|
@@ -51,20 +43,23 @@ module Mutant
|
|
51
43
|
# @param [Array<Report::Test>] test_reports
|
52
44
|
#
|
53
45
|
# @return [Boolean]
|
54
|
-
#
|
55
|
-
# @api private
|
56
46
|
def self.success?(test_result)
|
57
47
|
self::TEST_PASS_SUCCESS.equal?(test_result.passed)
|
58
48
|
end
|
59
49
|
|
60
50
|
# Insert mutated node
|
61
51
|
#
|
62
|
-
# @
|
52
|
+
# @param kernel [Kernel]
|
63
53
|
#
|
64
|
-
# @
|
65
|
-
def insert
|
54
|
+
# @return [self]
|
55
|
+
def insert(kernel)
|
66
56
|
subject.prepare
|
67
|
-
Loader
|
57
|
+
Loader.call(
|
58
|
+
binding: TOPLEVEL_BINDING,
|
59
|
+
kernel: kernel,
|
60
|
+
node: root,
|
61
|
+
subject: subject
|
62
|
+
)
|
68
63
|
self
|
69
64
|
end
|
70
65
|
|
@@ -73,8 +68,6 @@ module Mutant
|
|
73
68
|
# SHA1 sum of source and subject identification
|
74
69
|
#
|
75
70
|
# @return [String]
|
76
|
-
#
|
77
|
-
# @api private
|
78
71
|
def sha1
|
79
72
|
Digest::SHA1.hexdigest(subject.identification + CODE_DELIMITER + source)
|
80
73
|
end
|
@@ -83,8 +76,6 @@ module Mutant
|
|
83
76
|
# Mutated root node
|
84
77
|
#
|
85
78
|
# @return [Parser::AST::Node]
|
86
|
-
#
|
87
|
-
# @api private
|
88
79
|
def root
|
89
80
|
subject.context.root(node)
|
90
81
|
end
|
data/lib/mutant/mutator.rb
CHANGED
@@ -11,8 +11,6 @@ module Mutant
|
|
11
11
|
# @param [Mutator] parent
|
12
12
|
#
|
13
13
|
# @return [self]
|
14
|
-
#
|
15
|
-
# @api private
|
16
14
|
def self.each(input, parent = nil, &block)
|
17
15
|
return to_enum(__method__, input, parent) unless block_given?
|
18
16
|
REGISTRY.lookup(input).new(input, parent, block)
|
@@ -23,8 +21,6 @@ module Mutant
|
|
23
21
|
# Register node class handler
|
24
22
|
#
|
25
23
|
# @return [undefined]
|
26
|
-
#
|
27
|
-
# @api private
|
28
24
|
def self.handle(*types)
|
29
25
|
types.each do |type|
|
30
26
|
REGISTRY.register(type, self)
|
@@ -35,15 +31,11 @@ module Mutant
|
|
35
31
|
# Mutation input
|
36
32
|
#
|
37
33
|
# @return [Object]
|
38
|
-
#
|
39
|
-
# @api private
|
40
34
|
attr_reader :input
|
41
35
|
|
42
36
|
# Parent context of input
|
43
37
|
#
|
44
38
|
# @return [Object]
|
45
|
-
#
|
46
|
-
# @api private
|
47
39
|
attr_reader :parent
|
48
40
|
|
49
41
|
private
|
@@ -55,8 +47,6 @@ module Mutant
|
|
55
47
|
# @param [#call(node)] block
|
56
48
|
#
|
57
49
|
# @return [undefined]
|
58
|
-
#
|
59
|
-
# @api private
|
60
50
|
def initialize(input, parent, block)
|
61
51
|
@input, @parent, @block = input, parent, block
|
62
52
|
@seen = Set.new
|
@@ -69,8 +59,6 @@ module Mutant
|
|
69
59
|
# @param [Object] object
|
70
60
|
#
|
71
61
|
# @return [Boolean]
|
72
|
-
#
|
73
|
-
# @api private
|
74
62
|
def new?(object)
|
75
63
|
!@seen.include?(object)
|
76
64
|
end
|
@@ -80,8 +68,6 @@ module Mutant
|
|
80
68
|
# @param [Object] object
|
81
69
|
#
|
82
70
|
# @return [undefined]
|
83
|
-
#
|
84
|
-
# @api private
|
85
71
|
def guard(object)
|
86
72
|
@seen << object
|
87
73
|
end
|
@@ -89,8 +75,6 @@ module Mutant
|
|
89
75
|
# Dispatch node generations
|
90
76
|
#
|
91
77
|
# @return [undefined]
|
92
|
-
#
|
93
|
-
# @api private
|
94
78
|
abstract_method :dispatch
|
95
79
|
|
96
80
|
# Emit generated mutation if object is not equivalent to input
|
@@ -98,8 +82,6 @@ module Mutant
|
|
98
82
|
# @param [Object] object
|
99
83
|
#
|
100
84
|
# @return [undefined]
|
101
|
-
#
|
102
|
-
# @api private
|
103
85
|
def emit(object)
|
104
86
|
return unless new?(object)
|
105
87
|
|
@@ -113,8 +95,6 @@ module Mutant
|
|
113
95
|
# @param [Parser::AST::Node] node
|
114
96
|
#
|
115
97
|
# @return [self]
|
116
|
-
#
|
117
|
-
# @api private
|
118
98
|
def emit!(node)
|
119
99
|
@block.call(node)
|
120
100
|
self
|
@@ -123,8 +103,6 @@ module Mutant
|
|
123
103
|
# Run input with mutator
|
124
104
|
#
|
125
105
|
# @return [undefined]
|
126
|
-
#
|
127
|
-
# @api private
|
128
106
|
def run(mutator)
|
129
107
|
mutator.new(input, self, method(:emit))
|
130
108
|
end
|
@@ -132,8 +110,6 @@ module Mutant
|
|
132
110
|
# Shortcut to create a new unfrozen duplicate of input
|
133
111
|
#
|
134
112
|
# @return [Object]
|
135
|
-
#
|
136
|
-
# @api private
|
137
113
|
def dup_input
|
138
114
|
input.dup
|
139
115
|
end
|
data/lib/mutant/mutator/node.rb
CHANGED
@@ -17,8 +17,6 @@ module Mutant
|
|
17
17
|
# @param [Fixnum] index
|
18
18
|
#
|
19
19
|
# @return [undefined]
|
20
|
-
#
|
21
|
-
# @api private
|
22
20
|
def self.define_named_child(name, index)
|
23
21
|
super
|
24
22
|
|
@@ -37,22 +35,16 @@ module Mutant
|
|
37
35
|
# Node to mutate
|
38
36
|
#
|
39
37
|
# @return [Parser::AST::Node]
|
40
|
-
#
|
41
|
-
# @api private
|
42
38
|
alias_method :node, :input
|
43
39
|
|
44
40
|
# Duplicate of original
|
45
41
|
#
|
46
42
|
# @return [Parser::AST::Node]
|
47
|
-
#
|
48
|
-
# @api private
|
49
43
|
alias_method :dup_node, :dup_input
|
50
44
|
|
51
45
|
# Original nodes children
|
52
46
|
#
|
53
47
|
# @return [Array<Parser::AST::Node>]
|
54
|
-
#
|
55
|
-
# @api private
|
56
48
|
def children
|
57
49
|
node.children
|
58
50
|
end
|
@@ -62,8 +54,6 @@ module Mutant
|
|
62
54
|
# @param [Fixnum] index
|
63
55
|
#
|
64
56
|
# @return [undefined]
|
65
|
-
#
|
66
|
-
# @api private
|
67
57
|
def mutate_child(index, mutator = Mutator, &block)
|
68
58
|
block ||= TAUTOLOGY
|
69
59
|
child = children.at(index)
|
@@ -78,8 +68,6 @@ module Mutant
|
|
78
68
|
# @param [Fixnum] index
|
79
69
|
#
|
80
70
|
# @return [undefined]
|
81
|
-
#
|
82
|
-
# @api private
|
83
71
|
def delete_child(index)
|
84
72
|
dup_children = children.dup
|
85
73
|
dup_children.delete_at(index)
|
@@ -92,8 +80,6 @@ module Mutant
|
|
92
80
|
# @param [Parser::AST::Node] node
|
93
81
|
#
|
94
82
|
# @return [undefined]
|
95
|
-
#
|
96
|
-
# @api private
|
97
83
|
def emit_child_update(index, node)
|
98
84
|
new_children = children.dup
|
99
85
|
new_children[index] = node
|
@@ -105,17 +91,13 @@ module Mutant
|
|
105
91
|
# @param [Array<Parser::AST::Node>] children
|
106
92
|
#
|
107
93
|
# @return [undefined]
|
108
|
-
#
|
109
|
-
# @api private
|
110
94
|
def emit_type(*children)
|
111
|
-
emit(Parser::AST::Node.new(node.type, children))
|
95
|
+
emit(::Parser::AST::Node.new(node.type, children))
|
112
96
|
end
|
113
97
|
|
114
98
|
# Emit singleton literals
|
115
99
|
#
|
116
100
|
# @return [undefined]
|
117
|
-
#
|
118
|
-
# @api private
|
119
101
|
def emit_singletons
|
120
102
|
emit_nil
|
121
103
|
emit_self
|
@@ -124,8 +106,6 @@ module Mutant
|
|
124
106
|
# Emit a literal self
|
125
107
|
#
|
126
108
|
# @return [undefined]
|
127
|
-
#
|
128
|
-
# @api private
|
129
109
|
def emit_self
|
130
110
|
emit(N_SELF)
|
131
111
|
end
|
@@ -133,8 +113,6 @@ module Mutant
|
|
133
113
|
# Emit a literal nil
|
134
114
|
#
|
135
115
|
# @return [undefined]
|
136
|
-
#
|
137
|
-
# @api private
|
138
116
|
def emit_nil
|
139
117
|
emit(N_NIL) unless asgn_left?
|
140
118
|
end
|
@@ -144,8 +122,6 @@ module Mutant
|
|
144
122
|
# @param [Array<Object>] values
|
145
123
|
#
|
146
124
|
# @return [undefined]
|
147
|
-
#
|
148
|
-
# @api private
|
149
125
|
def emit_values(values)
|
150
126
|
values.each do |value|
|
151
127
|
emit_type(value)
|
@@ -159,8 +135,6 @@ module Mutant
|
|
159
135
|
#
|
160
136
|
# @return [nil]
|
161
137
|
# otherwise
|
162
|
-
#
|
163
|
-
# @api private
|
164
138
|
def parent_node
|
165
139
|
parent.node if parent
|
166
140
|
end
|
@@ -172,8 +146,6 @@ module Mutant
|
|
172
146
|
#
|
173
147
|
# @return [nil]
|
174
148
|
# otherwise
|
175
|
-
#
|
176
|
-
# @api private
|
177
149
|
def parent_type
|
178
150
|
parent_node.type if parent_node
|
179
151
|
end
|
@@ -181,8 +153,6 @@ module Mutant
|
|
181
153
|
# Test if the node is the left of an or_asgn or op_asgn
|
182
154
|
#
|
183
155
|
# @return [Boolean]
|
184
|
-
#
|
185
|
-
# @api private
|
186
156
|
def asgn_left?
|
187
157
|
AST::Types::OP_ASSIGN.include?(parent_type) && parent.node.children.first.equal?(node)
|
188
158
|
end
|
@@ -192,8 +162,6 @@ module Mutant
|
|
192
162
|
# @param [Range] range
|
193
163
|
#
|
194
164
|
# @return [Enumerable<Fixnum>]
|
195
|
-
#
|
196
|
-
# @api private
|
197
165
|
def children_indices(range)
|
198
166
|
range_end = range.end
|
199
167
|
last_index = range_end >= 0 ? range_end : children.length + range_end
|
@@ -15,8 +15,6 @@ module Mutant
|
|
15
15
|
# Perform dispatch
|
16
16
|
#
|
17
17
|
# @return [undefined]
|
18
|
-
#
|
19
|
-
# @api private
|
20
18
|
def dispatch
|
21
19
|
emit_name_mutation
|
22
20
|
end
|
@@ -24,8 +22,6 @@ module Mutant
|
|
24
22
|
# Emit name mutations
|
25
23
|
#
|
26
24
|
# @return [undefined]
|
27
|
-
#
|
28
|
-
# @api private
|
29
25
|
def emit_name_mutation
|
30
26
|
return if skip?
|
31
27
|
emit_name(:"#{UNDERSCORE}#{name}")
|
@@ -34,8 +30,6 @@ module Mutant
|
|
34
30
|
# Test if argument mutation is skipped
|
35
31
|
#
|
36
32
|
# @return [Boolean]
|
37
|
-
#
|
38
|
-
# @api private
|
39
33
|
def skip?
|
40
34
|
name.to_s.start_with?(UNDERSCORE)
|
41
35
|
end
|
@@ -52,8 +46,6 @@ module Mutant
|
|
52
46
|
# Perform dispatch
|
53
47
|
#
|
54
48
|
# @return [undefined]
|
55
|
-
#
|
56
|
-
# @api private
|
57
49
|
def dispatch
|
58
50
|
emit_name_mutation
|
59
51
|
emit_required_mutation
|
@@ -63,8 +55,6 @@ module Mutant
|
|
63
55
|
# Emit required mutation
|
64
56
|
#
|
65
57
|
# @return [undefined]
|
66
|
-
#
|
67
|
-
# @api private
|
68
58
|
def emit_required_mutation
|
69
59
|
emit(s(:arg, name))
|
70
60
|
end
|
@@ -11,8 +11,6 @@ module Mutant
|
|
11
11
|
# Perform dispatch
|
12
12
|
#
|
13
13
|
# @return [undefined]
|
14
|
-
#
|
15
|
-
# @api private
|
16
14
|
def dispatch
|
17
15
|
emit_argument_presence
|
18
16
|
emit_argument_mutations
|
@@ -22,8 +20,6 @@ module Mutant
|
|
22
20
|
# Emit argument presence mutation
|
23
21
|
#
|
24
22
|
# @return [undefined]
|
25
|
-
#
|
26
|
-
# @api private
|
27
23
|
def emit_argument_presence
|
28
24
|
emit_type
|
29
25
|
Mutator::Util::Array::Presence.each(children, self) do |children|
|
@@ -34,8 +30,6 @@ module Mutant
|
|
34
30
|
# Emit argument mutations
|
35
31
|
#
|
36
32
|
# @return [undefined]
|
37
|
-
#
|
38
|
-
# @api private
|
39
33
|
def emit_argument_mutations
|
40
34
|
children.each_with_index do |child, index|
|
41
35
|
Mutator.each(child) do |mutant|
|
@@ -50,8 +44,6 @@ module Mutant
|
|
50
44
|
# @param [Parser::AST::Node]
|
51
45
|
#
|
52
46
|
# @return [Boolean]
|
53
|
-
#
|
54
|
-
# @api private
|
55
47
|
def invalid_argument_replacement?(mutant, index)
|
56
48
|
original = children.fetch(index)
|
57
49
|
|
@@ -63,8 +55,6 @@ module Mutant
|
|
63
55
|
# Emit mlhs expansions
|
64
56
|
#
|
65
57
|
# @return [undefined]
|
66
|
-
#
|
67
|
-
# @api private
|
68
58
|
def emit_mlhs_expansion
|
69
59
|
mlhs_childs_with_index.each do |child, index|
|
70
60
|
dup_children = children.dup
|
@@ -77,8 +67,6 @@ module Mutant
|
|
77
67
|
# Multiple left hand side childs
|
78
68
|
#
|
79
69
|
# @return [Enumerable<Parser::AST::Node, Fixnum>]
|
80
|
-
#
|
81
|
-
# @api private
|
82
70
|
def mlhs_childs_with_index
|
83
71
|
children.each_with_index.select do |child, _index|
|
84
72
|
n_mlhs?(child)
|