mutant 0.5.24 → 0.5.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +8 -0
  3. data/config/flay.yml +1 -1
  4. data/config/flog.yml +1 -1
  5. data/config/reek.yml +15 -13
  6. data/lib/mutant.rb +28 -12
  7. data/lib/mutant/ast/meta.rb +0 -10
  8. data/lib/mutant/ast/named_children.rb +1 -0
  9. data/lib/mutant/ast/types.rb +5 -5
  10. data/lib/mutant/cli.rb +84 -64
  11. data/lib/mutant/config.rb +7 -39
  12. data/lib/mutant/delegator.rb +2 -0
  13. data/lib/mutant/env.rb +119 -16
  14. data/lib/mutant/expression.rb +8 -2
  15. data/lib/mutant/expression/method.rb +6 -16
  16. data/lib/mutant/expression/methods.rb +5 -5
  17. data/lib/mutant/expression/namespace.rb +7 -7
  18. data/lib/mutant/integration.rb +0 -10
  19. data/lib/mutant/isolation.rb +41 -15
  20. data/lib/mutant/matcher/chain.rb +1 -17
  21. data/lib/mutant/matcher/compiler.rb +108 -0
  22. data/lib/mutant/matcher/config.rb +28 -0
  23. data/lib/mutant/matcher/method.rb +1 -1
  24. data/lib/mutant/matcher/namespace.rb +5 -52
  25. data/lib/mutant/matcher/null.rb +1 -1
  26. data/lib/mutant/matcher/scope.rb +1 -1
  27. data/lib/mutant/mutation.rb +29 -13
  28. data/lib/mutant/mutator/node.rb +2 -12
  29. data/lib/mutant/mutator/node/named_value/variable_assignment.rb +1 -1
  30. data/lib/mutant/reporter/cli.rb +0 -2
  31. data/lib/mutant/reporter/cli/printer.rb +14 -0
  32. data/lib/mutant/reporter/cli/progress.rb +1 -3
  33. data/lib/mutant/reporter/cli/progress/config.rb +5 -9
  34. data/lib/mutant/reporter/cli/progress/env.rb +30 -0
  35. data/lib/mutant/reporter/cli/progress/noop.rb +4 -1
  36. data/lib/mutant/reporter/cli/progress/result.rb +12 -0
  37. data/lib/mutant/reporter/cli/progress/result/mutation.rb +45 -0
  38. data/lib/mutant/reporter/cli/progress/result/subject.rb +54 -0
  39. data/lib/mutant/reporter/cli/progress/subject.rb +7 -90
  40. data/lib/mutant/reporter/cli/registry.rb +2 -0
  41. data/lib/mutant/reporter/cli/report/env.rb +92 -0
  42. data/lib/mutant/reporter/cli/report/mutation.rb +58 -77
  43. data/lib/mutant/reporter/cli/report/subject.rb +4 -3
  44. data/lib/mutant/reporter/cli/report/test.rb +28 -0
  45. data/lib/mutant/reporter/null.rb +1 -1
  46. data/lib/mutant/reporter/trace.rb +16 -3
  47. data/lib/mutant/result.rb +302 -0
  48. data/lib/mutant/runner.rb +77 -123
  49. data/lib/mutant/subject.rb +32 -16
  50. data/lib/mutant/subject/method.rb +0 -15
  51. data/lib/mutant/subject/method/instance.rb +3 -3
  52. data/lib/mutant/version.rb +1 -1
  53. data/lib/mutant/warning_expectation.rb +12 -5
  54. data/spec/integration/mutant/corpus_spec.rb +1 -1
  55. data/spec/spec_helper.rb +5 -1
  56. data/spec/unit/mutant/cli_spec.rb +248 -0
  57. data/spec/unit/mutant/expression/namespace/flat_spec.rb +1 -1
  58. data/spec/unit/mutant/expression_spec.rb +55 -0
  59. data/spec/unit/mutant/integration_spec.rb +0 -5
  60. data/spec/unit/mutant/isolation_spec.rb +36 -5
  61. data/spec/unit/mutant/matcher/chain_spec.rb +1 -13
  62. data/spec/unit/mutant/matcher/compiler_spec.rb +95 -0
  63. data/spec/unit/mutant/matcher/filter_spec.rb +31 -0
  64. data/spec/unit/mutant/matcher/method/instance_spec.rb +33 -2
  65. data/spec/unit/mutant/matcher/method/singleton_spec.rb +1 -1
  66. data/spec/unit/mutant/matcher/methods/instance_spec.rb +1 -1
  67. data/spec/unit/mutant/matcher/methods/singleton_spec.rb +1 -1
  68. data/spec/unit/mutant/matcher/namespace_spec.rb +10 -6
  69. data/spec/unit/mutant/matcher/null_spec.rb +26 -0
  70. data/spec/unit/mutant/reporter/cli_spec.rb +337 -0
  71. data/spec/unit/mutant/reporter/null_spec.rb +12 -0
  72. data/spec/unit/mutant/runner_spec.rb +130 -0
  73. data/spec/unit/mutant/subject/context_spec.rb +4 -3
  74. data/spec/unit/mutant/subject/method/instance_spec.rb +5 -3
  75. data/spec/unit/mutant/subject/method/singleton_spec.rb +3 -2
  76. data/spec/unit/mutant/subject_spec.rb +36 -1
  77. data/spec/unit/mutant/test_spec.rb +25 -0
  78. data/spec/unit/mutant/warning_expectation.rb +11 -8
  79. data/spec/unit/mutant_spec.rb +11 -2
  80. metadata +27 -28
  81. data/lib/mutant/killer.rb +0 -44
  82. data/lib/mutant/matcher/builder.rb +0 -142
  83. data/lib/mutant/mutation/evil.rb +0 -23
  84. data/lib/mutant/mutation/neutral.rb +0 -18
  85. data/lib/mutant/reporter/cli/progress/mutation.rb +0 -46
  86. data/lib/mutant/reporter/cli/report/config.rb +0 -116
  87. data/lib/mutant/rspec.rb +0 -0
  88. data/lib/mutant/runner/config.rb +0 -138
  89. data/lib/mutant/runner/killer.rb +0 -75
  90. data/lib/mutant/runner/mutation.rb +0 -78
  91. data/lib/mutant/runner/subject.rb +0 -85
  92. data/lib/mutant/test/report.rb +0 -59
  93. data/spec/unit/mutant/cli_new_spec.rb +0 -147
  94. data/spec/unit/mutant/cli_run_spec.rb +0 -46
  95. data/spec/unit/mutant/runner/config_spec.rb +0 -157
  96. data/spec/unit/mutant/runner/mutation_spec.rb +0 -101
  97. data/spec/unit/mutant/runner/subject_spec.rb +0 -59
  98. data/spec/unit/mutant/subject/mutations_spec.rb +0 -23
  99. data/spec/unit/mutant/subject/node_spec.rb +0 -17
