mutant 0.2.20 → 0.3.0.beta2
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 +7 -0
- data/.travis.yml +10 -11
- data/Changelog.md +93 -38
- data/Gemfile +3 -1
- data/Gemfile.devtools +16 -20
- data/Guardfile +1 -1
- data/README.md +36 -16
- data/Rakefile +21 -2
- data/TODO +11 -7
- data/bin/mutant +4 -0
- data/bin/zombie +4 -0
- data/config/devtools.yml +2 -0
- data/config/flay.yml +2 -2
- data/config/flog.yml +1 -1
- data/config/{site.reek → reek.yml} +94 -70
- data/lib/mutant/cli/classifier/method.rb +100 -0
- data/lib/mutant/cli/classifier/namespace.rb +47 -0
- data/lib/mutant/cli/classifier/scope.rb +35 -0
- data/lib/mutant/cli/classifier.rb +141 -0
- data/lib/mutant/cli.rb +115 -162
- data/lib/mutant/color.rb +2 -2
- data/lib/mutant/config.rb +27 -0
- data/lib/mutant/constants.rb +32 -17
- data/lib/mutant/context/scope.rb +33 -51
- data/lib/mutant/context.rb +8 -19
- data/lib/mutant/differ.rb +5 -5
- data/lib/mutant/helper.rb +2 -17
- data/lib/mutant/killer/forked.rb +44 -0
- data/lib/mutant/killer/forking.rb +3 -57
- data/lib/mutant/killer/rspec.rb +16 -20
- data/lib/mutant/killer/static.rb +6 -7
- data/lib/mutant/killer.rb +48 -74
- data/lib/mutant/loader.rb +6 -6
- data/lib/mutant/matcher/chain.rb +4 -25
- data/lib/mutant/matcher/method/instance.rb +14 -24
- data/lib/mutant/matcher/method/singleton.rb +35 -46
- data/lib/mutant/matcher/method.rb +95 -83
- data/lib/mutant/matcher/{scope_methods.rb → methods.rb} +53 -76
- data/lib/mutant/matcher/namespace.rb +71 -0
- data/lib/mutant/matcher/scope.rb +34 -0
- data/lib/mutant/matcher.rb +24 -34
- data/lib/mutant/mutation/evil.rb +35 -0
- data/lib/mutant/mutation/filter/code.rb +7 -28
- data/lib/mutant/mutation/filter/regexp.rb +6 -18
- data/lib/mutant/mutation/filter/whitelist.rb +5 -4
- data/lib/mutant/mutation/filter.rb +10 -9
- data/lib/mutant/mutation/neutral.rb +35 -0
- data/lib/mutant/mutation.rb +21 -61
- data/lib/mutant/mutator/node/argument.rb +88 -0
- data/lib/mutant/mutator/node/arguments.rb +52 -0
- data/lib/mutant/mutator/node/assignment.rb +34 -38
- data/lib/mutant/mutator/node/begin.rb +33 -0
- data/lib/mutant/mutator/node/block.rb +14 -14
- data/lib/mutant/mutator/node/case.rb +59 -0
- data/lib/mutant/mutator/node/define.rb +26 -22
- data/lib/mutant/mutator/node/if.rb +31 -71
- data/lib/mutant/mutator/node/literal/array.rb +25 -9
- data/lib/mutant/mutator/node/literal/boolean.rb +13 -30
- data/lib/mutant/mutator/node/literal/dynamic.rb +6 -5
- data/lib/mutant/mutator/node/literal/fixnum.rb +18 -7
- data/lib/mutant/mutator/node/literal/float.rb +15 -8
- data/lib/mutant/mutator/node/literal/hash.rb +33 -52
- data/lib/mutant/mutator/node/literal/nil.rb +8 -7
- data/lib/mutant/mutator/node/literal/range.rb +25 -50
- data/lib/mutant/mutator/node/literal/regex.rb +15 -23
- data/lib/mutant/mutator/node/literal/string.rb +7 -6
- data/lib/mutant/mutator/node/literal/symbol.rb +7 -6
- data/lib/mutant/mutator/node/literal.rb +4 -46
- data/lib/mutant/mutator/node/mlhs.rb +27 -0
- data/lib/mutant/mutator/node/noop.rb +18 -43
- data/lib/mutant/mutator/node/return.rb +8 -8
- data/lib/mutant/mutator/node/send/binary.rb +31 -0
- data/lib/mutant/mutator/node/send.rb +106 -72
- data/lib/mutant/mutator/node/super.rb +15 -20
- data/lib/mutant/mutator/node/when.rb +32 -7
- data/lib/mutant/mutator/node/while.rb +9 -7
- data/lib/mutant/mutator/node.rb +116 -66
- data/lib/mutant/mutator/registry.rb +14 -11
- data/lib/mutant/mutator/util/array.rb +9 -9
- data/lib/mutant/mutator/util/symbol.rb +6 -20
- data/lib/mutant/mutator/util.rb +6 -3
- data/lib/mutant/mutator.rb +12 -28
- data/lib/mutant/node_helpers.rb +28 -0
- data/lib/mutant/random.rb +3 -2
- data/lib/mutant/reporter/cli/printer/config.rb +174 -0
- data/lib/mutant/reporter/cli/printer/killer.rb +42 -0
- data/lib/mutant/reporter/cli/printer/mutation.rb +55 -0
- data/lib/mutant/reporter/cli/printer/subject.rb +147 -0
- data/lib/mutant/reporter/cli/printer.rb +165 -0
- data/lib/mutant/reporter/cli.rb +9 -277
- data/lib/mutant/reporter/null.rb +6 -30
- data/lib/mutant/reporter.rb +6 -73
- data/lib/mutant/runner/config.rb +82 -0
- data/lib/mutant/runner/mutation.rb +58 -0
- data/lib/mutant/runner/subject.rb +81 -0
- data/lib/mutant/runner.rb +42 -92
- data/lib/mutant/singleton_methods.rb +2 -2
- data/lib/mutant/strategy/method_expansion.rb +51 -0
- data/lib/mutant/strategy/rspec/dm2/lookup/method.rb +142 -0
- data/lib/mutant/strategy/rspec/dm2/lookup.rb +61 -0
- data/lib/mutant/strategy/rspec/dm2.rb +22 -0
- data/lib/mutant/strategy/rspec.rb +20 -22
- data/lib/mutant/strategy/static.rb +18 -0
- data/lib/mutant/strategy.rb +15 -50
- data/lib/mutant/subject/method.rb +100 -0
- data/lib/mutant/subject.rb +18 -49
- data/lib/mutant/support/method_object.rb +4 -2
- data/lib/mutant.rb +40 -35
- data/mutant.gemspec +9 -8
- data/spec/integration/mutant/rspec_killer_spec.rb +3 -3
- data/spec/integration/mutant/test_mutator_handles_types_spec.rb +9 -0
- data/spec/integration/mutant/zombie_spec.rb +1 -1
- data/spec/shared/method_matcher_behavior.rb +35 -0
- data/spec/shared/mutator_behavior.rb +63 -32
- data/spec/spec_helper.rb +13 -3
- data/spec/support/ice_nine_config.rb +8 -0
- data/spec/support/rspec.rb +1 -1
- data/spec/support/zombie.rb +1 -1
- data/spec/unit/mutant/cli/class_methods/new_spec.rb +42 -28
- data/spec/unit/mutant/cli/class_methods/run_spec.rb +15 -13
- data/spec/unit/mutant/cli/classifier/class_methods/build_spec.rb +44 -0
- data/spec/unit/mutant/context/scope/root_spec.rb +4 -4
- data/spec/unit/mutant/killer/rspec/class_methods/new_spec.rb +6 -5
- data/spec/unit/mutant/killer/success_predicate_spec.rb +28 -0
- data/spec/unit/mutant/loader/eval/class_methods/run_spec.rb +1 -1
- data/spec/unit/mutant/matcher/chain/each_spec.rb +1 -1
- data/spec/unit/mutant/matcher/chain/matchers_spec.rb +1 -1
- data/spec/unit/mutant/matcher/method/instance/each_spec.rb +112 -0
- data/spec/unit/mutant/matcher/method/singleton/each_spec.rb +93 -0
- data/spec/unit/mutant/matcher/methods/instance/each_spec.rb +59 -0
- data/spec/unit/mutant/matcher/methods/singleton/each_spec.rb +53 -0
- data/spec/unit/mutant/matcher/namespace/each_spec.rb +37 -0
- data/spec/unit/mutant/mutator/node/begin/mutation_spec.rb +33 -0
- data/spec/unit/mutant/mutator/node/block/mutation_spec.rb +42 -14
- data/spec/unit/mutant/mutator/node/case/mutation_spec.rb +319 -0
- data/spec/unit/mutant/mutator/node/define/mutation_spec.rb +31 -27
- data/spec/unit/mutant/mutator/node/if/mutation_spec.rb +75 -0
- data/spec/unit/mutant/mutator/node/literal/fixnum_spec.rb +1 -1
- data/spec/unit/mutant/mutator/node/literal/hash_spec.rb +2 -2
- data/spec/unit/mutant/mutator/node/literal/nil_spec.rb +1 -3
- data/spec/unit/mutant/mutator/node/literal/regex_spec.rb +1 -9
- data/spec/unit/mutant/mutator/node/return/mutation_spec.rb +6 -2
- data/spec/unit/mutant/mutator/node/send/mutation_spec.rb +111 -108
- data/spec/unit/mutant/mutator/node/super/mutation_spec.rb +0 -33
- data/spec/unit/mutant/mutator/node/while/mutation_spec.rb +2 -2
- data/spec/unit/mutant/runner/config/subjects_spec.rb +38 -0
- data/spec/unit/mutant/runner/config/success_predicate_spec.rb +53 -0
- data/spec/unit/mutant/runner/failed_predicte_spec.rb +33 -0
- data/spec/unit/mutant/runner/mutation/killer_spec.rb +39 -0
- data/spec/unit/mutant/runner/subject/success_predicate_spec.rb +49 -0
- data/spec/unit/mutant/strategy/method_expansion/class_methods/run_spec.rb +49 -0
- data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/instance/spec_files_spec.rb +52 -0
- data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/singleton/spec_files_spec.rb +42 -0
- data/spec/unit/mutant/subject/context_spec.rb +6 -3
- data/spec/unit/mutant/subject/each_spec.rb +11 -8
- data/spec/unit/mutant/subject/node_spec.rb +6 -2
- data/test_app/spec/shared/method_filter_parse_behavior.rb +0 -2
- data/test_app/spec/shared/method_match_behavior.rb +1 -1
- data/test_app/spec/spec_helper.rb +4 -2
- metadata +101 -109
- data/config/roodi.yml +0 -26
- data/lib/mutant/matcher/method/classifier.rb +0 -141
- data/lib/mutant/matcher/object_space.rb +0 -114
- data/lib/mutant/mutator/node/actual_arguments.rb +0 -25
- data/lib/mutant/mutator/node/default_arguments.rb +0 -25
- data/lib/mutant/mutator/node/formal_arguments_19/default_mutations.rb +0 -33
- data/lib/mutant/mutator/node/formal_arguments_19/pattern_argument_expansion.rb +0 -35
- data/lib/mutant/mutator/node/formal_arguments_19/require_defaults.rb +0 -37
- data/lib/mutant/mutator/node/formal_arguments_19.rb +0 -41
- data/lib/mutant/mutator/node/iter_19.rb +0 -27
- data/lib/mutant/mutator/node/literal/empty_array.rb +0 -26
- data/lib/mutant/mutator/node/pattern_arguments.rb +0 -41
- data/lib/mutant/mutator/node/pattern_variable.rb +0 -23
- data/lib/mutant/mutator/node/receiver_case.rb +0 -122
- data/lib/mutant/mutator/node/send/binary_operator_method.rb +0 -61
- data/lib/mutant/mutator/node/send/with_arguments.rb +0 -81
- data/lib/mutant/reporter/stats.rb +0 -120
- data/lib/mutant/strategy/rspec/example_lookup.rb +0 -163
- data/spec/integration/mutant/method_matching_spec.rb +0 -269
- data/spec/shared/method_match_behavior.rb +0 -39
- data/spec/unit/mutant/killer/fail_ques_spec.rb +0 -39
- data/spec/unit/mutant/matcher/class_methods/from_string_spec.rb +0 -49
- data/spec/unit/mutant/matcher/class_methods/parse_spec.rb +0 -12
- data/spec/unit/mutant/matcher/method/class_methods/parse_spec.rb +0 -21
- data/spec/unit/mutant/matcher/method/classifier/class_methods/run_spec.rb +0 -52
- data/spec/unit/mutant/matcher/object_space/class_methods/parse_spec.rb +0 -24
- data/spec/unit/mutant/matcher/object_space/each_spec.rb +0 -31
- data/spec/unit/mutant/mutator/node/if_statement/mutation_spec.rb +0 -60
- data/spec/unit/mutant/mutator/node/receiver_case/mutation_spec.rb +0 -27
- data/spec/unit/mutant/strategy/rspec/example_lookup/spec_file_spec.rb +0 -236
- data/spec/unit/mutant/subject/class_methods/new_spec.rb +0 -13
- data/tasks/metrics/ci.rake +0 -7
- data/tasks/metrics/flay.rake +0 -41
- data/tasks/metrics/flog.rake +0 -43
- data/tasks/metrics/heckle.rake +0 -216
- data/tasks/metrics/metric_fu.rake +0 -31
- data/tasks/metrics/reek.rake +0 -15
- data/tasks/metrics/roodi.rake +0 -15
- data/tasks/metrics/yardstick.rake +0 -23
- data/tasks/spec.rake +0 -45
- data/tasks/yard.rake +0 -9
data/lib/mutant/helper.rb
CHANGED
|
@@ -19,20 +19,5 @@ module Mutant
|
|
|
19
19
|
Marshal.load(Marshal.dump(object))
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
# @param [Hash] options
|
|
25
|
-
# @param [Object] key
|
|
26
|
-
#
|
|
27
|
-
# @return [Object] value
|
|
28
|
-
#
|
|
29
|
-
# @api private
|
|
30
|
-
#
|
|
31
|
-
def self.extract_option(options, key)
|
|
32
|
-
options.fetch(key) do
|
|
33
|
-
raise ArgumentError,"Missing #{key.inspect} in options"
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
end
|
|
22
|
+
end # Helper
|
|
23
|
+
end # Mutant
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module Mutant
|
|
2
|
+
class Killer
|
|
3
|
+
|
|
4
|
+
# Killer that executes other killer in forked environment
|
|
5
|
+
class Forked < self
|
|
6
|
+
|
|
7
|
+
# Initialize object
|
|
8
|
+
#
|
|
9
|
+
# @param [Killer] killer
|
|
10
|
+
# @param [Strategy] strategy
|
|
11
|
+
# @param [Mutation] mutation
|
|
12
|
+
#
|
|
13
|
+
# @api private
|
|
14
|
+
#
|
|
15
|
+
def initialize(killer, strategy, mutation)
|
|
16
|
+
@killer = killer
|
|
17
|
+
super(strategy, mutation)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
# Run killer
|
|
23
|
+
#
|
|
24
|
+
# @return [true]
|
|
25
|
+
# if mutant was killed
|
|
26
|
+
#
|
|
27
|
+
# @return [false]
|
|
28
|
+
# otherwise
|
|
29
|
+
#
|
|
30
|
+
# @api private
|
|
31
|
+
#
|
|
32
|
+
def run
|
|
33
|
+
pid = fork do
|
|
34
|
+
killer = @killer.new(strategy, mutation)
|
|
35
|
+
exit(killer.success? ? CLI::EXIT_SUCCESS : CLI::EXIT_FAILURE)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
status = Process.wait2(pid).last
|
|
39
|
+
status.exited? && status.success?
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end # Forked
|
|
43
|
+
end # Killer
|
|
44
|
+
end # Mutant
|
|
@@ -1,59 +1,6 @@
|
|
|
1
1
|
module Mutant
|
|
2
2
|
class Killer
|
|
3
3
|
|
|
4
|
-
# Killer that executes other killer in forked environment
|
|
5
|
-
class Forked < self
|
|
6
|
-
|
|
7
|
-
# Initialize object
|
|
8
|
-
#
|
|
9
|
-
# @param [Killer] killer
|
|
10
|
-
# @param [Strategy] strategy
|
|
11
|
-
# @param [Mutation] mutation
|
|
12
|
-
#
|
|
13
|
-
# @api private
|
|
14
|
-
#
|
|
15
|
-
def initialize(killer, strategy, mutation)
|
|
16
|
-
@killer = killer
|
|
17
|
-
super(strategy, mutation)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# Return killer type
|
|
21
|
-
#
|
|
22
|
-
# @return [String]
|
|
23
|
-
#
|
|
24
|
-
# @api private
|
|
25
|
-
#
|
|
26
|
-
def type
|
|
27
|
-
@killer.type
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
private
|
|
31
|
-
|
|
32
|
-
# Run killer
|
|
33
|
-
#
|
|
34
|
-
# @return [true]
|
|
35
|
-
# if mutant was killed
|
|
36
|
-
#
|
|
37
|
-
# @return [false]
|
|
38
|
-
# otherwise
|
|
39
|
-
#
|
|
40
|
-
# @api private
|
|
41
|
-
#
|
|
42
|
-
def run
|
|
43
|
-
fork do
|
|
44
|
-
begin
|
|
45
|
-
killer = @killer.new(strategy, mutation)
|
|
46
|
-
Kernel.exit(killer.fail? ? 1 : 0)
|
|
47
|
-
rescue
|
|
48
|
-
Kernel.exit(1)
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
status = Process.wait2.last
|
|
53
|
-
status.exitstatus.zero?
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
4
|
# A killer that executes other killer in forked environemnts
|
|
58
5
|
class Forking < self
|
|
59
6
|
include Equalizer.new(:killer)
|
|
@@ -92,7 +39,6 @@ module Mutant
|
|
|
92
39
|
Forked.new(killer, strategy, mutation)
|
|
93
40
|
end
|
|
94
41
|
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
end
|
|
42
|
+
end # Forking
|
|
43
|
+
end # Killer
|
|
44
|
+
end # Mutant
|
data/lib/mutant/killer/rspec.rb
CHANGED
|
@@ -2,36 +2,31 @@ module Mutant
|
|
|
2
2
|
class Killer
|
|
3
3
|
# Runner for rspec tests
|
|
4
4
|
class Rspec < self
|
|
5
|
-
TYPE = 'rspec'.freeze
|
|
6
5
|
|
|
7
6
|
private
|
|
8
7
|
|
|
9
|
-
# Initialize rspec runner
|
|
10
|
-
#
|
|
11
|
-
# @return [undefined]
|
|
12
|
-
#
|
|
13
|
-
# @api private
|
|
14
|
-
#
|
|
15
|
-
def initialize(*)
|
|
16
|
-
@error_stream, @output_stream = StringIO.new, StringIO.new
|
|
17
|
-
super
|
|
18
|
-
end
|
|
19
|
-
|
|
20
8
|
# Run rspec test
|
|
21
9
|
#
|
|
22
10
|
# @return [true]
|
|
23
|
-
#
|
|
11
|
+
# when test is NOT successful
|
|
24
12
|
#
|
|
25
13
|
# @return [false]
|
|
26
|
-
#
|
|
14
|
+
# otherwise
|
|
27
15
|
#
|
|
28
16
|
# @api private
|
|
29
17
|
#
|
|
30
18
|
def run
|
|
31
19
|
mutation.insert
|
|
32
|
-
|
|
20
|
+
# TODO: replace with real streams from configuration
|
|
21
|
+
require 'stringio'
|
|
22
|
+
null = StringIO.new
|
|
23
|
+
args = command_line_arguments
|
|
24
|
+
begin
|
|
25
|
+
!::RSpec::Core::Runner.run(args, null, null).zero?
|
|
26
|
+
rescue StandardError
|
|
27
|
+
true
|
|
28
|
+
end
|
|
33
29
|
end
|
|
34
|
-
memoize :run
|
|
35
30
|
|
|
36
31
|
# Return command line arguments
|
|
37
32
|
#
|
|
@@ -42,8 +37,9 @@ module Mutant
|
|
|
42
37
|
def command_line_arguments
|
|
43
38
|
%W(
|
|
44
39
|
--fail-fast
|
|
45
|
-
) + strategy.spec_files(mutation)
|
|
40
|
+
) + strategy.spec_files(mutation.subject)
|
|
46
41
|
end
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
end
|
|
42
|
+
|
|
43
|
+
end # Rspec
|
|
44
|
+
end # Killer
|
|
45
|
+
end # Mutant
|
data/lib/mutant/killer/static.rb
CHANGED
|
@@ -19,15 +19,14 @@ module Mutant
|
|
|
19
19
|
|
|
20
20
|
# Killer that is always successful
|
|
21
21
|
class Success < self
|
|
22
|
-
TYPE = 'success'.freeze
|
|
23
22
|
RESULT = true
|
|
24
|
-
end
|
|
23
|
+
end # Success
|
|
25
24
|
|
|
26
25
|
# Killer that always fails
|
|
27
26
|
class Fail < self
|
|
28
|
-
TYPE = 'fail'.freeze
|
|
29
27
|
RESULT = false
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
end
|
|
28
|
+
end # Fail
|
|
29
|
+
|
|
30
|
+
end # Static
|
|
31
|
+
end # Killer
|
|
32
|
+
end # Mutant
|
data/lib/mutant/killer.rb
CHANGED
|
@@ -1,113 +1,87 @@
|
|
|
1
1
|
module Mutant
|
|
2
2
|
# Abstract base class for mutant killers
|
|
3
3
|
class Killer
|
|
4
|
-
include Adamantium::Flat, AbstractType
|
|
5
|
-
|
|
6
|
-
# Test for kill failure
|
|
7
|
-
#
|
|
8
|
-
# @return [true]
|
|
9
|
-
# returns true when mutant was killed
|
|
10
|
-
#
|
|
11
|
-
# @return [false]
|
|
12
|
-
# returns false otherwise
|
|
13
|
-
#
|
|
14
|
-
# @api private
|
|
15
|
-
#
|
|
16
|
-
def fail?
|
|
17
|
-
!@killed
|
|
18
|
-
end
|
|
4
|
+
include Adamantium::Flat, AbstractType, Equalizer.new(:strategy, :mutation, :killed?)
|
|
19
5
|
|
|
20
|
-
# Return
|
|
6
|
+
# Return strategy
|
|
21
7
|
#
|
|
22
|
-
# @return [
|
|
8
|
+
# @return [Strategy]
|
|
23
9
|
#
|
|
24
10
|
# @api private
|
|
25
11
|
#
|
|
26
|
-
attr_reader :
|
|
12
|
+
attr_reader :strategy
|
|
27
13
|
|
|
28
|
-
# Return
|
|
14
|
+
# Return mutation to kill
|
|
29
15
|
#
|
|
30
|
-
# @return [
|
|
16
|
+
# @return [Mutation]
|
|
31
17
|
#
|
|
32
18
|
# @api private
|
|
33
19
|
#
|
|
34
|
-
|
|
35
|
-
mutation.original_source
|
|
36
|
-
end
|
|
20
|
+
attr_reader :mutation
|
|
37
21
|
|
|
38
|
-
#
|
|
22
|
+
# Initialize killer object
|
|
39
23
|
#
|
|
40
|
-
# @
|
|
24
|
+
# @param [Strategy] strategy
|
|
25
|
+
# @param [Mutation] mutation
|
|
26
|
+
#
|
|
27
|
+
# @return [undefined]
|
|
41
28
|
#
|
|
42
29
|
# @api private
|
|
43
30
|
#
|
|
44
|
-
def
|
|
45
|
-
mutation
|
|
31
|
+
def initialize(strategy, mutation)
|
|
32
|
+
@strategy, @mutation = strategy, mutation
|
|
33
|
+
run_with_benchmark
|
|
46
34
|
end
|
|
47
35
|
|
|
48
|
-
#
|
|
49
|
-
#
|
|
50
|
-
# @return [Strategy]
|
|
51
|
-
#
|
|
52
|
-
# @api private
|
|
36
|
+
# Test for kill failure
|
|
53
37
|
#
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
# Return name of killer
|
|
38
|
+
# @return [true]
|
|
39
|
+
# when killer succeeded
|
|
57
40
|
#
|
|
58
|
-
# @return [
|
|
41
|
+
# @return [false]
|
|
42
|
+
# otherwise
|
|
59
43
|
#
|
|
60
44
|
# @api private
|
|
61
45
|
#
|
|
62
|
-
def
|
|
63
|
-
self
|
|
46
|
+
def success?
|
|
47
|
+
mutation.success?(self)
|
|
64
48
|
end
|
|
49
|
+
memoize :success?
|
|
65
50
|
|
|
66
|
-
#
|
|
67
|
-
#
|
|
68
|
-
# @return [String]
|
|
51
|
+
# Test if mutant was killed
|
|
69
52
|
#
|
|
70
|
-
# @
|
|
71
|
-
#
|
|
72
|
-
def identification
|
|
73
|
-
"#{type}:#{mutation.identification}".freeze
|
|
74
|
-
end
|
|
75
|
-
memoize :identification
|
|
76
|
-
|
|
77
|
-
# Return mae of killer
|
|
53
|
+
# @return [true]
|
|
54
|
+
# if mutant was killed
|
|
78
55
|
#
|
|
79
|
-
# @return [
|
|
56
|
+
# @return [false]
|
|
57
|
+
# otherwise
|
|
80
58
|
#
|
|
81
59
|
# @api private
|
|
82
60
|
#
|
|
83
|
-
def
|
|
84
|
-
|
|
61
|
+
def killed?
|
|
62
|
+
@killed
|
|
85
63
|
end
|
|
86
64
|
|
|
87
|
-
# Return
|
|
65
|
+
# Return runtime of killer
|
|
88
66
|
#
|
|
89
|
-
# @return [
|
|
67
|
+
# @return [Float]
|
|
90
68
|
#
|
|
91
69
|
# @api private
|
|
92
70
|
#
|
|
93
|
-
attr_reader :
|
|
94
|
-
|
|
95
|
-
private
|
|
71
|
+
attr_reader :runtime
|
|
96
72
|
|
|
97
|
-
#
|
|
98
|
-
#
|
|
99
|
-
# @param [Mutation] mutation
|
|
73
|
+
# Return mutated source
|
|
100
74
|
#
|
|
101
|
-
# @return [
|
|
75
|
+
# @return [String]
|
|
102
76
|
#
|
|
103
77
|
# @api private
|
|
104
78
|
#
|
|
105
|
-
def
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
run_with_benchmark
|
|
79
|
+
def mutation_source
|
|
80
|
+
mutation.source
|
|
109
81
|
end
|
|
110
82
|
|
|
83
|
+
private
|
|
84
|
+
|
|
111
85
|
# Run with taking the time
|
|
112
86
|
#
|
|
113
87
|
# @return [undefined]
|
|
@@ -115,23 +89,23 @@ module Mutant
|
|
|
115
89
|
# @api private
|
|
116
90
|
#
|
|
117
91
|
def run_with_benchmark
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
@runtime =
|
|
92
|
+
times = Benchmark.measure do
|
|
93
|
+
@killed = run
|
|
94
|
+
end
|
|
95
|
+
@runtime = times.real
|
|
122
96
|
end
|
|
123
97
|
|
|
124
|
-
# Run
|
|
98
|
+
# Run killer
|
|
125
99
|
#
|
|
126
100
|
# @return [true]
|
|
127
|
-
#
|
|
101
|
+
# when mutant was killed
|
|
128
102
|
#
|
|
129
103
|
# @return [false]
|
|
130
|
-
#
|
|
104
|
+
# otherwise
|
|
131
105
|
#
|
|
132
106
|
# @api private
|
|
133
107
|
#
|
|
134
108
|
abstract_method :run
|
|
135
109
|
|
|
136
|
-
end
|
|
137
|
-
end
|
|
110
|
+
end # Killer
|
|
111
|
+
end # Mutant
|
data/lib/mutant/loader.rb
CHANGED
|
@@ -16,7 +16,7 @@ module Mutant
|
|
|
16
16
|
|
|
17
17
|
# Initialize and insert mutation into vm
|
|
18
18
|
#
|
|
19
|
-
# @param [
|
|
19
|
+
# @param [Parser::AST::Node] root
|
|
20
20
|
# @param [Subject] subject
|
|
21
21
|
#
|
|
22
22
|
# @return [undefined]
|
|
@@ -40,7 +40,7 @@ module Mutant
|
|
|
40
40
|
# @api private
|
|
41
41
|
#
|
|
42
42
|
def run
|
|
43
|
-
|
|
43
|
+
eval(source, TOPLEVEL_BINDING, @subject.source_path, @subject.source_line)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
# Return source
|
|
@@ -50,9 +50,9 @@ module Mutant
|
|
|
50
50
|
# @api private
|
|
51
51
|
#
|
|
52
52
|
def source
|
|
53
|
-
|
|
53
|
+
Unparser.unparse(@root)
|
|
54
54
|
end
|
|
55
|
-
end
|
|
55
|
+
end # Eval
|
|
56
56
|
|
|
57
|
-
end
|
|
58
|
-
end
|
|
57
|
+
end # Loader
|
|
58
|
+
end # Mutant
|
data/lib/mutant/matcher/chain.rb
CHANGED
|
@@ -2,7 +2,7 @@ module Mutant
|
|
|
2
2
|
class Matcher
|
|
3
3
|
# A chain of matchers
|
|
4
4
|
class Chain < self
|
|
5
|
-
include
|
|
5
|
+
include Concord::Public.new(:matchers)
|
|
6
6
|
|
|
7
7
|
# Enumerate subjects
|
|
8
8
|
#
|
|
@@ -24,14 +24,6 @@ module Mutant
|
|
|
24
24
|
self
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
# Return the chain of matchers
|
|
28
|
-
#
|
|
29
|
-
# @return [Enumerable<Chain>]
|
|
30
|
-
#
|
|
31
|
-
# @api private
|
|
32
|
-
#
|
|
33
|
-
attr_reader :matchers
|
|
34
|
-
|
|
35
27
|
# Build matcher chain
|
|
36
28
|
#
|
|
37
29
|
# @param [Enumerable<Matcher>] matchers
|
|
@@ -48,19 +40,6 @@ module Mutant
|
|
|
48
40
|
new(matchers)
|
|
49
41
|
end
|
|
50
42
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
#
|
|
55
|
-
# @param [Enumerable<Matcher>] matchers
|
|
56
|
-
#
|
|
57
|
-
# @return [undefined]
|
|
58
|
-
#
|
|
59
|
-
# @api private
|
|
60
|
-
#
|
|
61
|
-
def initialize(matchers)
|
|
62
|
-
@matchers = matchers
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
|
43
|
+
end # Chain
|
|
44
|
+
end # Matcher
|
|
45
|
+
end # Mutant
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
module Mutant
|
|
2
2
|
class Matcher
|
|
3
|
-
class Method
|
|
3
|
+
class Method
|
|
4
4
|
# Matcher for instance methods
|
|
5
5
|
class Instance < self
|
|
6
|
-
|
|
6
|
+
SUBJECT_CLASS = Subject::Method::Instance
|
|
7
7
|
|
|
8
8
|
# Return identification
|
|
9
9
|
#
|
|
@@ -14,27 +14,15 @@ module Mutant
|
|
|
14
14
|
def identification
|
|
15
15
|
"#{scope.name}##{method_name}"
|
|
16
16
|
end
|
|
17
|
+
memoize :identification
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
#
|
|
20
|
-
# @return [true]
|
|
21
|
-
# if method is public
|
|
22
|
-
#
|
|
23
|
-
# @return [false]
|
|
24
|
-
# otherwise
|
|
25
|
-
#
|
|
26
|
-
# @api private
|
|
27
|
-
#
|
|
28
|
-
def public?
|
|
29
|
-
scope.public_method_defined?(method_name)
|
|
30
|
-
end
|
|
31
|
-
memoize :public?
|
|
19
|
+
NAME_INDEX = 0
|
|
32
20
|
|
|
33
21
|
private
|
|
34
22
|
|
|
35
23
|
# Check if node is matched
|
|
36
24
|
#
|
|
37
|
-
# @param [
|
|
25
|
+
# @param [Parser::AST::Node] node
|
|
38
26
|
#
|
|
39
27
|
# @return [true]
|
|
40
28
|
# returns true if node matches method
|
|
@@ -45,12 +33,14 @@ module Mutant
|
|
|
45
33
|
# @api private
|
|
46
34
|
#
|
|
47
35
|
def match?(node)
|
|
48
|
-
node.
|
|
49
|
-
|
|
50
|
-
|
|
36
|
+
location = node.location || return
|
|
37
|
+
expression = location.expression || return
|
|
38
|
+
expression.line == source_line &&
|
|
39
|
+
node.type == :def &&
|
|
40
|
+
node.children[NAME_INDEX] == method_name
|
|
51
41
|
end
|
|
52
42
|
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
43
|
+
end # Instance
|
|
44
|
+
end # Method
|
|
45
|
+
end # Matcher
|
|
46
|
+
end # Mutant
|