mutant 0.3.0.rc1 → 0.3.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +0 -1
  3. data/.travis.yml +5 -4
  4. data/Gemfile.devtools +4 -4
  5. data/Guardfile +7 -5
  6. data/README.md +8 -8
  7. data/config/flay.yml +2 -2
  8. data/config/reek.yml +1 -0
  9. data/config/rubocop.yml +0 -4
  10. data/lib/mutant/cli/builder.rb +177 -0
  11. data/lib/mutant/cli/classifier/method.rb +10 -14
  12. data/lib/mutant/cli/classifier/namespace.rb +7 -9
  13. data/lib/mutant/cli/classifier.rb +29 -31
  14. data/lib/mutant/cli.rb +34 -96
  15. data/lib/mutant/color.rb +1 -1
  16. data/lib/mutant/config.rb +9 -3
  17. data/lib/mutant/constants.rb +1 -1
  18. data/lib/mutant/context/scope.rb +2 -2
  19. data/lib/mutant/differ.rb +0 -1
  20. data/lib/mutant/killer/rspec.rb +3 -8
  21. data/lib/mutant/killer.rb +1 -22
  22. data/lib/mutant/matcher/chain.rb +2 -2
  23. data/lib/mutant/matcher/filter.rb +32 -0
  24. data/lib/mutant/matcher/method/instance.rb +2 -2
  25. data/lib/mutant/matcher/method.rb +3 -3
  26. data/lib/mutant/matcher/methods.rb +1 -1
  27. data/lib/mutant/matcher.rb +1 -0
  28. data/lib/mutant/mutation/evil.rb +0 -10
  29. data/lib/mutant/mutation/neutral.rb +0 -23
  30. data/lib/mutant/mutation.rb +13 -23
  31. data/lib/mutant/mutator/node/begin.rb +12 -10
  32. data/lib/mutant/mutator/node/block.rb +1 -0
  33. data/lib/mutant/mutator/node/blockarg.rb +15 -0
  34. data/lib/mutant/mutator/node/case.rb +1 -0
  35. data/lib/mutant/mutator/node/connective/binary.rb +2 -2
  36. data/lib/mutant/mutator/node/const.rb +2 -1
  37. data/lib/mutant/mutator/node/dstr.rb +28 -0
  38. data/lib/mutant/mutator/node/dsym.rb +28 -0
  39. data/lib/mutant/mutator/node/generic.rb +3 -4
  40. data/lib/mutant/mutator/node/if.rb +1 -0
  41. data/lib/mutant/mutator/node/literal/boolean.rb +2 -2
  42. data/lib/mutant/mutator/node/literal/range.rb +8 -6
  43. data/lib/mutant/mutator/node/literal.rb +0 -17
  44. data/lib/mutant/mutator/node/masgn.rb +1 -1
  45. data/lib/mutant/mutator/node/named_value/variable_assignment.rb +5 -4
  46. data/lib/mutant/mutator/node/op_asgn.rb +30 -0
  47. data/lib/mutant/mutator/node/restarg.rb +15 -0
  48. data/lib/mutant/mutator/node/return.rb +1 -2
  49. data/lib/mutant/mutator/node/send.rb +6 -5
  50. data/lib/mutant/mutator/node/super.rb +1 -0
  51. data/lib/mutant/mutator/node/while.rb +1 -0
  52. data/lib/mutant/mutator/node.rb +11 -1
  53. data/lib/mutant/node_helpers.rb +3 -3
  54. data/lib/mutant/predicate/attribute.rb +85 -0
  55. data/lib/mutant/predicate/blacklist.rb +27 -0
  56. data/lib/mutant/predicate/matcher.rb +36 -0
  57. data/lib/mutant/predicate/whitelist.rb +28 -0
  58. data/lib/mutant/predicate.rb +91 -0
  59. data/lib/mutant/reporter/cli/printer/config.rb +3 -3
  60. data/lib/mutant/reporter/cli/printer/killer.rb +1 -1
  61. data/lib/mutant/reporter/cli/printer/mutation.rb +12 -14
  62. data/lib/mutant/reporter/cli/printer/subject.rb +1 -3
  63. data/lib/mutant/reporter/cli/printer.rb +31 -7
  64. data/lib/mutant/runner/mutation.rb +9 -1
  65. data/lib/mutant/runner/subject.rb +9 -1
  66. data/lib/mutant/runner.rb +5 -6
  67. data/lib/mutant/strategy/rspec.rb +4 -4
  68. data/lib/mutant/strategy.rb +2 -0
  69. data/lib/mutant/support/method_object.rb +0 -1
  70. data/lib/mutant/version.rb +1 -2
  71. data/lib/mutant/zombifier.rb +6 -3
  72. data/lib/mutant.rb +12 -4
  73. data/mutant.gemspec +7 -7
  74. data/spec/integration/mutant/rspec_spec.rb +12 -5
  75. data/spec/shared/mutator_behavior.rb +2 -1
  76. data/spec/spec_helper.rb +11 -9
  77. data/spec/unit/mutant/cli/builder/rspec_spec.rb +38 -0
  78. data/spec/unit/mutant/cli/classifier/{method/each_spec.rb → method_spec.rb} +2 -14
  79. data/spec/unit/mutant/cli/classifier/namespace/{flat/each_spec.rb → flat_spec.rb} +1 -1
  80. data/spec/unit/mutant/cli/classifier/namespace/{recursive/each_spec.rb → recursive_spec.rb} +1 -1
  81. data/spec/unit/mutant/cli/classifier_spec.rb +59 -0
  82. data/spec/unit/mutant/{cli/class_methods/new_spec.rb → cli_new_spec.rb} +22 -23
  83. data/spec/unit/mutant/{cli/class_methods/run_spec.rb → cli_run_spec.rb} +8 -8
  84. data/spec/unit/mutant/killer/rspec/class_methods/new_spec.rb +6 -6
  85. data/spec/unit/mutant/killer/success_predicate_spec.rb +5 -5
  86. data/spec/unit/mutant/loader/eval/class_methods/run_spec.rb +1 -1
  87. data/spec/unit/mutant/matcher/filter_spec.rb +19 -0
  88. data/spec/unit/mutant/matcher/namespace/each_spec.rb +5 -5
  89. data/spec/unit/mutant/mutation_spec.rb +42 -0
  90. data/spec/unit/mutant/mutator/each_spec.rb +1 -1
  91. data/spec/unit/mutant/mutator/node/and_asgn/mutation_spec.rb +3 -2
  92. data/spec/unit/mutant/mutator/node/block/mutation_spec.rb +7 -2
  93. data/spec/unit/mutant/mutator/node/block_pass/mutation_spec.rb +1 -0
  94. data/spec/unit/mutant/mutator/node/blockarg/mutation_spec.rb +17 -0
  95. data/spec/unit/mutant/mutator/node/case/mutation_spec.rb +5 -1
  96. data/spec/unit/mutant/mutator/node/cbase/mutation_spec.rb +1 -0
  97. data/spec/unit/mutant/mutator/node/const/mutation_spec.rb +3 -2
  98. data/spec/unit/mutant/mutator/node/define/mutation_spec.rb +3 -3
  99. data/spec/unit/mutant/mutator/node/defined_predicate/mutation_spec.rb +6 -2
  100. data/spec/unit/mutant/mutator/node/dstr/mutation_spec.rb +4 -2
  101. data/spec/unit/mutant/mutator/node/dsym/mutation_spec.rb +4 -2
  102. data/spec/unit/mutant/mutator/node/if/mutation_spec.rb +6 -1
  103. data/spec/unit/mutant/mutator/node/literal/fixnum_spec.rb +1 -1
  104. data/spec/unit/mutant/mutator/node/literal/float_spec.rb +1 -1
  105. data/spec/unit/mutant/mutator/node/literal/range_spec.rb +31 -0
  106. data/spec/unit/mutant/mutator/node/literal/regex_spec.rb +4 -2
  107. data/spec/unit/mutant/mutator/node/literal/string_spec.rb +1 -1
  108. data/spec/unit/mutant/mutator/node/literal/symbol_spec.rb +1 -1
  109. data/spec/unit/mutant/mutator/node/masgn/mutation_spec.rb +6 -2
  110. data/spec/unit/mutant/mutator/node/match_current_line/mutation_spec.rb +1 -0
  111. data/spec/unit/mutant/mutator/node/named_value/access/mutation_spec.rb +5 -1
  112. data/spec/unit/mutant/mutator/node/named_value/constant_assignment/mutation_spec.rb +1 -2
  113. data/spec/unit/mutant/mutator/node/named_value/variable_assignment/mutation_spec.rb +5 -5
  114. data/spec/unit/mutant/mutator/node/op_assgn/mutation_spec.rb +3 -2
  115. data/spec/unit/mutant/mutator/node/or_asgn/mutation_spec.rb +3 -2
  116. data/spec/unit/mutant/mutator/node/rescue/mutation_spec.rb +1 -1
  117. data/spec/unit/mutant/mutator/node/restarg/mutation_spec.rb +3 -1
  118. data/spec/unit/mutant/mutator/node/return/mutation_spec.rb +7 -3
  119. data/spec/unit/mutant/mutator/node/send/mutation_spec.rb +37 -2
  120. data/spec/unit/mutant/mutator/node/super/mutation_spec.rb +4 -0
  121. data/spec/unit/mutant/mutator/node/while/mutation_spec.rb +3 -0
  122. data/spec/unit/mutant/predicate_spec.rb +135 -0
  123. data/spec/unit/mutant/runner/config/subjects_spec.rb +11 -11
  124. data/spec/unit/mutant/runner/config/success_predicate_spec.rb +6 -6
  125. data/spec/unit/mutant/runner/mutation/killer_spec.rb +11 -11
  126. data/spec/unit/mutant/runner/subject/success_predicate_spec.rb +9 -9
  127. data/spec/unit/mutant/strategy_spec.rb +21 -0
  128. data/spec/unit/mutant/subject_spec.rb +39 -0
  129. data/test_app/spec/shared/method_filter_parse_behavior.rb +1 -1
  130. metadata +54 -36
  131. data/lib/mutant/cli/classifier/scope.rb +0 -37
  132. data/lib/mutant/mutation/filter/code.rb +0 -49
  133. data/lib/mutant/mutation/filter/regexp.rb +0 -29
  134. data/lib/mutant/mutation/filter/whitelist.rb +0 -52
  135. data/lib/mutant/mutation/filter.rb +0 -78
  136. data/lib/mutant/strategy/static.rb +0 -20
  137. data/spec/unit/mutant/cli/classifier/class_methods/build_spec.rb +0 -48
  138. data/spec/unit/mutant/cli/classifier/scope/each_spec.rb +0 -33
