mutant 0.5.6 → 0.5.7

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: 54ae8c3475a320f0414ab619b85fbb4bb2965471
4
- data.tar.gz: 8d7fb1c5f84d6da82c4ea00ef4bae0f08c1b4354
3
+ metadata.gz: 6ed226d5dffa5ae1f7427abfa3d0906c4795aeb9
4
+ data.tar.gz: 683e7fb70196af33a3fa62bd208c1944f59c33c0
5
5
  SHA512:
6
- metadata.gz: becb5fa79ed00c804b3b04f3f4cdffb99bfe0c9fc206ec8fb1e6b4f4ba9acc16eee2cd7363e9d5e23e0f03663870c5482e3682fe6d9eac29ba020725e5936ecd
7
- data.tar.gz: ed0f26b5694e3b909c0de51db291c66149415dbadc6834f1bcdeef1e48a9c39acdd16233c5edf76c436433c9bc49baf3698fbab0a1c317c9df6d065ac18fff9a
6
+ metadata.gz: 484d060c5dbeeb7287a91d8e85d5146d628fface21960803e77d3a5d36d3eae5dfedcb2abd83dab0c5d926fde2cd1d5637bc3b4a0cbacb61c384d58a034b5095
7
+ data.tar.gz: 1aa578d23500f3be6ac4f885c4ef0dfeaa29047df8a869a158de38da36eef9728c3e1fe6b319a5bdffa3e97a71e1f93eb0904815b2c8e6bf6639f1018374f451
data/Changelog.md CHANGED
@@ -1,3 +1,9 @@
1
+ # v0.5.7 2014-03-23
2
+
3
+ Changes:
4
+
5
+ * Fix crash on invalid partial AST unparsing, closes: #164
6
+
1
7
  # v0.5.6 2014-03-09
2
8
 
3
9
  Changes:
data/lib/mutant.rb CHANGED
@@ -87,6 +87,7 @@ require 'mutant/mutator/node/if'
87
87
  require 'mutant/mutator/node/case'
88
88
  require 'mutant/mutator/node/splat'
89
89
  require 'mutant/mutator/node/resbody'
90
+ require 'mutant/mutator/node/rescue'
90
91
  require 'mutant/config'
91
92
  require 'mutant/loader'
92
93
  require 'mutant/context'
data/lib/mutant/loader.rb CHANGED
@@ -3,21 +3,7 @@
3
3
  module Mutant
4
4
  # Base class for code loaders
5
5
  class Loader
6
- include AbstractType
7
- include Procto.call
8
-
9
- # Initialize and insert mutation into vm
10
- #
11
- # @param [Parser::AST::Node] root
12
- # @param [Subject] subject
13
- #
14
- # @return [undefined]
15
- #
16
- # @api private
17
- #
18
- def initialize(root, subject)
19
- @root, @subject = root, subject
20
- end
6
+ include AbstractType, Concord.new(:root, :subject), Procto.call
21
7
 
22
8
  # Eval based loader
23
9
  class Eval < self
@@ -29,11 +15,12 @@ module Mutant
29
15
  # @api private
30
16
  #
31
17
  def call
18
+ subject.prepare
32
19
  eval(
33
20
  source,
34
21
  TOPLEVEL_BINDING,
35
- @subject.source_path.to_s,
36
- @subject.source_line
22
+ subject.source_path.to_s,
23
+ subject.source_line
37
24
  )
38
25
  nil
39
26
  end
@@ -47,7 +34,7 @@ module Mutant
47
34
  # @api private
48
35
  #
49
36
  def source
50
- Unparser.unparse(@root)
37
+ Unparser.unparse(root)
51
38
  end
52
39
 
53
40
  end # Eval
@@ -10,9 +10,7 @@ module Mutant
10
10
  # These nodes still need a dedicated mutator,
11
11
  # your contribution is that close!