@@ -7,9 +7,10 @@ describe Mutant::Subject, '#context' do
7
7
  Class.new(described_class)
8
8
  end
9
9
 
10
- let(:object) { class_under_test.new(context, node) }
11
- let(:node) { double('Node') }
12
- let(:context) { double('Context') }
10
+ let(:object) { class_under_test.new(config, context, node) }
11
+ let(:config) { Mutant::Config::DEFAULT }
12
+ let(:node) { double('Node') }
13
+ let(:context) { double('Context') }
13
14
 
14
15
  it { should be(context) }
15
16
 
@@ -3,8 +3,9 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Mutant::Subject::Method::Instance do
6
- let(:object) { described_class.new(context, node) }
6
+ let(:object) { described_class.new(config, context, node) }
7
7
  let(:context) { double }
8
+ let(:config) { Mutant::Config::DEFAULT }
8
9
 
9
10
  let(:node) do
10
11
  s(:def, :foo, s(:args))
@@ -71,8 +72,9 @@ describe Mutant::Subject::Method::Instance do
71
72
  end
72
73
 
73
74
  describe Mutant::Subject::Method::Instance::Memoized do
74
- let(:object) { described_class.new(context, node) }
75
- let(:context) { double }
75
+ let(:object) { described_class.new(config, context, node) }
76
+ let(:context) { double }
77
+ let(:config) { Mutant::Config::DEFAULT }
76
78
 
77
79
  let(:node) do
78
80
  s(:def, :foo, s(:args))
