mutant 0.8.9 → 0.8.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +4 -0
  3. data/config/devtools.yml +1 -1
  4. data/config/flay.yml +1 -1
  5. data/lib/mutant.rb +1 -2
  6. data/lib/mutant/ast/types.rb +3 -2
  7. data/lib/mutant/context.rb +78 -6
  8. data/lib/mutant/diff.rb +7 -13
  9. data/lib/mutant/matcher/method.rb +2 -2
  10. data/lib/mutant/mutation.rb +1 -1
  11. data/lib/mutant/mutator/node/generic.rb +1 -1
  12. data/lib/mutant/reporter/cli/printer.rb +25 -1
  13. data/lib/mutant/reporter/sequence.rb +22 -0
  14. data/lib/mutant/result.rb +4 -9
  15. data/lib/mutant/version.rb +1 -1
  16. data/meta/dsym.rb +7 -7
  17. data/mutant.gemspec +5 -5
  18. data/spec/spec_helper.rb +0 -1
  19. data/spec/unit/mutant/ast/named_children_spec.rb +12 -2
  20. data/spec/unit/mutant/context_spec.rb +85 -1
  21. data/spec/unit/mutant/diff_spec.rb +9 -0
  22. data/spec/unit/mutant/mutation_spec.rb +55 -4
  23. data/spec/unit/mutant/reporter/cli/printer/mutation_result_spec.rb +3 -3
  24. data/spec/unit/mutant/reporter/cli/printer_spec.rb +27 -6
  25. data/spec/unit/mutant/reporter/null_spec.rb +5 -15
  26. data/spec/unit/mutant/reporter/sequence_spec.rb +29 -0
  27. data/spec/unit/mutant/result/class_methods_spec.rb +49 -0
  28. data/spec/unit/mutant/result/mutation_spec.rb +49 -0
  29. data/spec/unit/mutant/result/subject_spec.rb +84 -19
  30. data/spec/unit/mutant/result_spec.rb +18 -10
  31. data/spec/unit/mutant/subject/method/instance_spec.rb +3 -3
  32. data/spec/unit/mutant/subject/method/singleton_spec.rb +1 -1
  33. metadata +19 -22
  34. data/lib/mutant/context/scope.rb +0 -94
  35. data/lib/mutant/delegator.rb +0 -43
  36. data/spec/unit/mutant/context/root_spec.rb +0 -11
  37. data/spec/unit/mutant/context/scope/root_spec.rb +0 -32
  38. data/spec/unit/mutant/context/scope/unqualified_name_spec.rb +0 -25
  39. data/spec/unit/mutant/context/scope_spec.rb +0 -11
@@ -1,17 +1,17 @@
1
1
  RSpec.describe Mutant::Result do
2
- describe '.included' do
3
- let(:object) do
4
- Class.new do
5
- include Mutant::Result
2
+ let(:object) do
3
+ Class.new do
4
+ include Mutant::Result, Concord.new(:runtime, :killtime)
6
5
 
7
- def collection
8
- [[1]]
9
- end
6
+ def collection
7
+ [[1]]
8
+ end
10
9
 
11
- sum :length, :collection
12
- end.new
13
- end
10
+ sum :length, :collection
11
+ end.new(3.0, 1.0)
12
+ end
14
13
 
14
+ describe '.included' do
15
15
  it 'includes mixin to freeze instances' do
16
16
  expect(object.frozen?).to be(true)
17
17
  end
@@ -20,4 +20,12 @@ RSpec.describe Mutant::Result do
20
20
  expect(object.length).to be(1)
21
21
  end
22
22
  end
23
+
24
+ describe '#overhead' do
25
+ subject { object.overhead }
26
+
27
+ it 'returns difference between runtime and killtime' do
28
+ should eql(2.0)
29
+ end
30
+ end
23
31
  end
@@ -2,7 +2,7 @@ RSpec.describe Mutant::Subject::Method::Instance do
2
2
  let(:object) { described_class.new(context, node) }
3
3
 
4
4
  let(:context) do