@@ -13,7 +13,6 @@ end
13
13
  shared_examples_for 'a cli parser' do
14
14
  subject { cli.config }
15
15
 
16
- its(:filter) { should eql(expected_filter) }
17
16
  its(:strategy) { should eql(expected_strategy) }
18
17
  its(:reporter) { should eql(expected_reporter) }
19
18
  its(:matcher) { should eql(expected_matcher) }
@@ -24,16 +23,16 @@ describe Mutant::CLI, '.new' do
24
23
  let(:time) { Time.now }
25
24
 
26
25
  before do
27
- Time.stub(:now => time)
26
+ Time.stub(now: time)
28
27
  end
29
28
 
30
29
  # Defaults
31
- let(:expected_filter) { Mutant::Mutation::Filter::ALL }
32
- let(:expected_strategy) { Mutant::Strategy::Rspec.new }
30
+ let(:expected_filter) { Mutant::Predicate::TAUTOLOGY }
31
+ let(:expected_strategy) { Mutant::Strategy::Rspec.new(0) }
33
32
  let(:expected_reporter) { Mutant::Reporter::CLI.new($stdout) }
34
33
 
35
- let(:ns) { Mutant::CLI::Classifier }
36
- let(:cache) { Mutant::Cache.new }
34
+ let(:ns) { Mutant::Matcher }
35
+ let(:cache) { Mutant::Cache.new }
37
36
 
