mutant 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
data/lib/mutant/literal.rb
CHANGED
@@ -114,6 +114,19 @@ module Mutant
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
+
class InstanceVariableAssignment < BaseLiteral
|
118
|
+
def swap
|
119
|
+
@node.value = literal_class.new(@node.value.clone).swap
|
120
|
+
@node
|
121
|
+
end
|
122
|
+
|
123
|
+
private
|
124
|
+
|
125
|
+
def literal_class
|
126
|
+
Module.nesting[1].literal_class(@node.value)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
117
130
|
class If < BaseLiteral
|
118
131
|
def swap
|
119
132
|
@node.body, @node.else = @node.else, @node.body
|
data/lib/mutant/version.rb
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Mutating instance variable assignments' do
|
4
|
+
context 'for an instance method' do
|
5
|
+
context 'that contains @a = 1' do
|
6
|
+
before do
|
7
|
+
write_file 'thing.rb', """
|
8
|
+
class Thing
|
9
|
+
attr_reader :a
|
10
|
+
def set_a
|
11
|
+
@a = 1
|
12
|
+
end
|
13
|
+
end
|
14
|
+
"""
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'with an expectation that a will be set to 1' do
|
18
|
+
before do
|
19
|
+
write_file 'spec/thing_spec.rb', """
|
20
|
+
$: << '.'
|
21
|
+
require 'thing'
|
22
|
+
|
23
|
+
describe 'Thing#set_a' do
|
24
|
+
specify do
|
25
|
+
thing = Thing.new
|
26
|
+
thing.set_a
|
27
|
+
thing.a.should eq(1)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
"""
|
31
|
+
mutate 'Thing#set_a spec/thing_spec.rb'
|
32
|
+
end
|
33
|
+
|
34
|
+
specify 'the mutation passes' do
|
35
|
+
all_output.should include('passed')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'with an expectation that a will bet set to some number' do
|
40
|
+
before do
|
41
|
+
write_file 'spec/thing_spec.rb', """
|
42
|
+
$: << '.'
|
43
|
+
require 'thing'
|
44
|
+
|
45
|
+
describe 'Thing#set_a' do
|
46
|
+
specify do
|
47
|
+
thing = Thing.new
|
48
|
+
thing.set_a
|
49
|
+
thing.a.should be_kind_of(Fixnum)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
"""
|
53
|
+
mutate 'Thing#set_a spec/thing_spec.rb'
|
54
|
+
end
|
55
|
+
|
56
|
+
specify 'the mutation fails' do
|
57
|
+
all_output.should include('failed')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Mutating instance variable assignments' do
|
4
|
+
context 'for an instance method' do
|
5
|
+
context 'that contains @a = 1' do
|
6
|
+
before do
|
7
|
+
write_file 'thing.rb', """
|
8
|
+
class Thing
|
9
|
+
class << self; attr_reader :a; end
|
10
|
+
def self.set_a
|
11
|
+
@a = 1
|
12
|
+
end
|
13
|
+
end
|
14
|
+
"""
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'with an expectation that a will be set to 1' do
|
18
|
+
before do
|
19
|
+
write_file 'spec/thing_spec.rb', """
|
20
|
+
$: << '.'
|
21
|
+
require 'thing'
|
22
|
+
|
23
|
+
describe 'Thing.set_a' do
|
24
|
+
specify do
|
25
|
+
Thing.set_a
|
26
|
+
Thing.a.should eq(1)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
"""
|
30
|
+
mutate 'Thing.set_a spec/thing_spec.rb'
|
31
|
+
end
|
32
|
+
|
33
|
+
specify 'the mutation passes' do
|
34
|
+
all_output.should include('passed')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'with an expectation that a will bet set to some number' do
|
39
|
+
before do
|
40
|
+
write_file 'spec/thing_spec.rb', """
|
41
|
+
$: << '.'
|
42
|
+
require 'thing'
|
43
|
+
|
44
|
+
describe 'Thing.set_a' do
|
45
|
+
specify do
|
46
|
+
Thing.set_a
|
47
|
+
Thing.a.should be_kind_of(Fixnum)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
"""
|
51
|
+
mutate 'Thing.set_a spec/thing_spec.rb'
|
52
|
+
end
|
53
|
+
|
54
|
+
specify 'the mutation fails' do
|
55
|
+
all_output.should include('failed')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: mutant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Justin Ko
|
@@ -10,50 +10,50 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-02-
|
13
|
+
date: 2012-02-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
version_requirements: &
|
16
|
+
version_requirements: &7400 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '0'
|
22
22
|
prerelease: false
|
23
|
-
requirement: *
|
23
|
+
requirement: *7400
|
24
24
|
name: to_source
|
25
25
|
type: :runtime
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
|
-
version_requirements: &
|
27
|
+
version_requirements: &7464 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '0'
|
33
33
|
prerelease: false
|
34
|
-
requirement: *
|
34
|
+
requirement: *7464
|
35
35
|
name: rake
|
36
36
|
type: :development
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
version_requirements: &
|
38
|
+
version_requirements: &7508 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '2.7'
|
44
44
|
prerelease: false
|
45
|
-
requirement: *
|
45
|
+
requirement: *7508
|
46
46
|
name: rspec
|
47
47
|
type: :development
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
|
-
version_requirements: &
|
49
|
+
version_requirements: &7552 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
prerelease: false
|
56
|
-
requirement: *
|
56
|
+
requirement: *7552
|
57
57
|
name: aruba
|
58
58
|
type: :development
|
59
59
|
description: Mutation tester
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- spec/functional/instance_method/float_spec.rb
|
97
97
|
- spec/functional/instance_method/hash_spec.rb
|
98
98
|
- spec/functional/instance_method/if_spec.rb
|
99
|
+
- spec/functional/instance_method/ivar_assign_spec.rb
|
99
100
|
- spec/functional/instance_method/range_spec.rb
|
100
101
|
- spec/functional/instance_method/regex_spec.rb
|
101
102
|
- spec/functional/instance_method/string_spec.rb
|
@@ -110,6 +111,7 @@ files:
|
|
110
111
|
- spec/functional/singleton_method/float_spec.rb
|
111
112
|
- spec/functional/singleton_method/hash_spec.rb
|
112
113
|
- spec/functional/singleton_method/if_spec.rb
|
114
|
+
- spec/functional/singleton_method/ivar_assign_spec.rb
|
113
115
|
- spec/functional/singleton_method/range_spec.rb
|
114
116
|
- spec/functional/singleton_method/regex_spec.rb
|
115
117
|
- spec/functional/singleton_method/string_spec.rb
|
@@ -158,6 +160,7 @@ test_files:
|
|
158
160
|
- spec/functional/instance_method/float_spec.rb
|
159
161
|
- spec/functional/instance_method/hash_spec.rb
|
160
162
|
- spec/functional/instance_method/if_spec.rb
|
163
|
+
- spec/functional/instance_method/ivar_assign_spec.rb
|
161
164
|
- spec/functional/instance_method/range_spec.rb
|
162
165
|
- spec/functional/instance_method/regex_spec.rb
|
163
166
|
- spec/functional/instance_method/string_spec.rb
|
@@ -172,6 +175,7 @@ test_files:
|
|
172
175
|
- spec/functional/singleton_method/float_spec.rb
|
173
176
|
- spec/functional/singleton_method/hash_spec.rb
|
174
177
|
- spec/functional/singleton_method/if_spec.rb
|
178
|
+
- spec/functional/singleton_method/ivar_assign_spec.rb
|
175
179
|
- spec/functional/singleton_method/range_spec.rb
|
176
180
|
- spec/functional/singleton_method/regex_spec.rb
|
177
181
|
- spec/functional/singleton_method/string_spec.rb
|