@@ -4,8 +4,9 @@ require 'spec_helper'
4
4
 
5
5
  describe Mutant::Subject::Method::Singleton do
6
6
 
7
- let(:object) { described_class.new(context, node) }
8
- let(:context) { double }
7
+ let(:object) { described_class.new(config, context, node) }
8
+ let(:config) { Mutant::Config::DEFAULT }
9
+ let(:context) { double }
9
10
 
10
11
  let(:node) do
11
12
  s(:defs, s(:self), :foo, s(:args))
@@ -9,7 +9,9 @@ describe Mutant::Subject do
9
9
  end
10
10
  end
11
11
 
12
- let(:object) { class_under_test.new(context, node) }
12
+ let(:object) { class_under_test.new(config, context, node) }
13
+
14
+ let(:config) { Mutant::Config::DEFAULT }
13
15
 
14
16
  let(:node) do
15
17
  double('Node', location: location)
@@ -36,4 +38,37 @@ describe Mutant::Subject do
36
38
 
37
39
  it { should eql('Test:source_path:source_line') }
38
40
  end
41
+
42
+ describe '#prepare' do
43
+ subject { object.prepare }
44
+
45
+ it_should_behave_like 'a command method'
46
+ end
47
+
48
+ describe '#node' do
49
+ subject { object.node }
50
+
51
+ it { should be(node) }
52
+
53
+ it_should_behave_like 'an idempotent method'
54
+ end
55
+
56
+ describe '#mutations' do
57
+ subject { object.mutations }
58
+
59
+ before do
60
+ expect(Mutant::Mutator).to receive(:each).with(node).and_yield(mutation_a).and_yield(mutation_b)
61
+ end
62
+
63
+ let(:mutation_a) { double('Mutation A') }
64
+ let(:mutation_b) { double('Mutation B') }
65
+
66
+ it 'generates neutral and evil mutations' do
67
+ should eql([
68
+ Mutant::Mutation::Neutral.new(object, node),
69
+ Mutant::Mutation::Evil.new(object, mutation_a),
70
+ Mutant::Mutation::Evil.new(object, mutation_b)
71
+ ])
72
+ end
73
+ end
39
74
  end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mutant::Test do
4
+ let(:object) { described_class.new(integration, expression) }
5
+
6
+ let(:integration) { double('Integration', name: 'test-integration') }
7
+ let(:expression) { double('Expression', syntax: 'test-syntax') }
8
+
9
+ describe '#identification' do
10
+ subject { object.identification }
11
+
12
+ it { should eql('test-integration:test-syntax') }
13
+ end
14
+
15
+ describe '#run' do
16
+ subject { object.run }
17
+
18
+ let(:report) { double('Report') }
19
+
20
+ it 'runs test via integration' do
21
+ expect(integration).to receive(:run).with(object).and_return(report)
22
+ expect(subject).to be(report)
23
+ end
24
+ end
25
+ end
@@ -4,7 +4,7 @@ describe Mutant::WarningExpectation do
4
4
  let(:object) { described_class.new(expected_warnings) }
5
5
 
6
6
  let(:expected_warnings) { [] }
7
- let(:warnings) { [] }
7
+ let(:actual_warnings) { [] }
8
8
 
9
9
  let(:warning_a) { "foo.rb:10: warning: We have a problem!\n" }
10
10
  let(:warning_b) { "bar.rb:10: warning: We have an other problem!\n" }
@@ -19,7 +19,7 @@ describe Mutant::WarningExpectation do
19
19
  let(:block) do
20
20
  lambda do
21
21
  @called = true
22
- warnings.each(&Kernel.method(:warn))
22
+ actual_warnings.each(&Kernel.method(:warn))
23
23
  end
24
24
  end
25
25
 
@@ -28,6 +28,7 @@ describe Mutant::WarningExpectation do
28
28
  end
29
29
 
30
30
  context 'when no warnings occur during block execution' do
31
+
31
32
  context 'and no warnings are expected' do
32
33
  it_should_behave_like 'a command method'
33
34
  end
@@ -35,20 +36,22 @@ describe Mutant::WarningExpectation do
35
36
  context 'and warnings are expected' do
36
37
  let(:expected_warnings) { [warning_a] }