12
12
  handle(
13
- :ensure,
14
- :rescue, :redo, :defined?,
15
- :regopt, :retry, :arg_expr,
13
+ :ensure, :redo, :defined?, :regopt, :retry, :arg_expr,
16
14
  :kwrestarg, :kwoptarg, :kwarg, :undef, :module, :empty,
17
15
  :alias, :for, :xstr, :back_ref, :class,
18
16
  :sclass, :match_with_lvasgn, :match_current_line, :while_post,
@@ -36,8 +36,6 @@ module Mutant
36
36
  Util::Array.each(captures.children, self) do |matchers|
37
37
  next if matchers.empty?
38
38
  emit_captures(s(:array, *matchers))
39
- # p capture
40
- # emit_captures(s(:array, *capture))
41
39
  end
42
40
  end
43
41
 
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ module Mutant
4
+ class Mutator
5
+ class Node
6
+ # Mutator for rescue nodes
7
+ class Rescue < Generic
8
+
9
+ handle :rescue
10
+
11
+ # Return identity
12
+ #
13
+ # @param [Parser::AST::Node] node
14
+ #
15
+ # @return [String]
16
+ #
17
+ # @api private
18
+ #
19
+ def self.identity(node)
20
+ super(NodeHelpers.s(:kwbegin, node))
21
+ end
22
+
23
+ end # Rescue
24
+ end # Node
25
+ end # Mutator
26
+ end # Mutant
@@ -29,6 +29,16 @@ module Mutant
29
29
  context.source_path
30
30
  end
31
31
 
32
+ # Prepare the subject for the insertion of mutation
33
+ #
34
+ # @return [self]
35
+ #
36
+ # @api private
37
+ #
38
+ def prepare
39
+ self
40
+ end
41
+
32
42
  # Return source line
33
43
  #
34
44
  # @return [Fixnum]
@@ -24,6 +24,17 @@ module Mutant
24
24
  end
25
25
  memoize :public?
26
26
 
27
+ # Prepare subject for mutation insertion
28
+ #
29
+ # @return [self]
30
+ #
31
+ # @api private
32
+ #
33
+ def prepare
34
+ scope.send(:undef_method, name)
35
+ self
36
+ end
37
+
27
38
  private
28
39
 
29
40
  # Mutator for memoized instance methods
@@ -24,6 +24,17 @@ module Mutant
24
24
  end
25
25
  memoize :public?
26
26
 
27
+ # Prepare subject for mutation insertion
28
+ #
29
+ # @return [self]
30
+ #
31
+ # @api private
32
+ #
33
+ def prepare
34
+ scope.singleton_class.send(:undef_method, name)
35
+ self
36
+ end
37
+
27
38
  end # Singleton
28
39
  end # Method
29
40
  end # Subject
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Mutant
4
4
  # The current mutant version
5
- VERSION = '0.5.6'.freeze
5
+ VERSION = '0.5.7'.freeze
6
6
  end # Mutant
@@ -14,6 +14,10 @@ describe Mutant::Loader::Eval, '.call' do
14
14
  double('Subject', source_path: path, source_line: line)
15
15
  end
16
16
 
17
+ before do
18
+ expect(mutation_subject).to receive(:prepare).and_return(mutation_subject)
19
+ end
20
+
17
21
  let(:source) do
18
22
  <<-RUBY
19
23
  class SomeNamespace
@@ -14,6 +14,19 @@ describe Mutant::Mutator, 'def' do
14
14
  it_should_behave_like 'a mutator'
15
15
  end
16
16
 
17
+ context 'empty rescue body' do
18
+ let(:source) { "def foo\nfoo\nrescue\nend" }
19
+
20
+ let(:mutations) do
21
+ mutations = []
22
+ mutations << 'def foo; raise; end'
23
+ mutations << 'def foo; nil; rescue; end'
24
+ mutations << 'def foo; end'
25
+ end
26
+
27
+ it_should_behave_like 'a mutator'
28
+ end
29
+
17
30
  context 'with no arguments' do
18
31
  let(:source) { 'def foo; true; false; end' }
19
32
 
@@ -12,6 +12,28 @@ describe Mutant::Subject::Method::Instance do
12
12
  s(:def, :foo, s(:args))
13
13
  end
14
14
 
15
+ describe '#prepare' do
16
+
17
+ let(:context) do
18
+ Mutant::Context::Scope.new(scope, double('Source Path'))
19
+ end
20
+
21
+ let(:scope) do
22
+ Class.new do
23
+ def foo
24
+ end
25
+ end
26
+ end
27
+
28
+ subject { object.prepare }
29
+
30
+ it 'undefines method on scope' do
31
+ expect { subject }.to change { scope.instance_methods.include?(:foo) }.from(true).to(false)
32
+ end
33
+
34
+ it_should_behave_like 'a command method'
35
+ end
36
+
15
37
  describe '#source' do
16
38
  subject { object.source }
17
39
 
@@ -0,0 +1,42 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Mutant::Subject::Method::Singleton do
6
+ include Mutant::NodeHelpers
7
+
8
+ let(:object) { described_class.new(context, node) }
9
+ let(:context) { double }
10
+
11
+ let(:node) do
12
+ s(:defs, s(:self), :foo, s(:args))
13
+ end
14
+
15
+ describe '#prepare' do
16
+
17
+ let(:context) do
18
+ Mutant::Context::Scope.new(scope, double('Source Path'))
19
+ end
20
+
21
+ let(:scope) do
22
+ Class.new do
23
+ def self.foo
24
+ end
25
+ end
26
+ end
27
+
28
+ subject { object.prepare }
29
+
30
+ it 'undefines method on scope' do
31
+ expect { subject }.to change { scope.methods.include?(:foo) }.from(true).to(false)
32
+ end
33
+
34
+ it_should_behave_like 'a command method'
35
+ end
36
+
37
+ describe '#source' do
38
+ subject { object.source }
39
+
40
+ it { should eql("def self.foo\nend") }
41
+ end
42
+ end
@@ -1,4 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rspec', '~> 2.14.1'
4
- gem 'mutant', path: '../'
3
+ gem 'rspec', '~> 2.14.1'
4
+ gem 'mutant', path: '../'
5
+ gem 'mutant-rspec', path: '../'
@@ -1,3 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
  gem 'rspec', '~> 3.0.0.beta2'
3
- gem 'mutant', path: '../'
3
+ gem 'mutant', path: '../'
4
+ gem 'mutant-rspec', path: '../'
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.6
4
+ version: 0.5.7
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-03-12 00:00:00.000000000 Z
11
+ date: 2014-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -315,6 +315,7 @@ files:
315
315
  - lib/mutant/mutator/node/nthref.rb
316
316
  - lib/mutant/mutator/node/op_asgn.rb
317
317
  - lib/mutant/mutator/node/resbody.rb
318
+ - lib/mutant/mutator/node/rescue.rb
318
319
  - lib/mutant/mutator/node/restarg.rb
319
320
  - lib/mutant/mutator/node/return.rb
320
321
  - lib/mutant/mutator/node/send.rb
@@ -435,6 +436,7 @@ files:
435
436
  - spec/unit/mutant/strategy_spec.rb
436
437
  - spec/unit/mutant/subject/context_spec.rb
437
438
  - spec/unit/mutant/subject/method/instance_spec.rb
439
+ - spec/unit/mutant/subject/method/singleton_spec.rb
438
440
  - spec/unit/mutant/subject/mutations_spec.rb
439
441
  - spec/unit/mutant/subject/node_spec.rb
440
442
  - spec/unit/mutant/subject_spec.rb
@@ -475,7 +477,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
475
477
  version: '0'
476
478
  requirements: []
477
479
  rubyforge_project:
478
- rubygems_version: 2.2.0
480
+ rubygems_version: 2.2.2
479
481
  signing_key:
480
482
  specification_version: 4
481
483
  summary: Mutation testing tool for ruby under MRI and Rubinius
@@ -554,6 +556,7 @@ test_files:
554
556
  - spec/unit/mutant/strategy_spec.rb
555
557
  - spec/unit/mutant/subject/context_spec.rb
556
558
  - spec/unit/mutant/subject/method/instance_spec.rb
559
+ - spec/unit/mutant/subject/method/singleton_spec.rb
557
560
  - spec/unit/mutant/subject/mutations_spec.rb
558
561
  - spec/unit/mutant/subject/node_spec.rb
559
562
  - spec/unit/mutant/subject_spec.rb