5
- Mutant::Context::Scope.new(
5
+ Mutant::Context.new(
6
6
  scope,
7
7
  instance_double(Pathname)
8
8
  )
@@ -48,7 +48,7 @@ RSpec.describe Mutant::Subject::Method::Instance do
48
48
  describe '#prepare' do
49
49
 
50
50
  let(:context) do
51
- Mutant::Context::Scope.new(scope, instance_double(Pathname))
51
+ Mutant::Context.new(scope, instance_double(Pathname))
52
52
  end
53
53
 
54
54
  subject { object.prepare }
@@ -78,7 +78,7 @@ RSpec.describe Mutant::Subject::Method::Instance::Memoized do
78
78
  describe '#prepare' do
79
79
 
80
80
  let(:context) do
81
- Mutant::Context::Scope.new(scope, double('Source Path'))
81
+ Mutant::Context.new(scope, double('Source Path'))
82
82
  end
83
83
 
84
84
  let(:scope) do
@@ -4,7 +4,7 @@ RSpec.describe Mutant::Subject::Method::Singleton do
4
4
  let(:node) { s(:defs, s(:self), :foo, s(:args)) }
5
5
 
6
6
  let(:context) do
7
- Mutant::Context::Scope.new(scope, instance_double(Pathname))
7
+ Mutant::Context.new(scope, instance_double(Pathname))
8
8
  end
9
9
 
10
10
  let(:scope) do
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.8.9
4
+ version: 0.8.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-06 00:00:00.000000000 Z
11
+ date: 2016-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.2.2
19
+ version: 2.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.2.2
26
+ version: 2.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ast
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.1'
33
+ version: '2.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.1'
40
+ version: '2.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: diff-lcs
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.2.5
75
+ version: 0.2.6
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.2.5
82
+ version: 0.2.6
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: procto
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.2.4
117
+ version: 0.2.5
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.2.4
124
+ version: 0.2.5
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: ice_nine
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -212,14 +212,14 @@ dependencies:
212
212
  requirements:
213
213
  - - "~>"
214
214
  - !ruby/object:Gem::Version
215
- version: 0.1.1
215
+ version: 0.1.3
216
216
  type: :development
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
- version: 0.1.1
222
+ version: 0.1.3
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: bundler
225
225
  requirement: !ruby/object:Gem::Requirement
@@ -301,8 +301,6 @@ files:
301
301
  - lib/mutant/color.rb
302
302
  - lib/mutant/config.rb
303
303
  - lib/mutant/context.rb
304
- - lib/mutant/context/scope.rb
305
- - lib/mutant/delegator.rb
306
304
  - lib/mutant/diff.rb
307
305
  - lib/mutant/env.rb
308
306
  - lib/mutant/env/bootstrap.rb
@@ -411,6 +409,7 @@ files:
411
409
  - lib/mutant/reporter/cli/printer/test_result.rb
412
410
  - lib/mutant/reporter/cli/tput.rb
413
411
  - lib/mutant/reporter/null.rb
412
+ - lib/mutant/reporter/sequence.rb
414
413
  - lib/mutant/repository.rb
415
414
  - lib/mutant/require_highjack.rb
416
415
  - lib/mutant/result.rb
@@ -516,10 +515,6 @@ files:
516
515
  - spec/unit/mutant/ast/sexp_spec.rb
517
516
  - spec/unit/mutant/ast_spec.rb
518
517
  - spec/unit/mutant/cli_spec.rb
519
- - spec/unit/mutant/context/root_spec.rb
520
- - spec/unit/mutant/context/scope/root_spec.rb
521
- - spec/unit/mutant/context/scope/unqualified_name_spec.rb
522
- - spec/unit/mutant/context/scope_spec.rb
523
518
  - spec/unit/mutant/context_spec.rb
524
519
  - spec/unit/mutant/diff_spec.rb
525
520
  - spec/unit/mutant/env/boostrap_spec.rb
@@ -569,10 +564,13 @@ files:
569
564
  - spec/unit/mutant/reporter/cli/tput_spec.rb
570
565
  - spec/unit/mutant/reporter/cli_spec.rb
571
566
  - spec/unit/mutant/reporter/null_spec.rb
567
+ - spec/unit/mutant/reporter/sequence_spec.rb
572
568
  - spec/unit/mutant/repository/diff_spec.rb
573
569
  - spec/unit/mutant/repository/subject_filter_spec.rb
574
570
  - spec/unit/mutant/require_highjack_spec.rb
571
+ - spec/unit/mutant/result/class_methods_spec.rb
575
572
  - spec/unit/mutant/result/env_spec.rb
573
+ - spec/unit/mutant/result/mutation_spec.rb
576
574
  - spec/unit/mutant/result/subject_spec.rb
577
575
  - spec/unit/mutant/result_spec.rb
578
576
  - spec/unit/mutant/runner/driver_spec.rb
@@ -634,10 +632,6 @@ test_files:
634
632
  - spec/unit/mutant/ast/sexp_spec.rb
635
633
  - spec/unit/mutant/ast_spec.rb
636
634
  - spec/unit/mutant/cli_spec.rb
637
- - spec/unit/mutant/context/root_spec.rb
638
- - spec/unit/mutant/context/scope/root_spec.rb
639
- - spec/unit/mutant/context/scope/unqualified_name_spec.rb
640
- - spec/unit/mutant/context/scope_spec.rb
641
635
  - spec/unit/mutant/context_spec.rb
642
636
  - spec/unit/mutant/diff_spec.rb
643
637
  - spec/unit/mutant/env/boostrap_spec.rb
@@ -687,10 +681,13 @@ test_files:
687
681
  - spec/unit/mutant/reporter/cli/tput_spec.rb
688
682
  - spec/unit/mutant/reporter/cli_spec.rb
689
683
  - spec/unit/mutant/reporter/null_spec.rb
684
+ - spec/unit/mutant/reporter/sequence_spec.rb
690
685
  - spec/unit/mutant/repository/diff_spec.rb
691
686
  - spec/unit/mutant/repository/subject_filter_spec.rb
692
687
  - spec/unit/mutant/require_highjack_spec.rb
688
+ - spec/unit/mutant/result/class_methods_spec.rb
693
689
  - spec/unit/mutant/result/env_spec.rb
690
+ - spec/unit/mutant/result/mutation_spec.rb
694
691
  - spec/unit/mutant/result/subject_spec.rb
695
692
  - spec/unit/mutant/result_spec.rb
696
693
  - spec/unit/mutant/runner/driver_spec.rb
@@ -1,94 +0,0 @@
1
- module Mutant
2
- class Context
3
- # Scope context for mutation (Class or Module)
4
- class Scope < self
5
- include Adamantium::Flat, Concord::Public.new(:scope, :source_path)
6
- extend AST::Sexp
7
-
8
- NAMESPACE_DELIMITER = '::'.freeze
9
-
10
- # Return root node for mutation
11
- #
12
- # @return [Parser::AST::Node]
13
- def root(node)
14
- nesting.reverse.reduce(node) do |current, scope|
15
- self.class.wrap(scope, current)
16
- end
17
- end
18
-
19
- # Identification string
20
- #
21
- # @return [String]
22
- def identification
23
- scope.name
24
- end
25
-
26
- # Wrap node into ast node
27
- #
28
- # @param [Class, Module] scope
29
- # @param [Parser::AST::Node] node
30
- #
31
- # @return [Parser::AST::Class]
32
- # if scope is of kind Class
33
- #
34
- # @return [Parser::AST::Module]
35
- # if scope is of kind module
36
- def self.wrap(scope, node)
37
- name = s(:const, nil, scope.name.split(NAMESPACE_DELIMITER).last.to_sym)
38
- case scope
39
- when Class
40
- s(:class, name, nil, node)
41
- when Module
42
- s(:module, name, node)
43
- end
44
- end
45
-
46
- # Nesting of scope
47
- #
48
- # @return [Enumerable<Class,Module>]
49
- def nesting
50
- const = ::Object
51
- name_nesting.each_with_object([]) do |name, nesting|
52
- const = const.const_get(name)
53
- nesting << const
54
- end
55
- end
56
- memoize :nesting
57
-
58
- # Unqualified name of scope
59
- #
60
- # @return [String]
61
- def unqualified_name
62
- name_nesting.last
63
- end
64
-
65
- # Match expressions for scope
66
- #
67
- # @return [Enumerable<Expression>]
68
- def match_expressions
69
- name_nesting.each_index.reverse_each.map do |index|
70
- Expression::Namespace::Recursive.new(
71
- scope_name: name_nesting.take(index.succ).join(NAMESPACE_DELIMITER)
72
- )
73
- end
74
- end
75
- memoize :match_expressions
76
-
77
- # Scope wrapped by context
78
- #
79
- # @return [::Module|::Class]
80
- attr_reader :scope
81
-
82
- private
83
-
84
- # Nesting of names in scope
85
- #
86
- # @return [Array<String>]
87
- def name_nesting
88
- scope.name.split(NAMESPACE_DELIMITER)
89
- end
90
- memoize :name_nesting
91
-
92
- end # Scope
93
- end # Context
94
- end # Mutant
@@ -1,43 +0,0 @@
1
- module Mutant
2
- # A simple delegator with opinions
3
- module Delegator
4
- # Class level mixins
5
- module ClassMethods
6
-
7
- private
8
-
9
- # Create delegators to object
10
- #
11
- # @return [undefined]
12
- def delegate(*names)
13
- names.each(&method(:define_delegator))
14
- end
15
-
16
- # Create delegator to object
17
- #
18
- # @param [Symbol] name
19
- #
20
- # @return [undefined]
21
- def define_delegator(name)
22
- fail "method #{name} already defined" if instance_methods.include?(name)
23
- define_method(name) do
24
- object.public_send(name)
25
- end
26
- private name
27
- end
28
-
29
- end # ClassMethods
30
-
31
- # Hook called when module is included
32
- #
33
- # @param [Class,Module] host
34
- #
35
- # @return [undefined]
36
- def self.included(host)
37
- super
38
-
39
- host.extend(ClassMethods)
40
- end
41
-
42
- end # Delegator
43
- end # Mutant
@@ -1,11 +0,0 @@
1
- RSpec.describe Mutant::Context, '#root' do
2
- subject { object.root }
3
-
4
- let(:object) { described_class.allocate }
5
-
6
- it 'should raise error' do
7
- expect do
8
- subject
9
- end.to raise_error('Mutant::Context#root is not implemented')
10
- end
11
- end
@@ -1,32 +0,0 @@
1
- RSpec.describe Mutant::Context::Scope, '#root' do
2
- subject { object.root(node) }
3
-
4
- let(:object) { described_class.new(TestApp::Literal, path) }
5
- let(:path) { instance_double(Pathname) }
6
- let(:node) { parse(':node') }
7
-
8
- let(:scope) { subject.body }
9
- let(:scope_body) { scope.body }
10
-
11
- let(:expected_source) do
12
- generate(parse(<<-RUBY))
13
- module TestApp
14
- class Literal
15
- :node
16
- end
17
- end
18
- RUBY
19
- end
20
-
21
- let(:generated_source) do
22
- Unparser.unparse(subject)
23
- end
24
-
25
- let(:round_tripped_source) do
26
- Unparser.unparse(parse(expected_source))
27
- end
28
-
29
- it 'should create correct source' do
30
- expect(generated_source).to eql(expected_source)
31
- end
32
- end
@@ -1,25 +0,0 @@
1
- RSpec.describe Mutant::Context::Scope, '#unqualified_name' do
2
- subject { object.unqualified_name }
3
-
4
- let(:path) { instance_double(Pathname) }
5
-
6
- context 'with top level constant name' do
7
- let(:object) { described_class.new(TestApp, path) }
8
-
9
- it 'should return the unqualified name' do
10
- should eql('TestApp')
11
- end
12
-
13
- it_should_behave_like 'an idempotent method'
14
- end
15
-
16
- context 'with scoped constant name' do
17
- let(:object) { described_class.new(TestApp::Literal, path) }
18
-
19
- it 'should return the unqualified name' do
20
- should eql('Literal')
21
- end
22
-
23
- it_should_behave_like 'an idempotent method'
24
- end
25
- end