38
37
  let(:cli) { object.new(arguments) }
39
38
 
@@ -56,8 +55,8 @@ describe Mutant::CLI, '.new' do
56
55
  end
57
56
 
58
57
  context 'with many strategy flags' do
59
- let(:arguments) { %w(--static-fail --rspec TestApp) }
60
- let(:expected_matcher) { Mutant::CLI::Classifier::Namespace::Flat.new(Mutant::Cache.new, 'TestApp') }
58
+ let(:arguments) { %w(--rspec --rspec TestApp) }
59
+ let(:expected_matcher) { Mutant::Matcher::Scope.new(cache, TestApp) }
61
60
 
62
61
  it_should_behave_like 'a cli parser'
63
62
  end
@@ -65,7 +64,7 @@ describe Mutant::CLI, '.new' do
65
64
  context 'without arguments' do
66
65
  let(:arguments) { [] }
67
66
 
68
- let(:expected_message) { 'No strategy was set!' }
67
+ let(:expected_message) { 'No matchers given' }
69
68
 
70
69
  it_should_behave_like 'an invalid cli run'
71
70
  end
@@ -79,15 +78,15 @@ describe Mutant::CLI, '.new' do
79
78
 
80
79
  context 'with explicit method matcher' do
81
80
  let(:arguments) { %w(--rspec TestApp::Literal#float) }
82
- let(:expected_matcher) { ns::Method.new(cache, 'TestApp::Literal#float') }
81
+ let(:expected_matcher) { ns::Method::Instance.new(cache, TestApp::Literal, TestApp::Literal.instance_method(:float)) }
83
82
 
84
83
  it_should_behave_like 'a cli parser'
85
84
  end
86
85
 
87
86
  context 'with debug flag' do
88
- let(:matcher) { '::TestApp*' }
89
- let(:arguments) { %W(--debug --rspec #{matcher}) }
90
- let(:expected_matcher) { ns::Namespace::Recursive.new(cache, matcher) }
87
+ let(:matcher) { '::TestApp*' }
88
+ let(:arguments) { %W(--debug --rspec #{matcher}) }
89
+ let(:expected_matcher) { ns::Namespace.new(cache, TestApp) }
91
90
 
92
91
  it_should_behave_like 'a cli parser'
93
92
 
@@ -97,9 +96,9 @@ describe Mutant::CLI, '.new' do
97
96
  end
98
97
 
99
98
  context 'with zombie flag' do
100
- let(:matcher) { '::TestApp*' }
101
- let(:arguments) { %W(--zombie --rspec #{matcher}) }
102
- let(:expected_matcher) { ns::Namespace::Recursive.new(cache, matcher) }
99
+ let(:matcher) { '::TestApp*' }
100
+ let(:arguments) { %W(--zombie --rspec #{matcher}) }
101
+ let(:expected_matcher) { ns::Namespace.new(cache, TestApp) }
103
102
 
104
103
  it_should_behave_like 'a cli parser'
105
104
 
@@ -109,9 +108,9 @@ describe Mutant::CLI, '.new' do
109
108
  end
110
109
 
111
110
  context 'with namespace matcher' do
112
- let(:matcher) { '::TestApp*' }
113
- let(:arguments) { %W(--rspec #{matcher}) }
114
- let(:expected_matcher) { ns::Namespace::Recursive.new(cache, matcher) }
111
+ let(:matcher) { '::TestApp*' }
112
+ let(:arguments) { %W(--rspec #{matcher}) }
113
+ let(:expected_matcher) { ns::Namespace.new(cache, TestApp) }
115
114
 
116
115
  it_should_behave_like 'a cli parser'
117
116
  end
@@ -122,13 +121,13 @@ describe Mutant::CLI, '.new' do
122
121
 
123
122
  let(:filters) do
124
123
  [
125
- Mutant::Mutation::Filter::Code.new('faa'),
126
- Mutant::Mutation::Filter::Code.new('bbb'),
124
+ Mutant::Predicate::Attribute.new(:code, 'faa'),
125
+ Mutant::Predicate::Attribute.new(:code, 'bbb'),
127
126
  ]
128
127
  end
129
128
 
130
- let(:expected_matcher) { ns::Method.new(cache, 'TestApp::Literal#float') }
131
- let(:expected_filter) { Mutant::Mutation::Filter::Whitelist.new(filters) }
129
+ let(:expected_matcher) { ns::Method::Instance.new(cache, TestApp::Literal, TestApp::Literal.instance_method(:float)) }
130
+ let(:expected_filter) { Mutant::Predicate::Whitelist.new(filters) }
132
131
 
133
132
  it_should_behave_like 'a cli parser'
134
133
  end
@@ -5,16 +5,16 @@ require 'spec_helper'
5
5
  describe Mutant::CLI, '.run' do
6
6
  subject { object.run(argv) }
7
7
 
8
- let(:object) { described_class }
9
- let(:argv) { double('ARGV') }
10
- let(:attributes) { double('Options') }
11
- let(:runner) { double('Runner', :success? => success) }
12
- let(:config) { double('Config') }
13
- let(:instance) { double(described_class.name, :config => config) }
8
+ let(:object) { described_class }
9
+ let(:argv) { double('ARGV') }
10
+ let(:attributes) { double('Options') }
11
+ let(:runner) { double('Runner', success?: success) }
12
+ let(:config) { double('Config') }
13
+ let(:instance) { double(described_class.name, config: config) }
14
14
 
15
15
  before do
16
- described_class.stub(:new => instance)
17
- Mutant::Runner::Config.stub(:run => runner)
16
+ described_class.stub(new: instance)
17
+ Mutant::Runner::Config.stub(run: runner)
18
18
  end
19
19
 
20
20
  context 'when runner is successful' do
@@ -18,24 +18,24 @@ describe Mutant::Killer::Rspec, '.new' do
18
18
  let(:mutation) do
19
19
  double(
20
20
  'Mutation',
21
- :subject => mutation_subject,
22
- :should_survive? => false
21
+ subject: mutation_subject,
22
+ should_survive?: false
23
23
  )
24
24
  end
25
25
 
26
26
  let(:strategy) do
27
27
  double(
28
28
  'Strategy',
29
- :spec_files => ['foo'],
30
- :error_stream => $stderr,
31
- :output_stream => $stdout
29
+ spec_files: ['foo'],
30
+ error_stream: $stderr,
31
+ output_stream: $stdout
32
32
  )
33
33
  end
34
34
 
35
35
  before do
36
36
  mutation.stub(:insert)
37
37
  mutation.stub(:reset)
38
- RSpec::Core::Runner.stub(:run => exit_status)
38
+ RSpec::Core::Runner.stub(run: exit_status)
39
39
  end
40
40
 
41
41
  context 'when run exits zero' do
@@ -5,13 +5,13 @@ require 'spec_helper'
5
5
  describe Mutant::Killer, '#success?' do
6
6
  subject { object.success? }
7
7
 
8
- let(:object) { class_under_test.new(strategy, mutation) }
9
- let(:strategy) { double('Strategy') }
10
- let(:mutation) { double('Mutation', :success? => kill_state) }
11
- let(:kill_state) { double('Kill State') }
8
+ let(:object) { class_under_test.new(strategy, mutation) }
9
+ let(:strategy) { double('Strategy') }
10
+ let(:mutation) { double('Mutation', success?: kill_state) }
11
+ let(:kill_state) { double('Kill State') }
12
12
 
13
13
  before do
14
- kill_state.stub(:freeze => kill_state, :dup => kill_state)
14
+ kill_state.stub(freeze: kill_state, dup: kill_state)
15
15
  end
16
16
 
17
17
  let(:class_under_test) do
@@ -11,7 +11,7 @@ describe Mutant::Loader::Eval, '.run' do
11
11
  let(:line) { 1 }
12
12
 
13
13
  let(:mutation_subject) do
14
- double('Subject', :source_path => path, :source_line => line)
14
+ double('Subject', source_path: path, source_line: line)
15
15
  end
16
16
 
17
17
  let(:source) do
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Mutant::Matcher::Filter do
6
+ let(:object) { described_class.new(matcher, predicate) }
7
+ let(:matcher) { [:foo, :bar] }
8
+
9
+ let(:predicate) { Mutant::Predicate::Attribute::Equality.new(:to_s, 'foo') }
10
+
11
+ describe '#each' do
12
+ subject { object.each { |item| yields << item } }
13
+
14
+ let(:yields) { [] }
15
+ its(:to_a) { should eql([:bar]) }
16
+
17
+ it_should_behave_like 'an #each method'
18
+ end
19
+ end
@@ -10,10 +10,10 @@ describe Mutant::Matcher::Namespace, '#each' do
10
10
 
11
11
  let(:cache) { Mutant::Cache.new }
12
12
 
13
- let(:singleton_a) { double('SingletonA', :name => 'TestApp::Literal') }
14
- let(:singleton_b) { double('SingletonB', :name => 'TestApp::Foo') }
15
- let(:subject_a) { double('SubjectA') }
16
- let(:subject_b) { double('SubjectB') }
13
+ let(:singleton_a) { double('SingletonA', name: 'TestApp::Literal') }
14
+ let(:singleton_b) { double('SingletonB', name: 'TestApp::Foo') }
15
+ let(:subject_a) { double('SubjectA') }
16
+ let(:subject_b) { double('SubjectB') }
17
17
 
18
18
  before do
19
19
  Mutant::Matcher::Methods::Singleton.stub(:each)
@@ -22,7 +22,7 @@ describe Mutant::Matcher::Namespace, '#each' do
22
22
  Mutant::Matcher::Methods::Instance.stub(:each)
23
23
  .with(cache, singleton_a)
24
24
  .and_yield(subject_b)
25
- ObjectSpace.stub(:each_object => [singleton_a, singleton_b])
25
+ ObjectSpace.stub(each_object: [singleton_a, singleton_b])
26
26
  end
27
27
 
28
28
  context 'with no block' do
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mutant::Mutation do
4
+
5
+ let(:class_under_test) { Class.new(described_class) }
6
+ let(:object) { class_under_test.new(mutation_subject, Mutant::NodeHelpers::N_NIL) }
7
+ let(:mutation_subject) { double('Subject', identification: 'subject', source: 'original') }
8
+ let(:node) { double('Node') }
9
+
10
+ describe '#code' do
11
+ subject { object.code }
12
+
13
+ it { should eql('8771a') }
14
+
15
+ it_should_behave_like 'an idempotent method'
16
+ end
17
+
18
+ describe '#original_source' do
19
+ subject { object.original_source }
20
+
21
+ it { should eql('original') }
22
+
23
+ it_should_behave_like 'an idempotent method'
24
+ end
25
+
26
+ describe '#source' do
27
+ subject { object.source }
28
+
29
+ it { should eql('nil') }
30
+
31
+ it_should_behave_like 'an idempotent method'
32
+ end
33
+
34
+ describe '#identification' do
35
+
36
+ subject { object.identification }
37
+
38
+ it { should eql('subject:8771a') }
39
+
40
+ it_should_behave_like 'an idempotent method'
41
+ end
42
+ end
@@ -19,7 +19,7 @@ describe Mutant::Mutator, '.each' do
19
19
  end
20
20
 
21
21
  before do
22
- Mutant::Random.stub(:hex_string => random_string)
22
+ Mutant::Random.stub(hex_string: random_string)
23
23
  end
24
24
 
25
25
  it_should_behave_like 'a mutator'
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Mutant::Mutator::Node::Generic, 'and_asgn' do
5
+ describe Mutant::Mutator::Node::OpAsgn, 'and_asgn' do
6
6
  let(:random_fixnum) { 5 }
7
7
  let(:random_string) { 'random' }
8
8
 
@@ -16,10 +16,11 @@ describe Mutant::Mutator::Node::Generic, 'and_asgn' do
16
16
  mutations << 'a &&= -1'
17
17
  mutations << 'a &&= 2'
18
18
  mutations << 'a &&= 5'
19
+ mutations << 'nil'
19
20
  end
20
21
 
21
22
  before do
22
- Mutant::Random.stub(:fixnum => random_fixnum, :hex_string => random_string)
23
+ Mutant::Random.stub(fixnum: random_fixnum, hex_string: random_string)
23
24
  end
24
25
 
25
26
  it_should_behave_like 'a mutator'
@@ -12,7 +12,10 @@ describe Mutant::Mutator, 'block' do
12
12
  mutations << 'foo { b }'
13
13
  mutations << 'foo {}'
14
14
  mutations << 'foo { raise }'
15
+ mutations << 'foo { a; nil }'
16
+ mutations << 'foo { nil; b }'
15
17
  mutations << 'foo'
18
+ mutations << 'nil'
16
19
  end
17
20
 
18
21
  it_should_behave_like 'a mutator'
@@ -23,7 +26,7 @@ describe Mutant::Mutator, 'block' do
23
26
  let(:source) { 'foo { |a, b| }' }
24
27
 
25
28
  before do
26
- Mutant::Random.stub(:hex_string => 'random')
29
+ Mutant::Random.stub(hex_string: 'random')
27
30
  end
28
31
 
29
32
  let(:mutations) do
@@ -35,6 +38,7 @@ describe Mutant::Mutator, 'block' do
35
38
  mutations << 'foo { |a| }'
36
39
  mutations << 'foo { |b| }'
37
40
  mutations << 'foo { || }'
41
+ mutations << 'nil'
38
42
  end
39
43
 
40
44
  it_should_behave_like 'a mutator'
@@ -43,7 +47,7 @@ describe Mutant::Mutator, 'block' do
43
47
  context 'with block pattern args' do
44
48
 
45
49
  before do
46
- Mutant::Random.stub(:hex_string => 'random')
50
+ Mutant::Random.stub(hex_string: 'random')
47
51
  end
48
52
 
49
53
  let(:source) { 'foo { |(a, b), c| }' }
@@ -61,6 +65,7 @@ describe Mutant::Mutator, 'block' do
61
65
  mutations << 'foo { |(a, srandom), c| }'
62
66
  mutations << 'foo { |(a, b), srandom| }'
63
67
  mutations << 'foo'
68
+ mutations << 'nil'
64
69
  end
65
70
 
66
71
  it_should_behave_like 'a mutator'
@@ -8,6 +8,7 @@ describe Mutant::Mutator::Node::NamedValue::Access, 'block_pass' do
8
8
  let(:mutations) do
9
9
  mutants = []
10
10
  mutants << 'foo'
11
+ mutants << 'nil'
11
12
  end
12
13
 
13
14
  it_should_behave_like 'a mutator'
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Mutant::Mutator::Node::Blockarg, 'blockarg' do
6
+ let(:source) { 'foo { |&bar| }' }
7
+
8
+ let(:mutations) do
9
+ mutations = []
10
+ mutations << 'foo { |&bar| raise }'
11
+ mutations << 'foo {}'
12
+ mutations << 'foo'
13
+ mutations << 'nil'
14
+ end
15
+
16
+ it_should_behave_like 'a mutator'
17
+ end
@@ -6,7 +6,7 @@ describe Mutant::Mutator::Node::Case do
6
6
  let(:random_string) { 'random' }
7
7
 
8
8
  before do
9
- Mutant::Random.stub(:hex_string => random_string)
9
+ Mutant::Random.stub(hex_string: random_string)
10
10
  end
11
11
 
12
12
  context 'with multiple when branches' do
@@ -217,6 +217,8 @@ describe Mutant::Mutator::Node::Case do
217
217
  :else
218
218
  end
219
219
  RUBY
220
+
221
+ mutations << 'nil'
220
222
  end
221
223
 
222
224
  it_should_behave_like 'a mutator'
@@ -314,6 +316,8 @@ describe Mutant::Mutator::Node::Case do
314
316
  :else
315
317
  end
316
318
  RUBY
319
+
320
+ mutations << 'nil'
317
321
  end
318
322
 
319
323
  it_should_behave_like 'a mutator'
@@ -8,6 +8,7 @@ describe Mutant::Mutator::Node::Noop, 'cbase' do
8
8
  let(:mutations) do
9
9
  mutants = []
10
10
  mutants << 'nil'
11
+ mutants << 'A'
11
12
  end
12
13
 
13
14
  it_should_behave_like 'a mutator'
@@ -3,12 +3,13 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Mutant::Mutator::Node::Const, 'const' do
6
- let(:source) { 'A::B' }
6
+ let(:source) { 'A::B::C' }
7
7
 
8
8
  let(:mutations) do
9
9
  mutants = []
10
10
  mutants << 'nil'
11
- mutants << 'nil::B'
11
+ mutants << 'B::C'
12
+ mutants << 'C'
12
13
  end
13
14
 
14
15
  it_should_behave_like 'a mutator'
@@ -43,7 +43,7 @@ describe Mutant::Mutator, 'def' do
43
43
  let(:source) { 'def foo(a, b); end' }
44
44
 
45
45
  before do
46
- Mutant::Random.stub(:hex_string => 'random')
46
+ Mutant::Random.stub(hex_string: 'random')
47
47
  end
48
48
 
49
49
  let(:mutations) do
@@ -83,7 +83,7 @@ describe Mutant::Mutator, 'def' do
83
83
  let(:source) { 'def foo(a = true); end' }
84
84
 
85
85
  before do
86
- Mutant::Random.stub(:hex_string => 'random')
86
+ Mutant::Random.stub(hex_string: 'random')
87
87
  end
88
88
 
89
89
  let(:mutations) do
@@ -127,7 +127,7 @@ describe Mutant::Mutator, 'def' do
127
127
  context 'define on singleton with argument' do
128
128
 
129
129
  before do
130
- Mutant::Random.stub(:hex_string => 'random')
130
+ Mutant::Random.stub(hex_string: 'random')
131
131
  end
132
132
 
133
133
  let(:source) { 'def self.foo(a, b); end' }
@@ -3,8 +3,12 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Mutant::Mutator::Node::Generic, 'defined?' do
6
- let(:source) { 'defined?(foo)' }
7
- let(:mutations) { [] }
6
+ let(:source) { 'defined?(foo)' }
7
+
8
+ let(:mutations) do
9
+ mutations = []
10
+ mutations << 'defined?(nil)'
11
+ end
8
12
 
9
13
  it_should_behave_like 'a mutator'
10
14
  end
@@ -2,9 +2,9 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Mutant::Mutator::Node::Generic, 'dstr' do
5
+ describe Mutant::Mutator::Node::Dstr, 'dstr' do
6
6
  before do
7
- Mutant::Random.stub(:hex_string => 'random')
7
+ Mutant::Random.stub(hex_string: 'random')
8
8
  end
9
9
 
10
10
  let(:source) { '"foo#{bar}baz"' }
@@ -15,6 +15,8 @@ describe Mutant::Mutator::Node::Generic, 'dstr' do
15
15
  mutations << '"#{nil}#{bar}baz"'
16
16
  mutations << '"foo#{bar}random"'
17
17
  mutations << '"foo#{bar}#{nil}"'
18
+ mutations << '"foo#{nil}baz"'
19
+ mutations << 'nil'
18
20
  end
19
21
 
20
22
  it_should_behave_like 'a mutator'
@@ -2,9 +2,9 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Mutant::Mutator::Node::Generic, 'dsum' do
5
+ describe Mutant::Mutator::Node::Dsym, 'dsym' do
6
6
  before do
7
- Mutant::Random.stub(:hex_string => 'random')
7
+ Mutant::Random.stub(hex_string: 'random')
8
8
  end
9
9
 
10
10
  let(:source) { ':"foo#{bar}baz"' }
@@ -15,6 +15,8 @@ describe Mutant::Mutator::Node::Generic, 'dsum' do
15
15
  mutations << ':"#{nil}#{bar}baz"'
16
16
  mutations << ':"foo#{bar}random"'
17
17
  mutations << ':"foo#{bar}#{nil}"'
18
+ mutations << ':"foo#{nil}baz"'
19
+ mutations << 'nil'
18
20
  end
19
21
 
20
22
  it_should_behave_like 'a mutator'
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe Mutant::Mutator, 'if' do
6
6
  before do
7
- Mutant::Random.stub(:hex_string => 'random')
7
+ Mutant::Random.stub(hex_string: 'random')
8
8
  end
9
9
 
10
10
  context 'with if and else branches' do
@@ -36,6 +36,8 @@ describe Mutant::Mutator, 'if' do
36
36
  # mutations of else body
37
37
  mutants << 'if :condition; true; else true; end'
38
38
  mutants << 'if :condition; true; else nil; end'
39
+
40
+ mutants << 'nil'
39
41
  end
40
42
 
41
43
  it_should_behave_like 'a mutator'
@@ -51,6 +53,8 @@ describe Mutant::Mutator, 'if' do
51
53
  mutants << 'if condition; nil; end'
52
54
  mutants << 'if true; true; end'
53
55
  mutants << 'if false; true; end'
56
+ mutants << 'if nil; true; end'
57
+ mutants << 'nil'
54
58
  end
55
59
 
56
60
  it_should_behave_like 'a mutator'
@@ -69,6 +73,7 @@ describe Mutant::Mutator, 'if' do
69
73
  mutants << 'unless true; true; end'
70
74
  mutants << 'unless false; true; end'
71
75
  mutants << 'if :condition; true; end'
76
+ mutants << 'nil'
72
77
  end
73
78
 
74
79
  it_should_behave_like 'a mutator'
@@ -12,7 +12,7 @@ describe Mutant::Mutator::Node::Literal, 'fixnum' do
12
12
  end
13
13
 
14
14
  before do
15
- Mutant::Random.stub(:fixnum => random_fixnum)
15
+ Mutant::Random.stub(fixnum: random_fixnum)
16
16
  end
17
17
 
18
18
  it_should_behave_like 'a mutator'
@@ -20,7 +20,7 @@ describe Mutant::Mutator::Node::Literal, 'float' do
20
20
  let(:random_float) { 7.123 }
21
21
 
22
22
  before do
23
- Mutant::Random.stub(:float => random_float)
23
+ Mutant::Random.stub(float: random_float)
24
24
  end
25
25
 
26
26
  it_should_behave_like 'a mutator'
@@ -3,6 +3,13 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Mutant::Mutator::Node::Literal, 'range' do
6
+
7
+ before :each do
8
+ Mutant::Random.stub(fixnum: random_fixnum)
9
+ end
10
+
11
+ let(:random_fixnum) { 5 }
12
+
6
13
  context 'inclusive range literal' do
7
14
  let(:source) { '1..100' }
8
15
 
@@ -13,6 +20,18 @@ describe Mutant::Mutator::Node::Literal, 'range' do
13
20
  mutations << '(0.0 / 0.0)..100'
14
21
  mutations << '1..(1.0 / 0.0)'
15
22
  mutations << '1..(0.0 / 0.0)'
23
+ mutations << '-1..100'
24
+ mutations << '5..100'
25
+ mutations << '0..100'
26
+ mutations << '2..100'
27
+ mutations << 'nil..100'
28
+ mutations << '1..nil'
29
+ mutations << '1..0'
30
+ mutations << '1..1'
31
+ mutations << '1..99'
32
+ mutations << '1..101'
33
+ mutations << '1..-100'
34
+ mutations << '1..5'
16
35
  end
17
36
 
18
37
  it_should_behave_like 'a mutator'
@@ -28,6 +47,18 @@ describe Mutant::Mutator::Node::Literal, 'range' do
28
47
  mutations << '(0.0 / 0.0)...100'
29
48
  mutations << '1...(1.0 / 0.0)'
30
49
  mutations << '1...(0.0 / 0.0)'
50
+ mutations << '-1...100'
51
+ mutations << '5...100'
52
+ mutations << '0...100'
53
+ mutations << '2...100'
54
+ mutations << 'nil...100'
55
+ mutations << '1...nil'
56
+ mutations << '1...0'
57
+ mutations << '1...1'
58
+ mutations << '1...99'
59
+ mutations << '1...101'
60
+ mutations << '1...-100'
61
+ mutations << '1...5'
31
62
  end
32
63
 
33
64
  it_should_behave_like 'a mutator'
@@ -9,9 +9,9 @@ describe Mutant::Mutator::Node::Literal, 'regex' do
9
9
 
10
10
  let(:mutations) do
11
11
  mutations = []
12
- mutations << 'nil'
13
12
  mutations << '//' # match all
14
13
  mutations << '/a\A/' # match nothing
14
+ mutations << 'nil'
15
15
  end
16
16
 
17
17
  it_should_behave_like 'a mutator'
@@ -22,10 +22,12 @@ describe Mutant::Mutator::Node::Literal, 'regex' do
22
22
 
23
23
  let(:mutations) do
24
24
  mutations = []
25
- mutations << 'nil'
26
25
  mutations << '//' # match all
27
26
  mutations << '/#{foo}n/' # match all
28
27
  mutations << '/a\A/' # match nothing
28
+ mutations << '/#{nil.bar}n/'
29
+ mutations << '/#{nil}n/'
30
+ mutations << 'nil'
29
31
  end
30
32
 
31
33
  it_should_behave_like 'a mutator'