37
38
 
38
- it 'raises an expectation error' do
39
- expect { subject }.to raise_error(Mutant::WarningExpectation::ExpectationError.new([], [warning_a]))
39
+ before do
40
+ expect($stderr).to receive(:puts).with("Expected but missing warnings: #{expected_warnings}")
40
41
  end
42
+
43
+ it_should_behave_like 'a command method'
41
44
  end
42
45
  end
43
46
 
44
47
  context 'when warnings occur during block execution' do
45
- let(:warnings) { [warning_a, warning_b] }
48
+ let(:actual_warnings) { [warning_a, warning_b] }
46
49
 
47
50
  context 'and only some no warnings are expected' do
48
51
  let(:expected_warnings) { [warning_a] }
49
52
 
50
53
  it 'raises an expectation error' do
51
- expect { subject }.to raise_error(Mutant::WarningExpectation::ExpectationError.new([warning_b], []))
54
+ expect { subject }.to raise_error(Mutant::WarningExpectation::ExpectationError.new(expected_warnings))
52
55
  end
53
56
  end
54
57
 
@@ -60,10 +63,10 @@ describe Mutant::WarningExpectation do
60
63
 
61
64
  context 'and there is an expected warning missing' do
62
65
  let(:expected_warnings) { [warning_a] }
63
- let(:warnings) { [warning_b] }
66
+ let(:actual_warnings) { [warning_b] }
64
67
 
65
68
  it 'raises an expectation error' do
66
- expect { subject }.to raise_error(Mutant::WarningExpectation::ExpectationError.new([warning_b], [warning_a]))
69
+ expect { subject }.to raise_error(Mutant::WarningExpectation::ExpectationError.new([warning_b]))
67
70
  end
68
71
  end
69
72
  end
@@ -1,9 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Mutant do
4
- describe '.singleton_subclass_instance' do
5
- let(:object) { described_class }
4
+ let(:object) { described_class }
5
+
6
+ describe '.zombify' do
7
+ subject { object.zombify }
8
+
9
+ it 'calls the zombifier' do
10
+ expect(Mutant::Zombifier).to receive(:run).with('mutant', :Zombie)
11
+ subject
12
+ end
13
+ end
6
14
 
15
+ describe '.singleton_subclass_instance' do
7
16
  subject { object.singleton_subclass_instance(name, superclass, &block) }
8
17
 
9
18
  before { subject }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mutant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.24
4
+ version: 0.5.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-30 00:00:00.000000000 Z
11
+ date: 2014-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -296,11 +296,11 @@ files:
296
296
  - lib/mutant/expression/namespace.rb
297
297
  - lib/mutant/integration.rb
298
298
  - lib/mutant/isolation.rb
299
- - lib/mutant/killer.rb
300
299
  - lib/mutant/loader.rb
301
300
  - lib/mutant/matcher.rb
302
- - lib/mutant/matcher/builder.rb
303
301
  - lib/mutant/matcher/chain.rb
302
+ - lib/mutant/matcher/compiler.rb
303
+ - lib/mutant/matcher/config.rb
304
304
  - lib/mutant/matcher/filter.rb
305
305
  - lib/mutant/matcher/method.rb
306
306
  - lib/mutant/matcher/method/finder.rb
@@ -314,8 +314,6 @@ files:
314
314
  - lib/mutant/meta/example.rb
315
315
  - lib/mutant/meta/example/dsl.rb
316
316
  - lib/mutant/mutation.rb
317
- - lib/mutant/mutation/evil.rb
318
- - lib/mutant/mutation/neutral.rb
319
317
  - lib/mutant/mutator.rb
320
318
  - lib/mutant/mutator/node.rb
321
319
  - lib/mutant/mutator/node/and_asgn.rb
@@ -380,29 +378,28 @@ files:
380
378
  - lib/mutant/reporter/cli/printer.rb
381
379
  - lib/mutant/reporter/cli/progress.rb
382
380
  - lib/mutant/reporter/cli/progress/config.rb
383
- - lib/mutant/reporter/cli/progress/mutation.rb
381
+ - lib/mutant/reporter/cli/progress/env.rb
384
382
  - lib/mutant/reporter/cli/progress/noop.rb
