mutant 0.3.0.beta21 → 0.3.0.beta22
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/.gitignore +37 -6
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.travis.yml +13 -7
- data/Gemfile +8 -3
- data/Gemfile.devtools +2 -6
- data/Guardfile +22 -8
- data/README.md +3 -1
- data/Rakefile +3 -0
- data/bin/mutant +4 -3
- data/config/devtools.yml +1 -1
- data/config/flay.yml +1 -1
- data/config/flog.yml +1 -1
- data/config/reek.yml +7 -6
- data/config/rubocop.yml +55 -0
- data/lib/mutant.rb +3 -1
- data/lib/mutant/cache.rb +2 -0
- data/lib/mutant/cli.rb +14 -10
- data/lib/mutant/cli/classifier.rb +22 -10
- data/lib/mutant/cli/classifier/method.rb +14 -15
- data/lib/mutant/cli/classifier/namespace.rb +6 -2
- data/lib/mutant/cli/classifier/scope.rb +3 -1
- data/lib/mutant/color.rb +7 -3
- data/lib/mutant/config.rb +2 -0
- data/lib/mutant/constants.rb +5 -4
- data/lib/mutant/context.rb +2 -0
- data/lib/mutant/context/scope.rb +3 -1
- data/lib/mutant/differ.rb +10 -2
- data/lib/mutant/killer.rb +4 -1
- data/lib/mutant/killer/forked.rb +2 -0
- data/lib/mutant/killer/forking.rb +2 -0
- data/lib/mutant/killer/rspec.rb +19 -3
- data/lib/mutant/killer/static.rb +2 -0
- data/lib/mutant/loader.rb +8 -1
- data/lib/mutant/matcher.rb +2 -0
- data/lib/mutant/matcher/chain.rb +2 -0
- data/lib/mutant/matcher/method.rb +15 -3
- data/lib/mutant/matcher/method/finder.rb +2 -0
- data/lib/mutant/matcher/method/instance.rb +4 -1
- data/lib/mutant/matcher/method/singleton.rb +7 -1
- data/lib/mutant/matcher/methods.rb +3 -1
- data/lib/mutant/matcher/namespace.rb +4 -2
- data/lib/mutant/matcher/scope.rb +2 -0
- data/lib/mutant/mutation.rb +19 -5
- data/lib/mutant/mutation/evil.rb +12 -0
- data/lib/mutant/mutation/filter.rb +2 -0
- data/lib/mutant/mutation/filter/code.rb +3 -1
- data/lib/mutant/mutation/filter/regexp.rb +2 -0
- data/lib/mutant/mutation/filter/whitelist.rb +2 -0
- data/lib/mutant/mutation/neutral.rb +25 -0
- data/lib/mutant/mutator.rb +4 -6
- data/lib/mutant/mutator/node.rb +5 -1
- data/lib/mutant/mutator/node/argument.rb +2 -0
- data/lib/mutant/mutator/node/arguments.rb +2 -0
- data/lib/mutant/mutator/node/begin.rb +2 -0
- data/lib/mutant/mutator/node/block.rb +2 -0
- data/lib/mutant/mutator/node/case.rb +3 -1
- data/lib/mutant/mutator/node/connective/binary.rb +3 -1
- data/lib/mutant/mutator/node/const.rb +2 -0
- data/lib/mutant/mutator/node/define.rb +2 -0
- data/lib/mutant/mutator/node/generic.rb +4 -3
- data/lib/mutant/mutator/node/if.rb +2 -0
- data/lib/mutant/mutator/node/literal.rb +2 -0
- data/lib/mutant/mutator/node/literal/array.rb +2 -0
- data/lib/mutant/mutator/node/literal/boolean.rb +2 -0
- data/lib/mutant/mutator/node/literal/dynamic.rb +2 -0
- data/lib/mutant/mutator/node/literal/fixnum.rb +3 -1
- data/lib/mutant/mutator/node/literal/float.rb +2 -0
- data/lib/mutant/mutator/node/literal/hash.rb +2 -0
- data/lib/mutant/mutator/node/literal/nil.rb +2 -0
- data/lib/mutant/mutator/node/literal/range.rb +2 -1
- data/lib/mutant/mutator/node/literal/regex.rb +2 -0
- data/lib/mutant/mutator/node/literal/string.rb +2 -0
- data/lib/mutant/mutator/node/literal/symbol.rb +5 -1
- data/lib/mutant/mutator/node/masgn.rb +2 -0
- data/lib/mutant/mutator/node/mlhs.rb +2 -0
- data/lib/mutant/mutator/node/named_value/access.rb +2 -0
- data/lib/mutant/mutator/node/named_value/constant_assignment.rb +2 -0
- data/lib/mutant/mutator/node/named_value/variable_assignment.rb +3 -1
- data/lib/mutant/mutator/node/{cbase.rb → noop.rb} +7 -5
- data/lib/mutant/mutator/node/return.rb +2 -0
- data/lib/mutant/mutator/node/send.rb +2 -0
- data/lib/mutant/mutator/node/send/binary.rb +2 -0
- data/lib/mutant/mutator/node/splat.rb +2 -0
- data/lib/mutant/mutator/node/super.rb +2 -0
- data/lib/mutant/mutator/node/when.rb +3 -1
- data/lib/mutant/mutator/node/while.rb +2 -0
- data/lib/mutant/mutator/node/zsuper.rb +2 -0
- data/lib/mutant/mutator/registry.rb +55 -13
- data/lib/mutant/mutator/util.rb +2 -0
- data/lib/mutant/mutator/util/array.rb +3 -1
- data/lib/mutant/mutator/util/symbol.rb +2 -0
- data/lib/mutant/node_helpers.rb +10 -4
- data/lib/mutant/random.rb +2 -0
- data/lib/mutant/reporter.rb +2 -0
- data/lib/mutant/reporter/cli.rb +2 -0
- data/lib/mutant/reporter/cli/printer.rb +2 -0
- data/lib/mutant/reporter/cli/printer/config.rb +5 -2
- data/lib/mutant/reporter/cli/printer/killer.rb +2 -0
- data/lib/mutant/reporter/cli/printer/mutation.rb +13 -6
- data/lib/mutant/reporter/cli/printer/subject.rb +5 -1
- data/lib/mutant/reporter/null.rb +2 -0
- data/lib/mutant/runner.rb +2 -0
- data/lib/mutant/runner/config.rb +2 -0
- data/lib/mutant/runner/mutation.rb +2 -0
- data/lib/mutant/runner/subject.rb +2 -0
- data/lib/mutant/singleton_methods.rb +5 -3
- data/lib/mutant/strategy.rb +2 -0
- data/lib/mutant/strategy/method_expansion.rb +2 -0
- data/lib/mutant/strategy/rspec.rb +2 -0
- data/lib/mutant/strategy/rspec/dm2.rb +2 -0
- data/lib/mutant/strategy/rspec/dm2/lookup.rb +4 -2
- data/lib/mutant/strategy/rspec/dm2/lookup/method.rb +2 -0
- data/lib/mutant/strategy/static.rb +2 -0
- data/lib/mutant/subject.rb +4 -1
- data/lib/mutant/subject/method.rb +2 -0
- data/lib/mutant/subject/method/instance.rb +2 -0
- data/lib/mutant/subject/method/singleton.rb +2 -0
- data/lib/mutant/support/method_object.rb +2 -0
- data/lib/mutant/zombifier.rb +10 -6
- data/mutant.gemspec +11 -10
- data/spec/integration/mutant/rspec_killer_spec.rb +9 -4
- data/spec/integration/mutant/test_mutator_handles_types_spec.rb +3 -1
- data/spec/integration/mutant/zombie_spec.rb +2 -0
- data/spec/shared/method_matcher_behavior.rb +2 -0
- data/spec/shared/mutator_behavior.rb +16 -7
- data/spec/spec_helper.rb +26 -5
- data/spec/support/compress_helper.rb +5 -5
- data/spec/support/ice_nine_config.rb +2 -0
- data/spec/support/rspec.rb +2 -0
- data/spec/support/test_app.rb +2 -0
- data/spec/unit/mutant/class_methods/singleton_subclass_instance_spec.rb +2 -0
- data/spec/unit/mutant/cli/class_methods/new_spec.rb +17 -8
- data/spec/unit/mutant/cli/class_methods/run_spec.rb +10 -2
- data/spec/unit/mutant/cli/classifier/class_methods/build_spec.rb +4 -1
- data/spec/unit/mutant/cli/classifier/method/each_spec.rb +89 -0
- data/spec/unit/mutant/cli/classifier/namespace/flat/each_spec.rb +58 -0
- data/spec/unit/mutant/cli/classifier/namespace/recursive/each_spec.rb +58 -0
- data/spec/unit/mutant/cli/classifier/scope/each_spec.rb +33 -0
- data/spec/unit/mutant/context/root_spec.rb +5 -1
- data/spec/unit/mutant/context/scope/root_spec.rb +2 -0
- data/spec/unit/mutant/context/scope/unqualified_name_spec.rb +2 -0
- data/spec/unit/mutant/differ/class_methods/build_spec.rb +2 -0
- data/spec/unit/mutant/differ/class_methods/colorize_line_spec.rb +2 -0
- data/spec/unit/mutant/differ/diff_spec.rb +67 -5
- data/spec/unit/mutant/killer/rspec/class_methods/new_spec.rb +21 -4
- data/spec/unit/mutant/killer/success_predicate_spec.rb +2 -0
- data/spec/unit/mutant/loader/eval/class_methods/run_spec.rb +12 -5
- data/spec/unit/mutant/matcher/chain/each_spec.rb +2 -0
- data/spec/unit/mutant/matcher/chain/matchers_spec.rb +2 -0
- data/spec/unit/mutant/matcher/each_spec.rb +8 -1
- data/spec/unit/mutant/matcher/method/instance/class_methods/build_spec.rb +4 -2
- data/spec/unit/mutant/matcher/method/instance/each_spec.rb +21 -20
- data/spec/unit/mutant/matcher/method/singleton/each_spec.rb +22 -19
- data/spec/unit/mutant/matcher/methods/instance/each_spec.rb +8 -3
- data/spec/unit/mutant/matcher/methods/singleton/each_spec.rb +8 -3
- data/spec/unit/mutant/matcher/namespace/each_spec.rb +8 -2
- data/spec/unit/mutant/mutator/each_spec.rb +2 -0
- data/spec/unit/mutant/mutator/emit_new_spec.rb +10 -3
- data/spec/unit/mutant/mutator/emit_spec.rb +4 -2
- data/spec/unit/mutant/mutator/node/and_asgn/mutation_spec.rb +26 -0
- data/spec/unit/mutant/mutator/node/begin/mutation_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/block/mutation_spec.rb +4 -2
- data/spec/unit/mutant/mutator/node/block_pass/mutation_spec.rb +14 -0
- data/spec/unit/mutant/mutator/node/break/mutation_spec.rb +15 -0
- data/spec/unit/mutant/mutator/node/case/mutation_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/cbase/mutation_spec.rb +3 -6
- data/spec/unit/mutant/mutator/node/connective/binary/mutation_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/const/mutation_spec.rb +3 -6
- data/spec/unit/mutant/mutator/node/define/mutation_spec.rb +2 -1
- data/spec/unit/mutant/mutator/node/defined_predicate/mutation_spec.rb +10 -0
- data/spec/unit/mutant/mutator/node/dstr/mutation_spec.rb +21 -0
- data/spec/unit/mutant/mutator/node/dsym/mutation_spec.rb +21 -0
- data/spec/unit/mutant/mutator/node/ensure/mutation_spec.rb +15 -0
- data/spec/unit/mutant/mutator/node/if/mutation_spec.rb +2 -1
- data/spec/unit/mutant/mutator/node/literal/array_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/literal/boolean/mutation_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/literal/fixnum_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/literal/float_spec.rb +4 -2
- data/spec/unit/mutant/mutator/node/literal/hash_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/literal/nil_spec.rb +4 -5
- data/spec/unit/mutant/mutator/node/literal/range_spec.rb +8 -8
- data/spec/unit/mutant/mutator/node/literal/regex_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/literal/string_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/literal/symbol_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/masgn/mutation_spec.rb +4 -10
- data/spec/unit/mutant/mutator/node/match_current_line/mutation_spec.rb +20 -0
- data/spec/unit/mutant/mutator/node/named_value/access/mutation_spec.rb +3 -2
- data/spec/unit/mutant/mutator/node/named_value/constant_assignment/mutation_spec.rb +3 -2
- data/spec/unit/mutant/mutator/node/named_value/variable_assignment/mutation_spec.rb +3 -2
- data/spec/unit/mutant/mutator/node/next/mutation_spec.rb +15 -0
- data/spec/unit/mutant/mutator/node/op_assgn/mutation_spec.rb +26 -0
- data/spec/unit/mutant/mutator/node/or_asgn/mutation_spec.rb +26 -0
- data/spec/unit/mutant/mutator/node/redo/mutation_spec.rb +10 -0
- data/spec/unit/mutant/mutator/node/rescue/mutation_spec.rb +24 -0
- data/spec/unit/mutant/mutator/node/restarg/mutation_spec.rb +16 -0
- data/spec/unit/mutant/mutator/node/return/mutation_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/send/mutation_spec.rb +3 -1
- data/spec/unit/mutant/mutator/node/super/mutation_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/while/mutation_spec.rb +3 -1
- data/spec/unit/mutant/mutator/node/yield/mutation_spec.rb +15 -0
- data/spec/unit/mutant/node_helpers/n_not_spec.rb +2 -0
- data/spec/unit/mutant/runner/config/subjects_spec.rb +6 -2
- data/spec/unit/mutant/runner/config/success_predicate_spec.rb +15 -6
- data/spec/unit/mutant/runner/mutation/killer_spec.rb +3 -1
- data/spec/unit/mutant/runner/subject/success_predicate_spec.rb +15 -8
- data/spec/unit/mutant/strategy/method_expansion/class_methods/run_spec.rb +2 -0
- data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/instance/spec_files_spec.rb +32 -11
- data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/singleton/spec_files_spec.rb +31 -11
- data/spec/unit/mutant/subject/context_spec.rb +2 -0
- data/spec/unit/mutant/subject/mutations_spec.rb +2 -0
- data/spec/unit/mutant/subject/node_spec.rb +2 -0
- data/test_app/lib/test_app.rb +2 -0
- data/test_app/lib/test_app/literal.rb +2 -0
- data/test_app/spec/shared/method_filter_parse_behavior.rb +5 -1
- data/test_app/spec/shared/method_match_behavior.rb +2 -0
- data/test_app/spec/spec_helper.rb +3 -1
- data/test_app/spec/unit/test_app/literal/command_spec.rb +2 -0
- data/test_app/spec/unit/test_app/literal/string_spec.rb +3 -1
- metadata +66 -18
- data/bin/zombie +0 -18
- data/test_app/spec/shared/mutator_behavior.rb +0 -44
|
@@ -1,16 +1,33 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Mutant::Killer::Rspec, '.new' do
|
|
4
6
|
|
|
5
7
|
subject { object.new(strategy, mutation) }
|
|
6
8
|
|
|
7
|
-
let(:
|
|
8
|
-
let(:
|
|
9
|
-
let(:mutation) { double('Mutation', :subject => mutation_subject) }
|
|
10
|
-
let(:mutation_subject) { double('Mutation Subject') }
|
|
9
|
+
let(:context) { double('Context') }
|
|
10
|
+
let(:mutation_subject) { double('Mutation Subject') }
|
|
11
11
|
|
|
12
12
|
let(:object) { described_class }
|
|
13
13
|
|
|
14
|
+
let(:mutation) do
|
|
15
|
+
double(
|
|
16
|
+
'Mutation',
|
|
17
|
+
:subject => mutation_subject,
|
|
18
|
+
:should_survive? => false
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
let(:strategy) do
|
|
23
|
+
double(
|
|
24
|
+
'Strategy',
|
|
25
|
+
:spec_files => ['foo'],
|
|
26
|
+
:error_stream => $stderr,
|
|
27
|
+
:output_stream => $stdout
|
|
28
|
+
)
|
|
29
|
+
end
|
|
30
|
+
|
|
14
31
|
before do
|
|
15
32
|
mutation.stub(:insert)
|
|
16
33
|
mutation.stub(:reset)
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Mutant::Loader::Eval, '.run' do
|
|
4
6
|
|
|
5
7
|
subject { object.run(node, mutation_subject) }
|
|
6
8
|
|
|
7
|
-
let(:object)
|
|
8
|
-
let(:
|
|
9
|
-
let(:
|
|
10
|
-
|
|
9
|
+
let(:object) { described_class }
|
|
10
|
+
let(:path) { __FILE__ }
|
|
11
|
+
let(:line) { 1 }
|
|
12
|
+
|
|
13
|
+
let(:mutation_subject) do
|
|
14
|
+
double('Subject', :source_path => path, :source_line => line)
|
|
15
|
+
end
|
|
11
16
|
|
|
12
17
|
let(:source) do
|
|
13
18
|
<<-RUBY
|
|
@@ -36,6 +41,8 @@ describe Mutant::Loader::Eval, '.run' do
|
|
|
36
41
|
|
|
37
42
|
it 'should set file and line correctly' do
|
|
38
43
|
subject
|
|
39
|
-
::SomeNamespace::Bar
|
|
44
|
+
::SomeNamespace::Bar
|
|
45
|
+
.instance_method(:some_method)
|
|
46
|
+
.source_location.should eql([__FILE__, 3])
|
|
40
47
|
end
|
|
41
48
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
# This spec is only present to ensure 100% test coverage.
|
|
@@ -9,6 +11,11 @@ describe Mutant::Matcher, '#each' do
|
|
|
9
11
|
let(:object) { described_class.allocate }
|
|
10
12
|
|
|
11
13
|
it 'should raise error' do
|
|
12
|
-
expect
|
|
14
|
+
expect do
|
|
15
|
+
subject
|
|
16
|
+
end.to raise_error(
|
|
17
|
+
NotImplementedError,
|
|
18
|
+
'Mutant::Matcher#each is not implemented'
|
|
19
|
+
)
|
|
13
20
|
end
|
|
14
21
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Mutant::Matcher::Method::Instance, '.build' do
|
|
@@ -28,13 +30,13 @@ describe Mutant::Matcher::Method::Instance, '.build' do
|
|
|
28
30
|
context 'with unmemoized method' do
|
|
29
31
|
let(:method_name) { :bar }
|
|
30
32
|
|
|
31
|
-
it { should eql(
|
|
33
|
+
it { should eql(described_class.new(cache, scope, method)) }
|
|
32
34
|
end
|
|
33
35
|
|
|
34
36
|
context 'with memoized method' do
|
|
35
37
|
let(:method_name) { :foo }
|
|
36
38
|
|
|
37
|
-
it { should eql(
|
|
39
|
+
it { should eql(described_class::Memoized.new(cache, scope, method)) }
|
|
38
40
|
end
|
|
39
41
|
end
|
|
40
42
|
end
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Mutant::Matcher::Method::Instance, '#each' do
|
|
4
|
-
let(:cache) { Fixtures::AST_CACHE }
|
|
5
|
-
let(:object) { described_class.new(cache, scope, method) }
|
|
6
|
-
let(:method) { scope.instance_method(method_name) }
|
|
7
|
-
|
|
8
|
-
let(:yields) { [] }
|
|
9
|
-
|
|
10
|
-
let(:namespace) do
|
|
11
|
-
klass = self.class
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
let(:scope) { self.class::Foo }
|
|
15
|
-
|
|
16
6
|
subject { object.each { |subject| yields << subject } }
|
|
17
7
|
|
|
18
|
-
let(:
|
|
19
|
-
let(:
|
|
20
|
-
let(:
|
|
8
|
+
let(:cache) { Fixtures::AST_CACHE }
|
|
9
|
+
let(:object) { described_class.new(cache, scope, method) }
|
|
10
|
+
let(:method) { scope.instance_method(method_name) }
|
|
11
|
+
let(:yields) { [] }
|
|
12
|
+
let(:namespace) { self.class }
|
|
13
|
+
let(:scope) { self.class::Foo }
|
|
14
|
+
let(:type) { :def }
|
|
15
|
+
let(:method_name) { :bar }
|
|
16
|
+
let(:method_arity) { 0 }
|
|
21
17
|
|
|
22
18
|
def name
|
|
23
19
|
node.children[0]
|
|
@@ -42,11 +38,14 @@ describe Mutant::Matcher::Method::Instance, '#each' do
|
|
|
42
38
|
context 'on differend lines' do
|
|
43
39
|
let(:base) { __LINE__ }
|
|
44
40
|
class self::Foo
|
|
45
|
-
def bar
|
|
46
|
-
|
|
41
|
+
def bar
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def bar(arg)
|
|
45
|
+
end
|
|
47
46
|
end
|
|
48
47
|
|
|
49
|
-
let(:method_line) {
|
|
48
|
+
let(:method_line) { 5 }
|
|
50
49
|
let(:method_arity) { 1 }
|
|
51
50
|
|
|
52
51
|
it_should_behave_like 'a method matcher'
|
|
@@ -83,7 +82,8 @@ describe Mutant::Matcher::Method::Instance, '#each' do
|
|
|
83
82
|
let(:base) { __LINE__ }
|
|
84
83
|
class self::Foo
|
|
85
84
|
class Bar
|
|
86
|
-
def baz
|
|
85
|
+
def baz
|
|
86
|
+
end
|
|
87
87
|
end
|
|
88
88
|
end
|
|
89
89
|
|
|
@@ -98,7 +98,8 @@ describe Mutant::Matcher::Method::Instance, '#each' do
|
|
|
98
98
|
let(:base) { __LINE__ }
|
|
99
99
|
module self::Foo
|
|
100
100
|
class Bar
|
|
101
|
-
def baz
|
|
101
|
+
def baz
|
|
102
|
+
end
|
|
102
103
|
end
|
|
103
104
|
end
|
|
104
105
|
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Mutant::Matcher::Method::Singleton, '#each' do
|
|
4
|
-
let(:object) { described_class.new(cache, scope, method) }
|
|
5
|
-
let(:method) { scope.method(method_name) }
|
|
6
|
-
let(:cache) { Fixtures::AST_CACHE }
|
|
7
|
-
|
|
8
|
-
let(:yields) { [] }
|
|
9
|
-
|
|
10
|
-
let(:namespace) do
|
|
11
|
-
klass = self.class
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
let(:scope) { self.class::Foo }
|
|
15
|
-
|
|
16
6
|
subject { object.each { |subject| yields << subject } }
|
|
17
7
|
|
|
18
|
-
let(:
|
|
19
|
-
let(:
|
|
8
|
+
let(:object) { described_class.new(cache, scope, method) }
|
|
9
|
+
let(:method) { scope.method(method_name) }
|
|
10
|
+
let(:cache) { Fixtures::AST_CACHE }
|
|
11
|
+
let(:yields) { [] }
|
|
12
|
+
let(:namespace) { self.class }
|
|
13
|
+
let(:scope) { self.class::Foo }
|
|
14
|
+
let(:type) { :defs }
|
|
15
|
+
let(:method_arity) { 0 }
|
|
20
16
|
|
|
21
17
|
def name
|
|
22
18
|
node.children[1]
|
|
@@ -46,7 +42,8 @@ describe Mutant::Matcher::Method::Singleton, '#each' do
|
|
|
46
42
|
let(:base) { __LINE__ }
|
|
47
43
|
module self::Namespace
|
|
48
44
|
class Foo
|
|
49
|
-
def Foo.bar
|
|
45
|
+
def Foo.bar
|
|
46
|
+
end
|
|
50
47
|
end
|
|
51
48
|
end
|
|
52
49
|
|
|
@@ -60,12 +57,15 @@ describe Mutant::Matcher::Method::Singleton, '#each' do
|
|
|
60
57
|
context 'outside namespace' do
|
|
61
58
|
let(:base) { __LINE__ }
|
|
62
59
|
module self::Namespace
|
|
63
|
-
class Foo
|
|
64
|
-
|
|
60
|
+
class Foo
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def Foo.bar
|
|
64
|
+
end
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
let(:method_name) { :bar }
|
|
68
|
-
let(:method_line) {
|
|
68
|
+
let(:method_line) { 5 }
|
|
69
69
|
let(:scope) { self.class::Namespace::Foo }
|
|
70
70
|
|
|
71
71
|
it_should_behave_like 'a method matcher'
|
|
@@ -78,7 +78,10 @@ describe Mutant::Matcher::Method::Singleton, '#each' do
|
|
|
78
78
|
module self::Namespace
|
|
79
79
|
module Foo; end
|
|
80
80
|
module Bar
|
|
81
|
-
def self.baz
|
|
81
|
+
def self.baz
|
|
82
|
+
end
|
|
83
|
+
def Foo.baz(arg)
|
|
84
|
+
end
|
|
82
85
|
end
|
|
83
86
|
end
|
|
84
87
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Mutant::Matcher::Methods::Instance, '#each' do
|
|
@@ -46,9 +48,12 @@ describe Mutant::Matcher::Methods::Instance, '#each' do
|
|
|
46
48
|
|
|
47
49
|
before do
|
|
48
50
|
matcher = Mutant::Matcher::Method::Instance
|
|
49
|
-
matcher.stub(:new)
|
|
50
|
-
|
|
51
|
-
matcher.stub(:new)
|
|
51
|
+
matcher.stub(:new)
|
|
52
|
+
.with(cache, Foo, Foo.instance_method(:method_a)).and_return([subject_a])
|
|
53
|
+
matcher.stub(:new)
|
|
54
|
+
.with(cache, Foo, Foo.instance_method(:method_b)).and_return([subject_b])
|
|
55
|
+
matcher.stub(:new)
|
|
56
|
+
.with(cache, Foo, Foo.instance_method(:method_c)).and_return([subject_c])
|
|
52
57
|
end
|
|
53
58
|
|
|
54
59
|
it 'should yield expected subjects' do
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Mutant::Matcher::Methods::Singleton, '#each' do
|
|
@@ -40,9 +42,12 @@ describe Mutant::Matcher::Methods::Singleton, '#each' do
|
|
|
40
42
|
|
|
41
43
|
before do
|
|
42
44
|
matcher = Mutant::Matcher::Method::Singleton
|
|
43
|
-
matcher.stub(:new)
|
|
44
|
-
|
|
45
|
-
matcher.stub(:new)
|
|
45
|
+
matcher.stub(:new)
|
|
46
|
+
.with(cache, Foo, Foo.method(:method_a)).and_return([subject_a])
|
|
47
|
+
matcher.stub(:new)
|
|
48
|
+
.with(cache, Foo, Foo.method(:method_b)).and_return([subject_b])
|
|
49
|
+
matcher.stub(:new)
|
|
50
|
+
.with(cache, Foo, Foo.method(:method_c)).and_return([subject_c])
|
|
46
51
|
end
|
|
47
52
|
|
|
48
53
|
it 'should yield expected subjects' do
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Mutant::Matcher::Namespace, '#each' do
|
|
@@ -14,8 +16,12 @@ describe Mutant::Matcher::Namespace, '#each' do
|
|
|
14
16
|
let(:subject_b) { double('SubjectB') }
|
|
15
17
|
|
|
16
18
|
before do
|
|
17
|
-
Mutant::Matcher::Methods::Singleton.stub(:each)
|
|
18
|
-
|
|
19
|
+
Mutant::Matcher::Methods::Singleton.stub(:each)
|
|
20
|
+
.with(cache, singleton_a)
|
|
21
|
+
.and_yield(subject_a)
|
|
22
|
+
Mutant::Matcher::Methods::Instance.stub(:each)
|
|
23
|
+
.with(cache, singleton_a)
|
|
24
|
+
.and_yield(subject_b)
|
|
19
25
|
ObjectSpace.stub(:each_object => [singleton_a, singleton_b])
|
|
20
26
|
end
|
|
21
27
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Mutant::Mutator, '#emit_new' do
|
|
4
6
|
subject { object.send(:emit_new) { generated } }
|
|
5
7
|
|
|
6
8
|
class Block
|
|
7
|
-
|
|
9
|
+
attr_reader :arguments
|
|
8
10
|
|
|
9
11
|
def called?
|
|
10
12
|
defined?(@arguments)
|
|
@@ -23,7 +25,7 @@ describe Mutant::Mutator, '#emit_new' do
|
|
|
23
25
|
let(:class_under_test) do
|
|
24
26
|
Class.new(described_class) do
|
|
25
27
|
def dispatch
|
|
26
|
-
#noop
|
|
28
|
+
# noop
|
|
27
29
|
end
|
|
28
30
|
end
|
|
29
31
|
end
|
|
@@ -46,7 +48,12 @@ describe Mutant::Mutator, '#emit_new' do
|
|
|
46
48
|
let(:generated) { input }
|
|
47
49
|
|
|
48
50
|
it 'should raise error' do
|
|
49
|
-
expect
|
|
51
|
+
expect do
|
|
52
|
+
subject
|
|
53
|
+
end.to raise_error(
|
|
54
|
+
RuntimeError,
|
|
55
|
+
'New AST could not be generated after 3 attempts'
|
|
56
|
+
)
|
|
50
57
|
end
|
|
51
58
|
end
|
|
52
59
|
end
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Mutant::Mutator, '#emit' do
|
|
4
6
|
subject { object.send(:emit, generated) }
|
|
5
7
|
|
|
6
8
|
class Block
|
|
7
|
-
|
|
9
|
+
attr_reader :arguments
|
|
8
10
|
|
|
9
11
|
def called?
|
|
10
12
|
defined?(@arguments)
|
|
@@ -23,7 +25,7 @@ describe Mutant::Mutator, '#emit' do
|
|
|
23
25
|
let(:class_under_test) do
|
|
24
26
|
Class.new(described_class) do
|
|
25
27
|
def dispatch
|
|
26
|
-
#noop
|
|
28
|
+
# noop
|
|
27
29
|
end
|
|
28
30
|
end
|
|
29
31
|
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Mutant::Mutator::Node::Generic, 'and_asgn' do
|
|
6
|
+
let(:random_fixnum) { 5 }
|
|
7
|
+
let(:random_string) { 'random' }
|
|
8
|
+
|
|
9
|
+
let(:source) { 'a &&= 1' }
|
|
10
|
+
|
|
11
|
+
let(:mutations) do
|
|
12
|
+
mutations = []
|
|
13
|
+
mutations << 'srandom &&= 1'
|
|
14
|
+
mutations << 'a &&= nil'
|
|
15
|
+
mutations << 'a &&= 0'
|
|
16
|
+
mutations << 'a &&= -1'
|
|
17
|
+
mutations << 'a &&= 2'
|
|
18
|
+
mutations << 'a &&= 5'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
before do
|
|
22
|
+
Mutant::Random.stub(:fixnum => random_fixnum, :hex_string => random_string)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it_should_behave_like 'a mutator'
|
|
26
|
+
end
|