mutiny 0.2.5 → 0.2.6
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 +4 -4
- data/Gemfile.lock +1 -1
- data/RELEASES.md +3 -0
- data/lib/mutiny/mutants/mutant/location.rb +6 -4
- data/lib/mutiny/mutants/mutation_set.rb +10 -4
- data/lib/mutiny/mutants/storage/mutant_file_contents.rb +9 -3
- data/lib/mutiny/version.rb +1 -1
- data/spec/unit/mutants/mutant/location_spec.rb +4 -4
- data/spec/unit/mutants/storage/mutant_file_contents_spec.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82f8ce8c2e31d5a113f71eb05cae910a1e0942ae
|
4
|
+
data.tar.gz: 2f39cf42e45814019566e7729fc12cc76c74c812
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4161257ca1df94e4ff122a14261affb7dcf9637d1e9b6e96de9be70c39b1f7d6563a58acce9e083732d3ac6af9f6f3013e148cf1acbcb27f95467cc043a24899
|
7
|
+
data.tar.gz: 0029e46e1070c21440256a86e75e3db603e160ff741d910075d405a601d42d7f8e3c374bf8d6cc07407c1002bf0113e80bc0b9662fde45a13b38293a2b73d358
|
data/Gemfile.lock
CHANGED
data/RELEASES.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
## v0.2.6 (17 February 2016)
|
4
|
+
* A mutant's position now carries information about the affected range in the subject, as well as in the mutated code.
|
5
|
+
|
3
6
|
## v0.2.5 (16 February 2016)
|
4
7
|
* Fix bug in the --cached switch of the score command, which was preventing mutants being correctly loaded from disk on Linux.
|
5
8
|
* Fix bug in the --cached switch of the score command, which was causing mutiny to report the incorrect path to subject files.
|
@@ -2,17 +2,19 @@ module Mutiny
|
|
2
2
|
module Mutants
|
3
3
|
class Mutant
|
4
4
|
class Location
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :old_position, :new_position, :content
|
6
6
|
|
7
7
|
def initialize(position:, content:)
|
8
|
-
|
8
|
+
position ||= {}
|
9
|
+
@old_position = position[:old].freeze
|
10
|
+
@new_position = position[:new].freeze
|
9
11
|
@content = content
|
10
12
|
end
|
11
13
|
|
12
14
|
def lines
|
13
15
|
Range.new(
|
14
|
-
line_number_of_offset(
|
15
|
-
line_number_of_offset(
|
16
|
+
line_number_of_offset(new_position.begin),
|
17
|
+
line_number_of_offset(new_position.end)
|
16
18
|
)
|
17
19
|
end
|
18
20
|
|
@@ -38,10 +38,7 @@ module Mutiny
|
|
38
38
|
positions = []
|
39
39
|
|
40
40
|
code = mutation.mutate_file(path) do |change|
|
41
|
-
|
42
|
-
ending_position = change.original_position.begin + change.transformed_code.size - 1
|
43
|
-
|
44
|
-
positions << (starting_position..ending_position)
|
41
|
+
positions << extract_position(change)
|
45
42
|
end
|
46
43
|
|
47
44
|
code.zip(positions)
|
@@ -49,6 +46,15 @@ module Mutiny
|
|
49
46
|
msg = "Error encountered whilst mutating file at '#{path}' with #{mutation.name}"
|
50
47
|
raise Mutation::Error, msg
|
51
48
|
end
|
49
|
+
|
50
|
+
def extract_position(change)
|
51
|
+
old_start = change.original_position.begin
|
52
|
+
old_end = change.original_position.end
|
53
|
+
new_start = change.original_position.begin
|
54
|
+
new_end = change.original_position.begin + change.transformed_code.size - 1
|
55
|
+
|
56
|
+
{ old: old_start..old_end, new: new_start..new_end }
|
57
|
+
end
|
52
58
|
end
|
53
59
|
end
|
54
60
|
end
|
@@ -2,10 +2,12 @@ module Mutiny
|
|
2
2
|
module Mutants
|
3
3
|
class Storage
|
4
4
|
class MutantFileContents
|
5
|
+
# rubocop:disable Metrics/AbcSize
|
5
6
|
def serialise(mutant)
|
6
7
|
"# " + mutant.subject.name + "\n" \
|
7
8
|
"# " + mutant.mutation_name + "\n" \
|
8
|
-
"# " + mutant.location.
|
9
|
+
"# " + mutant.location.old_position.to_s + "\n" \
|
10
|
+
"# " + mutant.location.new_position.to_s + "\n" +
|
9
11
|
mutant.code
|
10
12
|
end
|
11
13
|
|
@@ -13,10 +15,14 @@ module Mutiny
|
|
13
15
|
{
|
14
16
|
subject: { name: extract_contents_of_comment(contents.lines[0]) },
|
15
17
|
mutation_name: extract_contents_of_comment(contents.lines[1]),
|
16
|
-
position:
|
17
|
-
|
18
|
+
position: {
|
19
|
+
old: convert_to_range(extract_contents_of_comment(contents.lines[2])),
|
20
|
+
new: convert_to_range(extract_contents_of_comment(contents.lines[3]))
|
21
|
+
},
|
22
|
+
code: contents.lines.drop(4).join
|
18
23
|
}
|
19
24
|
end
|
25
|
+
# rubocop:enable Metrics/AbcSize
|
20
26
|
|
21
27
|
private
|
22
28
|
|
data/lib/mutiny/version.rb
CHANGED
@@ -4,15 +4,15 @@ module Mutiny
|
|
4
4
|
describe Location do
|
5
5
|
context "calculates lines" do
|
6
6
|
it "correctly for a multi-line location" do
|
7
|
-
#
|
8
|
-
#
|
9
|
-
location = Location.new(position: 3..
|
7
|
+
# 0 1
|
8
|
+
# 01234567 890123 4567
|
9
|
+
location = Location.new(position: { new: 3..13 }, content: "if BOMB\n fail\nend")
|
10
10
|
|
11
11
|
expect(location.lines).to eq(1..2)
|
12
12
|
end
|
13
13
|
|
14
14
|
it "correctly for a single-line location" do
|
15
|
-
location = Location.new(position: 2..4, content: "a <= b\nb <= c")
|
15
|
+
location = Location.new(position: { new: 2..4 }, content: "a <= b\nb <= c")
|
16
16
|
|
17
17
|
expect(location.lines).to eq(1..1)
|
18
18
|
end
|
@@ -16,7 +16,7 @@ module Mutiny
|
|
16
16
|
code: "2 - 2",
|
17
17
|
index: 0,
|
18
18
|
mutation_name: "BAOR",
|
19
|
-
position: 2..3
|
19
|
+
position: { old: 2..3, new: 3..5 }
|
20
20
|
)
|
21
21
|
end
|
22
22
|
|
@@ -32,6 +32,7 @@ module Mutiny
|
|
32
32
|
"# Two\n" \
|
33
33
|
"# BAOR\n" \
|
34
34
|
"# 2..3\n" \
|
35
|
+
"# 3..5\n" \
|
35
36
|
"2 - 2"
|
36
37
|
end
|
37
38
|
|
@@ -40,7 +41,7 @@ module Mutiny
|
|
40
41
|
subject: { name: "Two" },
|
41
42
|
mutation_name: "BAOR",
|
42
43
|
code: "2 - 2",
|
43
|
-
position: 2..3
|
44
|
+
position: { old: 2..3, new: 3..5 }
|
44
45
|
}
|
45
46
|
end
|
46
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mutiny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Louis Rose
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|