383
+ - lib/mutant/reporter/cli/progress/result.rb
384
+ - lib/mutant/reporter/cli/progress/result/mutation.rb
385
+ - lib/mutant/reporter/cli/progress/result/subject.rb
385
386
  - lib/mutant/reporter/cli/progress/subject.rb
386
387
  - lib/mutant/reporter/cli/registry.rb
387
388
  - lib/mutant/reporter/cli/report.rb
388
- - lib/mutant/reporter/cli/report/config.rb
389
+ - lib/mutant/reporter/cli/report/env.rb
389
390
  - lib/mutant/reporter/cli/report/mutation.rb
390
391
  - lib/mutant/reporter/cli/report/subject.rb
392
+ - lib/mutant/reporter/cli/report/test.rb
391
393
  - lib/mutant/reporter/null.rb
392
394
  - lib/mutant/reporter/trace.rb
393
395
  - lib/mutant/require_highjack.rb
394
- - lib/mutant/rspec.rb
396
+ - lib/mutant/result.rb
395
397
  - lib/mutant/runner.rb
396
- - lib/mutant/runner/config.rb
397
- - lib/mutant/runner/killer.rb
398
- - lib/mutant/runner/mutation.rb
399
- - lib/mutant/runner/subject.rb
400
398
  - lib/mutant/subject.rb
401
399
  - lib/mutant/subject/method.rb
402
400
  - lib/mutant/subject/method/instance.rb
403
401
  - lib/mutant/subject/method/singleton.rb
404
402
  - lib/mutant/test.rb
405
- - lib/mutant/test/report.rb
406
403
  - lib/mutant/version.rb
407
404
  - lib/mutant/walker.rb
408
405
  - lib/mutant/warning_expectation.rb
@@ -481,8 +478,7 @@ files:
481
478
  - spec/support/mutation_verifier.rb
482
479
  - spec/support/rspec.rb
483
480
  - spec/support/test_app.rb
484
- - spec/unit/mutant/cli_new_spec.rb
485
- - spec/unit/mutant/cli_run_spec.rb
481
+ - spec/unit/mutant/cli_spec.rb
486
482
  - spec/unit/mutant/context/root_spec.rb
487
483
  - spec/unit/mutant/context/scope/root_spec.rb
488
484
  - spec/unit/mutant/context/scope/unqualified_name_spec.rb
@@ -491,28 +487,30 @@ files:
491
487
  - spec/unit/mutant/expression/methods_spec.rb
492
488
  - spec/unit/mutant/expression/namespace/flat_spec.rb
493
489
  - spec/unit/mutant/expression/namespace/recursive_spec.rb
490
+ - spec/unit/mutant/expression_spec.rb
494
491
  - spec/unit/mutant/integration_spec.rb
495
492
  - spec/unit/mutant/isolation_spec.rb
496
493
  - spec/unit/mutant/loader/eval_spec.rb
497
494
  - spec/unit/mutant/matcher/chain_spec.rb
495
+ - spec/unit/mutant/matcher/compiler_spec.rb
496
+ - spec/unit/mutant/matcher/filter_spec.rb
498
497
  - spec/unit/mutant/matcher/method/instance_spec.rb
499
498
  - spec/unit/mutant/matcher/method/singleton_spec.rb
500
499
  - spec/unit/mutant/matcher/methods/instance_spec.rb
501
500
  - spec/unit/mutant/matcher/methods/singleton_spec.rb
502
501
  - spec/unit/mutant/matcher/namespace_spec.rb
502
+ - spec/unit/mutant/matcher/null_spec.rb
503
503
  - spec/unit/mutant/mutation_spec.rb
504
504
  - spec/unit/mutant/mutator/node_spec.rb
505
+ - spec/unit/mutant/reporter/cli_spec.rb
505
506
  - spec/unit/mutant/reporter/null_spec.rb
506
507
  - spec/unit/mutant/require_highjack_spec.rb
507
- - spec/unit/mutant/runner/config_spec.rb
508
- - spec/unit/mutant/runner/mutation_spec.rb
509
- - spec/unit/mutant/runner/subject_spec.rb
508
+ - spec/unit/mutant/runner_spec.rb
510
509
  - spec/unit/mutant/subject/context_spec.rb
