mutant 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +9 -0
  3. data/Gemfile +4 -6
  4. data/Gemfile.devtools +65 -0
  5. data/Rakefile +2 -2
  6. data/config/devtools.yml +2 -0
  7. data/config/flay.yml +1 -1
  8. data/config/rubocop.yml +8 -9
  9. data/lib/mutant.rb +26 -3
  10. data/lib/mutant/cli/builder.rb +0 -11
  11. data/lib/mutant/constants.rb +12 -18
  12. data/lib/mutant/loader.rb +7 -16
  13. data/lib/mutant/mutation.rb +1 -1
  14. data/lib/mutant/mutator/node/binary.rb +58 -0
  15. data/lib/mutant/mutator/node/{while.rb → conditional_loop.rb} +2 -2
  16. data/lib/mutant/mutator/node/generic.rb +2 -1
  17. data/lib/mutant/node_helpers.rb +1 -1
  18. data/lib/mutant/version.rb +1 -1
  19. data/lib/mutant/zombifier.rb +2 -1
  20. data/mutant.gemspec +4 -3
  21. data/spec/integration/mutant/test_mutator_handles_types_spec.rb +1 -0
  22. data/spec/spec_helper.rb +1 -1
  23. data/spec/unit/mutant/cli/classifier/method_spec.rb +1 -1
  24. data/spec/unit/mutant/cli/classifier/namespace/flat_spec.rb +2 -2
  25. data/spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb +2 -2
  26. data/spec/unit/mutant/differ_spec.rb +42 -0
  27. data/spec/unit/mutant/killer/{rspec/class_methods/new_spec.rb → rspec_spec.rb} +0 -0
  28. data/spec/unit/mutant/loader/{eval/class_methods/run_spec.rb → eval_spec.rb} +2 -2
  29. data/spec/unit/mutant/matcher/chain_spec.rb +57 -0
  30. data/spec/unit/mutant/matcher/method/instance_spec.rb +155 -0
  31. data/spec/unit/mutant/matcher/method/{singleton/each_spec.rb → singleton_spec.rb} +0 -0
  32. data/spec/unit/mutant/matcher/methods/{instance/each_spec.rb → instance_spec.rb} +0 -0
  33. data/spec/unit/mutant/matcher/methods/{singleton/each_spec.rb → singleton_spec.rb} +0 -0
  34. data/spec/unit/mutant/matcher/{namespace/each_spec.rb → namespace_spec.rb} +0 -0
  35. data/spec/unit/mutant/mutator/node/{and_asgn/mutation_spec.rb → and_asgn_spec.rb} +0 -0
  36. data/spec/unit/mutant/mutator/node/{begin/mutation_spec.rb → begin_spec.rb} +0 -0
  37. data/spec/unit/mutant/mutator/node/{connective/binary/mutation_spec.rb → binary_spec.rb} +1 -1
  38. data/spec/unit/mutant/mutator/node/{block_pass/mutation_spec.rb → block_pass_spec.rb} +0 -0
  39. data/spec/unit/mutant/mutator/node/{block/mutation_spec.rb → block_spec.rb} +0 -0
  40. data/spec/unit/mutant/mutator/node/{blockarg/mutation_spec.rb → blockarg_spec.rb} +0 -0
  41. data/spec/unit/mutant/mutator/node/{case/mutation_spec.rb → case_spec.rb} +0 -0
  42. data/spec/unit/mutant/mutator/node/{cbase/mutation_spec.rb → cbase_spec.rb} +0 -0
  43. data/spec/unit/mutant/mutator/node/conditional_loop_spec.rb +42 -0
  44. data/spec/unit/mutant/mutator/node/{const/mutation_spec.rb → const_spec.rb} +0 -0
  45. data/spec/unit/mutant/mutator/node/{define/mutation_spec.rb → define_spec.rb} +0 -0
  46. data/spec/unit/mutant/mutator/node/{defined_predicate/mutation_spec.rb → defined_spec.rb} +0 -0
  47. data/spec/unit/mutant/mutator/node/{dstr/mutation_spec.rb → dstr_spec.rb} +0 -0
  48. data/spec/unit/mutant/mutator/node/{dsym/mutation_spec.rb → dsym_spec.rb} +0 -0
  49. data/spec/unit/mutant/mutator/node/{ensure/mutation_spec.rb → ensure_spec.rb} +0 -0
  50. data/spec/unit/mutant/mutator/node/{if/mutation_spec.rb → if_spec.rb} +0 -0
  51. data/spec/unit/mutant/mutator/node/{kwbegin/mutation_spec.rb → kwbegin_spec.rb} +0 -0
  52. data/spec/unit/mutant/mutator/node/literal/{boolean/mutation_spec.rb → boolean_spec.rb} +0 -0
  53. data/spec/unit/mutant/mutator/node/{masgn/mutation_spec.rb → masgn_spec.rb} +0 -0
  54. data/spec/unit/mutant/mutator/node/{match_current_line/mutation_spec.rb → match_current_line_spec.rb} +1 -1
  55. data/spec/unit/mutant/mutator/node/named_value/{access/mutation_spec.rb → access_spec.rb} +0 -0
  56. data/spec/unit/mutant/mutator/node/named_value/{constant_assignment/mutation_spec.rb → constant_assignment_spec.rb} +0 -0
  57. data/spec/unit/mutant/mutator/node/named_value/{variable_assignment/mutation_spec.rb → variable_assignment_spec.rb} +0 -0
  58. data/spec/unit/mutant/mutator/node/{nthref/mutation_spec.rb → nthref_spec.rb} +0 -0
  59. data/spec/unit/mutant/mutator/node/{op_assgn/mutation_spec.rb → op_assgn_spec.rb} +0 -0
  60. data/spec/unit/mutant/mutator/node/{or_asgn/mutation_spec.rb → or_asgn_spec.rb} +0 -0
  61. data/spec/unit/mutant/mutator/node/{redo/mutation_spec.rb → redo_spec.rb} +0 -0
  62. data/spec/unit/mutant/mutator/node/{rescue/mutation_spec.rb → rescue_spec.rb} +0 -0
  63. data/spec/unit/mutant/mutator/node/{restarg/mutation_spec.rb → restarg_spec.rb} +0 -0
  64. data/spec/unit/mutant/mutator/node/{return/mutation_spec.rb → return_spec.rb} +0 -0
  65. data/spec/unit/mutant/mutator/node/{send/mutation_spec.rb → send_spec.rb} +0 -0
  66. data/spec/unit/mutant/mutator/node/{super/mutation_spec.rb → super_spec.rb} +0 -0
  67. data/spec/unit/mutant/mutator/node/{yield/mutation_spec.rb → yield_spec.rb} +0 -0
  68. data/spec/unit/mutant/mutator_spec.rb +29 -0
  69. data/spec/unit/mutant/runner/config_spec.rb +88 -0
  70. data/spec/unit/mutant/runner/{subject/success_predicate_spec.rb → subject_spec.rb} +0 -0
  71. data/spec/unit/mutant_spec.rb +43 -0
  72. data/test_app/Gemfile.devtools +65 -0
  73. metadata +119 -119
  74. data/lib/mutant/mutator/node/connective/binary.rb +0 -61
  75. data/lib/mutant/support/method_object.rb +0 -34
  76. data/spec/unit/mutant/class_methods/singleton_subclass_instance_spec.rb +0 -41
  77. data/spec/unit/mutant/differ/class_methods/build_spec.rb +0 -14
  78. data/spec/unit/mutant/differ/class_methods/colorize_line_spec.rb +0 -27
  79. data/spec/unit/mutant/matcher/chain/each_spec.rb +0 -43
  80. data/spec/unit/mutant/matcher/chain/matchers_spec.rb +0 -14
  81. data/spec/unit/mutant/matcher/each_spec.rb +0 -21
  82. data/spec/unit/mutant/matcher/method/instance/class_methods/build_spec.rb +0 -42
  83. data/spec/unit/mutant/matcher/method/instance/each_spec.rb +0 -114
  84. data/spec/unit/mutant/mutator/each_spec.rb +0 -27
  85. data/spec/unit/mutant/mutator/emit_new_spec.rb +0 -59
  86. data/spec/unit/mutant/mutator/emit_spec.rb +0 -55
  87. data/spec/unit/mutant/mutator/node/while/mutation_spec.rb +0 -24
  88. data/spec/unit/mutant/node_helpers/n_not_spec.rb +0 -14
  89. data/spec/unit/mutant/runner/config/subjects_spec.rb +0 -52
  90. data/spec/unit/mutant/runner/config/success_predicate_spec.rb +0 -57
