mutant 0.5.6 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +6 -0
- data/lib/mutant.rb +1 -0
- data/lib/mutant/loader.rb +5 -18
- data/lib/mutant/mutator/node/generic.rb +1 -3
- data/lib/mutant/mutator/node/resbody.rb +0 -2
- data/lib/mutant/mutator/node/rescue.rb +26 -0
- data/lib/mutant/subject.rb +10 -0
- data/lib/mutant/subject/method/instance.rb +11 -0
- data/lib/mutant/subject/method/singleton.rb +11 -0
- data/lib/mutant/version.rb +1 -1
- data/spec/unit/mutant/loader/eval_spec.rb +4 -0
- data/spec/unit/mutant/mutator/node/define_spec.rb +13 -0
- data/spec/unit/mutant/subject/method/instance_spec.rb +22 -0
- data/spec/unit/mutant/subject/method/singleton_spec.rb +42 -0
- data/test_app/Gemfile.rspec2 +3 -2
- data/test_app/Gemfile.rspec3 +2 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ed226d5dffa5ae1f7427abfa3d0906c4795aeb9
|
4
|
+
data.tar.gz: 683e7fb70196af33a3fa62bd208c1944f59c33c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 484d060c5dbeeb7287a91d8e85d5146d628fface21960803e77d3a5d36d3eae5dfedcb2abd83dab0c5d926fde2cd1d5637bc3b4a0cbacb61c384d58a034b5095
|
7
|
+
data.tar.gz: 1aa578d23500f3be6ac4f885c4ef0dfeaa29047df8a869a158de38da36eef9728c3e1fe6b319a5bdffa3e97a71e1f93eb0904815b2c8e6bf6639f1018374f451
|
data/Changelog.md
CHANGED
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
|
-
|
36
|
-
|
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(
|
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,
|
@@ -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
|
data/lib/mutant/subject.rb
CHANGED
@@ -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
|
data/lib/mutant/version.rb
CHANGED
@@ -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
|
data/test_app/Gemfile.rspec2
CHANGED
data/test_app/Gemfile.rspec3
CHANGED
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.
|
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-
|
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.
|
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
|