511
510
  - spec/unit/mutant/subject/method/instance_spec.rb
512
511
  - spec/unit/mutant/subject/method/singleton_spec.rb
513
- - spec/unit/mutant/subject/mutations_spec.rb
514
- - spec/unit/mutant/subject/node_spec.rb
515
512
  - spec/unit/mutant/subject_spec.rb
513
+ - spec/unit/mutant/test_spec.rb
516
514
  - spec/unit/mutant/warning_expectation.rb
517
515
  - spec/unit/mutant/warning_filter_spec.rb
518
516
  - spec/unit/mutant_spec.rb
@@ -555,8 +553,7 @@ test_files:
555
553
  - spec/integration/mutant/rspec_spec.rb
556
554
  - spec/integration/mutant/test_mutator_handles_types_spec.rb
557
555
  - spec/integration/mutant/zombie_spec.rb
558
- - spec/unit/mutant/cli_new_spec.rb
559
- - spec/unit/mutant/cli_run_spec.rb
556
+ - spec/unit/mutant/cli_spec.rb
560
557
  - spec/unit/mutant/context/root_spec.rb
561
558
  - spec/unit/mutant/context/scope/root_spec.rb
562
559
  - spec/unit/mutant/context/scope/unqualified_name_spec.rb
@@ -565,28 +562,30 @@ test_files:
565
562
  - spec/unit/mutant/expression/methods_spec.rb
566
563
  - spec/unit/mutant/expression/namespace/flat_spec.rb
567
564
  - spec/unit/mutant/expression/namespace/recursive_spec.rb
565
+ - spec/unit/mutant/expression_spec.rb
568
566
  - spec/unit/mutant/integration_spec.rb
569
567
  - spec/unit/mutant/isolation_spec.rb
570
568
  - spec/unit/mutant/loader/eval_spec.rb
571
569
  - spec/unit/mutant/matcher/chain_spec.rb
570
+ - spec/unit/mutant/matcher/compiler_spec.rb
571
+ - spec/unit/mutant/matcher/filter_spec.rb
572
572
  - spec/unit/mutant/matcher/method/instance_spec.rb
573
573
  - spec/unit/mutant/matcher/method/singleton_spec.rb
574
574
  - spec/unit/mutant/matcher/methods/instance_spec.rb
575
575
  - spec/unit/mutant/matcher/methods/singleton_spec.rb
576
576
  - spec/unit/mutant/matcher/namespace_spec.rb
577
+ - spec/unit/mutant/matcher/null_spec.rb
577
578
  - spec/unit/mutant/mutation_spec.rb
578
579
  - spec/unit/mutant/mutator/node_spec.rb
580
+ - spec/unit/mutant/reporter/cli_spec.rb
579
581
  - spec/unit/mutant/reporter/null_spec.rb
580
582
  - spec/unit/mutant/require_highjack_spec.rb
581
- - spec/unit/mutant/runner/config_spec.rb
582
- - spec/unit/mutant/runner/mutation_spec.rb
583
- - spec/unit/mutant/runner/subject_spec.rb
583
+ - spec/unit/mutant/runner_spec.rb
584
584
  - spec/unit/mutant/subject/context_spec.rb
585
585
  - spec/unit/mutant/subject/method/instance_spec.rb
586
586
  - spec/unit/mutant/subject/method/singleton_spec.rb
587
- - spec/unit/mutant/subject/mutations_spec.rb
588
- - spec/unit/mutant/subject/node_spec.rb
589
587
  - spec/unit/mutant/subject_spec.rb
588
+ - spec/unit/mutant/test_spec.rb
590
589
  - spec/unit/mutant/warning_expectation.rb
591
590
  - spec/unit/mutant/warning_filter_spec.rb
592
591
  - spec/unit/mutant_spec.rb