@@ -1,59 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::Mutator, '#emit_new' do
6
- subject { object.send(:emit_new) { generated } }
7
-
8
- class Block
9
- attr_reader :arguments
10
-
11
- def called?
12
- defined?(@arguments)
13
- end
14
-
15
- def call(*arguments)
16
- @arguments = arguments
17
- end
18
- end
19
-
20
- let(:object) { class_under_test.new(input, parent, block) }
21
- let(:block) { Block.new }
22
- let(:input) { :input }
23
- let(:parent) { :parent }
24
-
25
- let(:class_under_test) do
26
- Class.new(described_class) do
27
- def dispatch
28
- # noop
29
- end
30
- end
31
- end
32
-
33
- context 'when new object generated' do
34
- let(:generated) { :generated }
35
-
36
- it 'should call block' do
37
- subject
38
- block.should be_called
39
- end
40
-
41
- it 'should call block with generated object' do
42
- subject
43
- block.arguments.should eql([generated])
44
- end
45
- end
46
-
47
- context 'when new AST could not be generated' do
48
- let(:generated) { input }
49
-
50
- it 'should raise error' do
51
- expect do
52
- subject
53
- end.to raise_error(
54
- RuntimeError,
55
- 'New AST could not be generated after 3 attempts'
56
- )
57
- end
58
- end
59
- end
@@ -1,55 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::Mutator, '#emit' do
6
- subject { object.send(:emit, generated) }
7
-
8
- class Block
9
- attr_reader :arguments
10
-
11
- def called?
12
- defined?(@arguments)
13
- end
14
-
15
- def call(*arguments)
16
- @arguments = arguments
17
- end
18
- end
19
-
20
- let(:object) { class_under_test.new(input, parent, block) }
21
- let(:block) { Block.new }
22
- let(:input) { :input }
23
- let(:parent) { :parent }
24
-
25
- let(:class_under_test) do
26
- Class.new(described_class) do
27
- def dispatch
28
- # noop
29
- end
30
- end
31
- end
32
-
33
- context 'with generated that is not equal to input' do
34
- let(:generated) { :generated }
35
-
36
- it 'should call block' do
37
- subject
38
- block.should be_called
39
- end
40
-
41
- it 'should call block with generated' do
42
- subject
43
- block.arguments.should eql([generated])
44
- end
45
- end
46
-
47
- context 'with generated object that is equal to input' do
48
- let(:generated) { input }
49
-
50
- it 'should not call block' do
51
- subject
52
- block.should_not be_called
53
- end
54
- end
55
- end
@@ -1,24 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::Mutator::Node::While do
6
-
7
- context 'with more than one statement' do
8
- let(:source) { 'while true; foo; bar; end' }
9
-
10
- let(:mutations) do
11
- mutations = []
12
- mutations << 'while true; bar; end'
13
- mutations << 'while true; foo; end'
14
- mutations << 'while true; end'
15
- mutations << 'while false; foo; bar; end'
16
- mutations << 'while nil; foo; bar; end'
17
- mutations << 'while true; foo; nil; end'
18
- mutations << 'while true; nil; bar; end'
19
- mutations << 'nil'
20
- end
21
-
22
- it_should_behave_like 'a mutator'
23
- end
24
- end
@@ -1,14 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::NodeHelpers, '#n_not' do
6
- subject { object.n_not(node) }
7
-
8
- let(:object) { Object.new.extend(described_class) }
9
- let(:node) { described_class::N_TRUE }
10
-
11
- it 'returns the negated node' do
12
- expect(subject).to eq(parse('not true'))
13
- end
14
- end
@@ -1,52 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::Runner::Config, '#subjects' do
6
- let(:object) { described_class.run(config) }
7
-
8
- subject { object.subjects }
9
-
10
- let(:config) do
11
- double(
12
- 'Config',
13
- class: Mutant::Config,
14
- subjects: [subject_a, subject_b],
15
- strategy: strategy,
16
- reporter: reporter
17
- )
18
- end
19
-
20
- let(:reporter) { double('Reporter') }
21
- let(:strategy) { double('Strategy') }
22
- let(:subject_a) { double('Subject A') }
23
- let(:subject_b) { double('Subject B') }
24
- let(:runner_a) { double('Runner A', stop?: stop_a) }
25
- let(:runner_b) { double('Runner B', stop?: stop_b) }
26
-
27
- before do
28
- strategy.stub(:setup)
29
- strategy.stub(:teardown)
30
- reporter.stub(report: reporter)
31
- Mutant::Runner.stub(:run).with(config, subject_a).and_return(runner_a)
32
- Mutant::Runner.stub(:run).with(config, subject_b).and_return(runner_b)
33
- end
34
-
35
- context 'without early stop' do
36
- let(:stop_a) { false }
37
- let(:stop_b) { false }
38
-
39
- it { should eql([runner_a, runner_b]) }
40
-
41
- it_should_behave_like 'an idempotent method'
42
- end
43
-
44
- context 'with early stop' do
45
- let(:stop_a) { true }
46
- let(:stop_b) { false }
47
-
48
- it { should eql([runner_a]) }
49
-
50
- it_should_behave_like 'an idempotent method'
51
- end
52
- end
@@ -1,57 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::Runner::Config, '#success?' do
6
- subject { object.success? }
7
-
8
- let(:object) { described_class.new(config) }
9
-
10
- let(:config) do
11
- double(
12
- 'Config',
13
- reporter: reporter,
14
- strategy: strategy,
15
- subjects: [subject_a, subject_b]
16
- )
17
- end
18
-
19
- let(:reporter) { double('Reporter') }
20
- let(:strategy) { double('Strategy') }
21
- let(:subject_a) { double('Subject A') }
22
- let(:subject_b) { double('Subject B') }
23
-
24
- let(:runner_a) do
25
- double('Runner A', stop?: stop_a, success?: success_a)
26
- end
27
-
28
- let(:runner_b) do
29
- double('Runner B', stop?: stop_b, success?: success_b)
30
- end
31
-
32
- before do
33
- reporter.stub(report: reporter)
34
- strategy.stub(:setup)
35
- strategy.stub(:teardown)
36
- Mutant::Runner.stub(:run).with(config, subject_a).and_return(runner_a)
37
- Mutant::Runner.stub(:run).with(config, subject_b).and_return(runner_b)
38
- end
39
-
40
- context 'without failed subjects' do
41
- let(:stop_a) { false }
42
- let(:stop_b) { false }
43
- let(:success_a) { true }
44
- let(:success_b) { true }
45
-
46
- it { should be(true) }
47
- end
48
-
49
- context 'with failing subjects' do
50
- let(:stop_a) { false }
51
- let(:stop_b) { false }
52
- let(:success_a) { false }
53
- let(:success_b) { true }
54
-
55
- it { should be(false) }
56
- end
57
- end