mutant 0.3.0.beta2 → 0.3.0.beta3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8076c9cdfc1fcf12d08d67b2b57bafdb5c9baff4
4
- data.tar.gz: ab09a106e752bcc776d41ef04b5a77563eee0cf5
3
+ metadata.gz: 99a1dc445a2a8e2fc4485a5fc03b65366c9f00ab
4
+ data.tar.gz: 9bb4ca3b1255de13857a9c142b1d933dec0049ab
5
5
  SHA512:
6
- metadata.gz: a4dc97bbebfc57f572c0c040515403e1d3dd8d87d72c96b8931de25716e9bf9612c56822f65d823227a4f2d461247ab43b5278f5f206726e9146f508d36c05db
7
- data.tar.gz: 67f727d12f7e6ba0c522e0d8de73cc8784648a3fa08dabf63eefb9580b560786b7bcafec6fe9733a708f88f6365bc189fac178f20789b1ec6b0723aa4443035d
6
+ metadata.gz: 89768cb785f9bb73daf81720e688ae824a60b967722577c3048944f46c32b57360aa9e96ac3a48517bc889a8ee59c397248c7b90b0a401c543483e0f8f660f1a
7
+ data.tar.gz: fc7fb6c821a962efa4542513c930adb6b89b96d4811946f62080f0ac79dc1e0361d5d07b5c569a1d6b5fa25e1fa91f9d5ff32833a0fa7fb3bb00c2fe0e43a7c7
data/.travis.yml CHANGED
@@ -11,6 +11,7 @@ matrix:
11
11
  allow_failures:
12
12
  - rvm: jruby-19mode # No fork(2) support, workaround planned
13
13
  - rvm: ruby-head # Broken at this time
14
+ - rvm: rbx-19mode # Broken at this time, yard/yardstick issue
14
15
  notifications:
15
16
  irc:
16
17
  channels:
@@ -12,9 +12,9 @@ module Mutant
12
12
  #
13
13
  # @api private
14
14
  #
15
- def self.each(node, &block)
16
- return to_enum(__method__, node) unless block_given?
17
- Registry.lookup(node).new(node, block)
15
+ def self.each(node, parent=nil, &block)
16
+ return to_enum(__method__, node, parent) unless block_given?
17
+ Registry.lookup(node).new(node, parent, block)
18
18
 
19
19
  self
20
20
  end
@@ -52,19 +52,28 @@ module Mutant
52
52
  #
53
53
  attr_reader :input
54
54
 
55
+ # Return input
56
+ #
57
+ # @return [Object]
58
+ #
59
+ # @api private
60
+ #
61
+ attr_reader :parent
62
+
55
63
  private
56
64
 
57
65
  # Initialize object
58
66
  #
59
67
  # @param [Object] input
68
+ # @param [Object] parent
60
69
  # @param [#call(node)] block
61
70
  #
62
71
  # @return [undefined]
63
72
  #
64
73
  # @api private
65
74
  #
66
- def initialize(input, block)
67
- @input, @block = IceNine.deep_freeze(input), block
75
+ def initialize(input, parent, block)
76
+ @input, @parent, @block = input, parent, block
68
77
  @seen = Set.new
69
78
  guard(input)
70
79
  dispatch
@@ -173,7 +182,7 @@ module Mutant
173
182
  # @api private
174
183
  #
175
184
  def run(mutator)
176
- mutator.new(input, method(:emit))
185
+ mutator.new(input, self, method(:emit))
177
186
  end
178
187
 
179
188
  # Shortcut to create a new unfrozen duplicate of input
@@ -99,7 +99,7 @@ module Mutant
99
99
  # @api private
100
100
  #
101
101
  def emit_children_mutations
102
- Mutator::Util::Array.each(children) do |children|
102
+ Mutator::Util::Array.each(children, self) do |children|
103
103
  emit_self(*children)
104
104
  end
105
105
  end
@@ -125,7 +125,7 @@ module Mutant
125
125
  def mutate_child(index, mutator = Mutator)
126
126
  children = node.children
127
127
  child = children[index]
128
- mutator.each(child) do |mutation|
128
+ mutator.each(child, self) do |mutation|
129
129
  emit_child_update(index, mutation)
130
130
  end
131
131
  end
@@ -30,7 +30,7 @@ module Mutant
30
30
  # @api private
31
31
  #
32
32
  def emit_name_mutation