@@ -1,44 +0,0 @@
1
- module Mutant
2
- # Mutation killer
3
- class Killer
4
- include Adamantium::Flat, Anima.new(:test, :mutation)
5
-
6
- # Report object for kill results
7
- class Report
8
- include Anima.new(
9
- :killer,
10
- :test_report
11
- )
12
-
13
- # Test if kill was successful
14
- #
15
- # @return [Boolean]
16
- #
17
- # @api private
18
- #
19
- def success?
20
- killer.mutation.should_fail?.equal?(test_report.failed?)
21
- end
22
-
23
- end # Report
24
-
25
- # Return killer report
26
- #
27
- # @return [Killer::Report]
28
- #
29
- # @api private
30
- #
31
- def run
32
- test_report = Isolation.call do
33
- mutation.insert
34
- test.run
35
- end
36
-
37
- Report.new(
38
- killer: self,
39
- test_report: test_report.update(test: test)
40
- )
41
- end
42
-
43
- end # Killer
44
- end # Mutant
@@ -1,142 +0,0 @@
1
- module Mutant
2
- class Matcher
3
- # Builder for complex matchers
4
- class Builder
5
- include Concord.new(:env), AST::Sexp
6
-
7
- # Initalize object
8
- #
9
- # @param [Cache] env
10
- #
11
- # @return [undefined]
12
- #
13
- # @api private
14
- #
15
- def initialize(env)
16
- super
17
- @matchers = []
18
- @subject_ignores = []
19
- @subject_selectors = []
20
- end
21
-
22
- # Add a subject ignore
23
- #
24
- # @param [Expression] expression
25
- #
26
- # @return [self]
27
- #
28
- # @api private
29
- #
30
- def add_subject_ignore(expression)
31
- @subject_ignores << expression.matcher(env)
32
- self
33
- end
34
-
35
- # Add a subject selector
36
- #
37
- # @param [#call] selector
38
- #
39
- # @return [self]
40
- #
41
- # @api private
42
- #
43
- def add_subject_selector(attribute, value)
44
- @subject_selectors << Morpher.compile(s(:eql, s(:attribute, attribute), s(:static, value)))
45
- self
46
- end
47
-
48
- # Add a match expression
49
- #
50
- # @param [Expression] expression
51
- #
52
- # @return [self]
53
- #
54
- # @api private
55
- #
56
- def add_match_expression(expression)
57
- @matchers << expression.matcher(env)
58
- self
59
- end
60
-
61
- # Return generated matcher
62
- #
63
- # @return [Mutant::Matcher]
64
- #
65
- # @api private
66
- #
67
- def matcher
68
- if @matchers.empty?
69
- return Matcher::Null.new
70
- end
71
-
72
- matcher = Matcher::Chain.build(@matchers)
73
-
74
- if predicate
75
- Matcher::Filter.new(matcher, predicate)
76
- else
77
- matcher
78
- end
79
- end
80
-
81
- private
82
-
83
- # Return subject selector
84
- #
85
- # @return [#call]
86
- # if selector is present
87
- #
88
- # @return [nil]
89
- # otherwise
90
- #
91
- # @api private
92
- #
93
- def subject_selector
94
- Morpher::Evaluator::Predicate::Boolean::Or.new(@subject_selectors) if @subject_selectors.any?
95
- end
96
-
97
- # Return predicate
98
- #
99
- # @return [#call]
100
- # if filter is needed
101
- #
102
- # @return [nil]
103
- # othrwise
104
- #
105
- # @api private
106
- #
107
- def predicate
108
- if subject_selector && subject_rejector
109
- Morpher::Evaluator::Predicate::Boolean::And.new([
110
- subject_selector,
111
- Morpher::Evaluator::Predicate::Negation.new(subject_rejector)
112
- ])
113
- elsif subject_selector
114
- subject_selector
115
- elsif subject_rejector
116
- Morpher::Evaluator::Predicate::Negation.new(subject_rejector)
117
- else
118
- nil
119
- end
120
- end
121
-
122
- # Return subject rejector
123
- #
124
- # @return [#call]
125
- # if there is a subject rejector
126
- #
127
- # @return [nil]
128
- # otherwise
129
- #
130
- # @api private
131
- #
132
- def subject_rejector
133
- rejectors = @subject_ignores.flat_map(&:to_a).map do |subject|
134
- Morpher.compile(s(:eql, s(:attribute, :identification), s(:static, subject.identification)))
135
- end
136
-
137
- Morpher::Evaluator::Predicate::Boolean::Or.new(rejectors) if rejectors.any?
138
- end
139
-
140
- end # Builder
141
- end # Matcher
142
- end # Mutant