33
- Mutator::Util::Symbol.each(name) do |name|
33
+ Mutator::Util::Symbol.each(name, self) do |name|
34
34
  emit_name(name)
35
35
  end
36
36
  end
@@ -39,7 +39,7 @@ module Mutant
39
39
  #
40
40
  def mutate_name
41
41
  prefix = MAP.fetch(node.type)
42
- Mutator::Util::Symbol.each(name) do |name|
42
+ Mutator::Util::Symbol.each(name, self) do |name|
43
43
  emit_name("#{prefix}#{name}")
44
44
  end
45
45
  end
@@ -16,7 +16,7 @@ module Mutant
16
16
  # @api private
17
17
  #
18
18
  def dispatch
19
- Util::Array.each(children) do |children|
19
+ Util::Array.each(children, self) do |children|
20
20
  if children.length > 1
21
21
  emit_self(*children)
22
22
  end
@@ -24,7 +24,21 @@ module Mutant
24
24
  children.each do |child|
25
25
  emit(child)
26
26
  end
27
- emit(nil)
27
+ emit(nil) unless parent_send?
28
+ end
29
+
30
+ # Test if parent input is a send
31
+ #
32
+ # @return [true]
33
+ # if parent input is a send node
34
+ #
35
+ # @return [false]
36
+ # otherwise
37
+ #
38
+ # @api private
39
+ #
40
+ def parent_send?
41
+ parent && parent.input.type == :send
28
42
  end
29
43
 
30
44
  end # Block
@@ -6,6 +6,7 @@ module Mutant
6
6
  # Run ulitity mutator
7
7
  #
8
8
  # @param [Object] object
9
+ # @param [Object] parent
9
10
  #
10
11
  # @return [Enumerator<Object>]
11
12
  # if no block given
@@ -15,10 +16,10 @@ module Mutant
15
16
  #
16
17
  # @api private
17
18
  #
18
- def self.each(object, &block)
19
- return to_enum(__method__, object) unless block_given?
19
+ def self.each(object, parent, &block)
20
+ return to_enum(__method__, object, parent) unless block_given?
20
21
 
21
- new(object, block)
22
+ new(object, parent, block)
22
23
 
23
24
  self
24
25
  end
data/mutant.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'mutant'
5
- gem.version = '0.3.0.beta2'
5
+ gem.version = '0.3.0.beta3'
6
6
  gem.authors = [ 'Markus Schirp' ]
7
7
  gem.email = [ 'mbj@schirp-dso.com' ]
8
8
 
@@ -15,9 +15,10 @@ describe Mutant::Mutator, '#emit_new' do
15
15
  end
16
16
  end
17
17
 
18
- let(:object) { class_under_test.new(input, block) }
19
- let(:block) { Block.new }
20
- let(:input) { :input }
18
+ let(:object) { class_under_test.new(input, parent, block) }
19
+ let(:block) { Block.new }
20
+ let(:input) { :input }
21
+ let(:parent) { :parent }
21
22
 
22
23
  let(:class_under_test) do
23
24
  Class.new(described_class) do
@@ -15,9 +15,10 @@ describe Mutant::Mutator, '#emit' do
15
15
  end
16
16
  end
17
17
 
18
- let(:object) { class_under_test.new(input, block) }
19
- let(:block) { Block.new }
20
- let(:input) { :nput }
18
+ let(:object) { class_under_test.new(input, parent, block) }
19
+ let(:block) { Block.new }
20
+ let(:input) { :input }
21
+ let(:parent) { :parent }
21
22
 
22
23
  let(:class_under_test) do
23
24
  Class.new(described_class) do
@@ -168,6 +168,18 @@ describe Mutant::Mutator, 'send' do
168
168
  end
169
169
 
170
170
  context 'binary operator methods' do
171
+ context 'nested' do
172
+ let(:source) { '(left - right) / foo' }
173
+
174
+ let(:mutations) do
175
+ mutations = []
176
+ mutations << 'foo'
177
+ mutations << 'left - right'
178
+ end
179
+
180
+ it_should_behave_like 'a mutator'
181
+ end
182
+
171
183
  Mutant::BINARY_METHOD_OPERATORS.each do |operator|
172
184
  context 'on literal scalar arguments' do
173
185
  let(:source) { "true #{operator} false" }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mutant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.beta2
4
+ version: 0.3.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp