diff-lcs 1.2.2 → 1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +0 -1
- data/Code-of-Conduct.md +74 -0
- data/Contributing.md +84 -0
- data/History.md +247 -0
- data/{License.rdoc → License.md} +0 -0
- data/Manifest.txt +15 -9
- data/README.rdoc +21 -18
- data/Rakefile +35 -23
- data/autotest/discover.rb +3 -1
- data/bin/htmldiff +7 -4
- data/bin/ldiff +4 -1
- data/lib/diff-lcs.rb +1 -1
- data/lib/diff/lcs.rb +181 -254
- data/lib/diff/lcs/array.rb +1 -1
- data/lib/diff/lcs/backports.rb +9 -0
- data/lib/diff/lcs/block.rb +1 -1
- data/lib/diff/lcs/callbacks.rb +15 -12
- data/lib/diff/lcs/change.rb +34 -37
- data/lib/diff/lcs/htmldiff.rb +17 -16
- data/lib/diff/lcs/hunk.rb +59 -47
- data/lib/diff/lcs/internals.rb +44 -40
- data/lib/diff/lcs/ldiff.rb +45 -65
- data/lib/diff/lcs/string.rb +1 -1
- data/spec/change_spec.rb +31 -7
- data/spec/diff_spec.rb +28 -18
- data/spec/fixtures/aX +1 -0
- data/spec/fixtures/bXaX +1 -0
- data/spec/fixtures/ds1.csv +50 -0
- data/spec/fixtures/ds2.csv +51 -0
- data/spec/fixtures/ldiff/output.diff +4 -0
- data/spec/fixtures/ldiff/output.diff-c +7 -0
- data/spec/fixtures/ldiff/output.diff-e +3 -0
- data/spec/fixtures/ldiff/output.diff-f +3 -0
- data/spec/fixtures/ldiff/output.diff-u +5 -0
- data/spec/hunk_spec.rb +54 -45
- data/spec/issues_spec.rb +50 -17
- data/spec/lcs_spec.rb +24 -22
- data/spec/ldiff_spec.rb +72 -0
- data/spec/patch_spec.rb +182 -180
- data/spec/sdiff_spec.rb +99 -87
- data/spec/spec_helper.rb +141 -58
- data/spec/traverse_balanced_spec.rb +177 -177
- data/spec/traverse_sequences_spec.rb +63 -63
- metadata +100 -169
- data.tar.gz.sig +0 -0
- data/.autotest +0 -3
- data/.gemtest +0 -0
- data/.hoerc +0 -2
- data/.travis.yml +0 -22
- data/Contributing.rdoc +0 -64
- data/Gemfile +0 -19
- data/History.rdoc +0 -117
- data/diff-lcs.gemspec +0 -63
- metadata.gz.sig +0 -4
data/spec/sdiff_spec.rb
CHANGED
@@ -1,202 +1,214 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe 'Diff::LCS.sdiff' do
|
6
6
|
include Diff::LCS::SpecHelper::Matchers
|
7
7
|
|
8
|
-
shared_examples
|
9
|
-
it
|
10
|
-
Diff::LCS.sdiff(s1, s2).
|
8
|
+
shared_examples 'compare sequences correctly' do
|
9
|
+
it 'compares s1 -> s2 correctly' do
|
10
|
+
expect(Diff::LCS.sdiff(s1, s2)).to eq(context_diff(result))
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
14
|
-
Diff::LCS.sdiff(s2, s1).
|
13
|
+
it 'compares s2 -> s1 correctly' do
|
14
|
+
expect(Diff::LCS.sdiff(s2, s1)).to eq(context_diff(reverse_sdiff(result)))
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
describe
|
18
|
+
describe 'using seq1 & seq2' do
|
19
19
|
let(:s1) { seq1 }
|
20
20
|
let(:s2) { seq2 }
|
21
21
|
let(:result) { correct_forward_sdiff }
|
22
22
|
|
23
|
-
it_has_behavior
|
23
|
+
it_has_behavior 'compare sequences correctly'
|
24
24
|
end
|
25
25
|
|
26
|
-
describe
|
26
|
+
describe 'using %w(abc def yyy xxx ghi jkl) & %w(abc dxf xxx ghi jkl)' do
|
27
27
|
let(:s1) { %w(abc def yyy xxx ghi jkl) }
|
28
28
|
let(:s2) { %w(abc dxf xxx ghi jkl) }
|
29
29
|
let(:result) {
|
30
30
|
[
|
31
|
-
[
|
32
|
-
[
|
33
|
-
[
|
34
|
-
[
|
35
|
-
[
|
36
|
-
[
|
31
|
+
['=', [0, 'abc'], [0, 'abc']],
|
32
|
+
['!', [1, 'def'], [1, 'dxf']],
|
33
|
+
['-', [2, 'yyy'], [2, nil]],
|
34
|
+
['=', [3, 'xxx'], [2, 'xxx']],
|
35
|
+
['=', [4, 'ghi'], [3, 'ghi']],
|
36
|
+
['=', [5, 'jkl'], [4, 'jkl']]
|
37
37
|
]
|
38
38
|
}
|
39
39
|
|
40
|
-
it_has_behavior
|
40
|
+
it_has_behavior 'compare sequences correctly'
|
41
41
|
end
|
42
42
|
|
43
|
-
describe
|
43
|
+
describe 'using %w(a b c d e) & %w(a e)' do
|
44
44
|
let(:s1) { %w(a b c d e) }
|
45
45
|
let(:s2) { %w(a e) }
|
46
46
|
let(:result) {
|
47
47
|
[
|
48
|
-
[
|
49
|
-
[
|
50
|
-
[
|
51
|
-
[
|
52
|
-
[
|
48
|
+
['=', [0, 'a'], [0, 'a']],
|
49
|
+
['-', [1, 'b'], [1, nil]],
|
50
|
+
['-', [2, 'c'], [1, nil]],
|
51
|
+
['-', [3, 'd'], [1, nil]],
|
52
|
+
['=', [4, 'e'], [1, 'e']]
|
53
53
|
]
|
54
54
|
}
|
55
55
|
|
56
|
-
it_has_behavior
|
56
|
+
it_has_behavior 'compare sequences correctly'
|
57
57
|
end
|
58
58
|
|
59
|
-
describe
|
59
|
+
describe 'using %w(a e) & %w(a b c d e)' do
|
60
60
|
let(:s1) { %w(a e) }
|
61
61
|
let(:s2) { %w(a b c d e) }
|
62
62
|
let(:result) {
|
63
63
|
[
|
64
|
-
[
|
65
|
-
[
|
66
|
-
[
|
67
|
-
[
|
68
|
-
[
|
64
|
+
['=', [0, 'a'], [0, 'a']],
|
65
|
+
['+', [1, nil], [1, 'b']],
|
66
|
+
['+', [1, nil], [2, 'c']],
|
67
|
+
['+', [1, nil], [3, 'd']],
|
68
|
+
['=', [1, 'e'], [4, 'e']]
|
69
69
|
]
|
70
70
|
}
|
71
71
|
|
72
|
-
it_has_behavior
|
72
|
+
it_has_behavior 'compare sequences correctly'
|
73
73
|
end
|
74
74
|
|
75
|
-
describe
|
75
|
+
describe 'using %w(v x a e) & %w(w y a b c d e)' do
|
76
76
|
let(:s1) { %w(v x a e) }
|
77
77
|
let(:s2) { %w(w y a b c d e) }
|
78
78
|
let(:result) {
|
79
79
|
[
|
80
|
-
[
|
81
|
-
[
|
82
|
-
[
|
83
|
-
[
|
84
|
-
[
|
85
|
-
[
|
86
|
-
[
|
80
|
+
['!', [0, 'v'], [0, 'w']],
|
81
|
+
['!', [1, 'x'], [1, 'y']],
|
82
|
+
['=', [2, 'a'], [2, 'a']],
|
83
|
+
['+', [3, nil], [3, 'b']],
|
84
|
+
['+', [3, nil], [4, 'c']],
|
85
|
+
['+', [3, nil], [5, 'd']],
|
86
|
+
['=', [3, 'e'], [6, 'e']]
|
87
87
|
]
|
88
88
|
}
|
89
89
|
|
90
|
-
it_has_behavior
|
90
|
+
it_has_behavior 'compare sequences correctly'
|
91
91
|
end
|
92
92
|
|
93
|
-
describe
|
93
|
+
describe 'using %w(x a e) & %w(a b c d e)' do
|
94
94
|
let(:s1) { %w(x a e) }
|
95
95
|
let(:s2) { %w(a b c d e) }
|
96
96
|
let(:result) {
|
97
97
|
[
|
98
|
-
[
|
99
|
-
[
|
100
|
-
[
|
101
|
-
[
|
102
|
-
[
|
103
|
-
[
|
98
|
+
['-', [0, 'x'], [0, nil]],
|
99
|
+
['=', [1, 'a'], [0, 'a']],
|
100
|
+
['+', [2, nil], [1, 'b']],
|
101
|
+
['+', [2, nil], [2, 'c']],
|
102
|
+
['+', [2, nil], [3, 'd']],
|
103
|
+
['=', [2, 'e'], [4, 'e']]
|
104
104
|
]
|
105
105
|
}
|
106
106
|
|
107
|
-
it_has_behavior
|
107
|
+
it_has_behavior 'compare sequences correctly'
|
108
108
|
end
|
109
109
|
|
110
|
-
describe
|
110
|
+
describe 'using %w(a e) & %w(x a b c d e)' do
|
111
111
|
let(:s1) { %w(a e) }
|
112
112
|
let(:s2) { %w(x a b c d e) }
|
113
113
|
let(:result) {
|
114
114
|
[
|
115
|
-
[
|
116
|
-
[
|
117
|
-
[
|
118
|
-
[
|
119
|
-
[
|
120
|
-
[
|
115
|
+
['+', [0, nil], [0, 'x']],
|
116
|
+
['=', [0, 'a'], [1, 'a']],
|
117
|
+
['+', [1, nil], [2, 'b']],
|
118
|
+
['+', [1, nil], [3, 'c']],
|
119
|
+
['+', [1, nil], [4, 'd']],
|
120
|
+
['=', [1, 'e'], [5, 'e']]
|
121
121
|
]
|
122
122
|
}
|
123
123
|
|
124
|
-
it_has_behavior
|
124
|
+
it_has_behavior 'compare sequences correctly'
|
125
125
|
end
|
126
126
|
|
127
|
-
describe
|
127
|
+
describe 'using %w(a e v) & %w(x a b c d e w x)' do
|
128
128
|
let(:s1) { %w(a e v) }
|
129
129
|
let(:s2) { %w(x a b c d e w x) }
|
130
130
|
let(:result) {
|
131
131
|
[
|
132
|
-
[
|
133
|
-
[
|
134
|
-
[
|
135
|
-
[
|
136
|
-
[
|
137
|
-
[
|
138
|
-
[
|
139
|
-
[
|
132
|
+
['+', [0, nil], [0, 'x']],
|
133
|
+
['=', [0, 'a'], [1, 'a']],
|
134
|
+
['+', [1, nil], [2, 'b']],
|
135
|
+
['+', [1, nil], [3, 'c']],
|
136
|
+
['+', [1, nil], [4, 'd']],
|
137
|
+
['=', [1, 'e'], [5, 'e']],
|
138
|
+
['!', [2, 'v'], [6, 'w']],
|
139
|
+
['+', [3, nil], [7, 'x']]
|
140
140
|
]
|
141
141
|
}
|
142
142
|
|
143
|
-
it_has_behavior
|
143
|
+
it_has_behavior 'compare sequences correctly'
|
144
144
|
end
|
145
145
|
|
146
|
-
describe
|
146
|
+
describe 'using %w() & %w(a b c)' do
|
147
147
|
let(:s1) { %w() }
|
148
148
|
let(:s2) { %w(a b c) }
|
149
149
|
let(:result) {
|
150
150
|
[
|
151
|
-
[
|
152
|
-
[
|
153
|
-
[
|
151
|
+
['+', [0, nil], [0, 'a']],
|
152
|
+
['+', [0, nil], [1, 'b']],
|
153
|
+
['+', [0, nil], [2, 'c']]
|
154
154
|
]
|
155
155
|
}
|
156
156
|
|
157
|
-
it_has_behavior
|
157
|
+
it_has_behavior 'compare sequences correctly'
|
158
158
|
end
|
159
159
|
|
160
|
-
describe
|
160
|
+
describe 'using %w(a b c) & %w(1)' do
|
161
161
|
let(:s1) { %w(a b c) }
|
162
162
|
let(:s2) { %w(1) }
|
163
163
|
let(:result) {
|
164
164
|
[
|
165
|
-
[
|
166
|
-
[
|
167
|
-
[
|
165
|
+
['!', [0, 'a'], [0, '1']],
|
166
|
+
['-', [1, 'b'], [1, nil]],
|
167
|
+
['-', [2, 'c'], [1, nil]]
|
168
168
|
]
|
169
169
|
}
|
170
170
|
|
171
|
-
it_has_behavior
|
171
|
+
it_has_behavior 'compare sequences correctly'
|
172
172
|
end
|
173
173
|
|
174
|
-
describe
|
174
|
+
describe 'using %w(a b c) & %w(c)' do
|
175
175
|
let(:s1) { %w(a b c) }
|
176
176
|
let(:s2) { %w(c) }
|
177
177
|
let(:result) {
|
178
178
|
[
|
179
|
-
[
|
180
|
-
[
|
181
|
-
[
|
179
|
+
['-', [0, 'a'], [0, nil]],
|
180
|
+
['-', [1, 'b'], [0, nil]],
|
181
|
+
['=', [2, 'c'], [0, 'c']]
|
182
182
|
]
|
183
183
|
}
|
184
184
|
|
185
|
-
it_has_behavior
|
185
|
+
it_has_behavior 'compare sequences correctly'
|
186
186
|
end
|
187
187
|
|
188
|
-
describe
|
188
|
+
describe 'using %w(abcd efgh ijkl mnop) & []' do
|
189
189
|
let(:s1) { %w(abcd efgh ijkl mnop) }
|
190
190
|
let(:s2) { [] }
|
191
191
|
let(:result) {
|
192
192
|
[
|
193
|
-
[
|
194
|
-
[
|
195
|
-
[
|
196
|
-
[
|
193
|
+
['-', [0, 'abcd'], [0, nil]],
|
194
|
+
['-', [1, 'efgh'], [0, nil]],
|
195
|
+
['-', [2, 'ijkl'], [0, nil]],
|
196
|
+
['-', [3, 'mnop'], [0, nil]]
|
197
197
|
]
|
198
198
|
}
|
199
199
|
|
200
|
-
it_has_behavior
|
200
|
+
it_has_behavior 'compare sequences correctly'
|
201
|
+
end
|
202
|
+
|
203
|
+
describe 'using [[1,2]] & []' do
|
204
|
+
let(:s1) { [[1, 2]] }
|
205
|
+
let(:s2) { [] }
|
206
|
+
let(:result) {
|
207
|
+
[
|
208
|
+
['-', [0, [1, 2]], [0, nil]]
|
209
|
+
]
|
210
|
+
}
|
211
|
+
|
212
|
+
it_has_behavior 'compare sequences correctly'
|
201
213
|
end
|
202
214
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,35 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'pathname'
|
5
|
+
require 'psych'
|
6
|
+
|
7
|
+
if ENV['COVERAGE']
|
8
|
+
require 'simplecov'
|
9
|
+
|
10
|
+
def require_do(resource)
|
11
|
+
require resource
|
12
|
+
yield if block_given?
|
13
|
+
rescue LoadError
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
|
17
|
+
formatters = [SimpleCov::Formatter::HTMLFormatter]
|
18
|
+
|
19
|
+
require_do('simplecov-rcov') {
|
20
|
+
formatters << SimpleCov::Formatter::RcovFormatter
|
21
|
+
}
|
22
|
+
require_do('simplecov-vim/formatter') {
|
23
|
+
formatters << SimpleCov::Formatter::VimFormatter
|
24
|
+
}
|
25
|
+
require_do('simplecov-sublime-ruby-coverage') {
|
26
|
+
formatters << SimpleCov::Formatter::SublimeRubyCoverageFormatter
|
27
|
+
}
|
28
|
+
|
29
|
+
SimpleCov.start do
|
30
|
+
formatter SimpleCov::Formatter::MultiFormatter[*formatters]
|
31
|
+
end
|
32
|
+
end
|
5
33
|
|
6
34
|
file = Pathname.new(__FILE__).expand_path
|
7
35
|
path = file.parent
|
@@ -9,15 +37,47 @@ parent = path.parent
|
|
9
37
|
|
10
38
|
$:.unshift parent.join('lib')
|
11
39
|
|
40
|
+
module CaptureSubprocessIO
|
41
|
+
def _synchronize
|
42
|
+
yield
|
43
|
+
end
|
44
|
+
|
45
|
+
def capture_subprocess_io
|
46
|
+
_synchronize do
|
47
|
+
begin
|
48
|
+
require 'tempfile'
|
49
|
+
|
50
|
+
captured_stdout, captured_stderr = Tempfile.new('out'), Tempfile.new('err')
|
51
|
+
|
52
|
+
orig_stdout, orig_stderr = $stdout.dup, $stderr.dup
|
53
|
+
$stdout.reopen captured_stdout
|
54
|
+
$stderr.reopen captured_stderr
|
55
|
+
|
56
|
+
yield
|
57
|
+
|
58
|
+
$stdout.rewind
|
59
|
+
$stderr.rewind
|
60
|
+
|
61
|
+
return captured_stdout.read, captured_stderr.read
|
62
|
+
ensure
|
63
|
+
captured_stdout.unlink
|
64
|
+
captured_stderr.unlink
|
65
|
+
$stdout.reopen orig_stdout
|
66
|
+
$stderr.reopen orig_stderr
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
12
72
|
require 'diff-lcs'
|
13
73
|
|
14
74
|
module Diff::LCS::SpecHelper
|
15
75
|
def hello
|
16
|
-
|
76
|
+
'hello'
|
17
77
|
end
|
18
78
|
|
19
79
|
def hello_ary
|
20
|
-
%
|
80
|
+
%w(h e l l o)
|
21
81
|
end
|
22
82
|
|
23
83
|
def seq1
|
@@ -46,50 +106,69 @@ module Diff::LCS::SpecHelper
|
|
46
106
|
|
47
107
|
def correct_forward_diff
|
48
108
|
[
|
49
|
-
[
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
[
|
57
|
-
[
|
58
|
-
|
109
|
+
[
|
110
|
+
['-', 0, 'a']
|
111
|
+
],
|
112
|
+
[
|
113
|
+
['+', 2, 'd']
|
114
|
+
],
|
115
|
+
[
|
116
|
+
['-', 4, 'h'],
|
117
|
+
['+', 4, 'f']
|
118
|
+
],
|
119
|
+
[
|
120
|
+
['+', 6, 'k']
|
121
|
+
],
|
122
|
+
[
|
123
|
+
['-', 8, 'n'],
|
124
|
+
['-', 9, 'p'],
|
125
|
+
['+', 9, 'r'],
|
126
|
+
['+', 10, 's'],
|
127
|
+
['+', 11, 't']
|
128
|
+
]
|
59
129
|
]
|
60
130
|
end
|
61
131
|
|
62
132
|
def correct_backward_diff
|
63
133
|
[
|
64
|
-
[ [ '+', 0, 'a' ] ],
|
65
|
-
[ [ '-', 2, 'd' ] ],
|
66
|
-
[ [ '-', 4, 'f' ],
|
67
|
-
[ '+', 4, 'h' ] ],
|
68
|
-
[ [ '-', 6, 'k' ] ],
|
69
134
|
[
|
70
|
-
[
|
71
|
-
|
72
|
-
|
73
|
-
[
|
74
|
-
|
135
|
+
['+', 0, 'a']
|
136
|
+
],
|
137
|
+
[
|
138
|
+
['-', 2, 'd']
|
139
|
+
],
|
140
|
+
[
|
141
|
+
['-', 4, 'f'],
|
142
|
+
['+', 4, 'h']
|
143
|
+
],
|
144
|
+
[
|
145
|
+
['-', 6, 'k']
|
146
|
+
],
|
147
|
+
[
|
148
|
+
['-', 9, 'r'],
|
149
|
+
['-', 10, 's'],
|
150
|
+
['+', 8, 'n'],
|
151
|
+
['-', 11, 't'],
|
152
|
+
['+', 9, 'p']
|
153
|
+
]
|
75
154
|
]
|
76
155
|
end
|
77
156
|
|
78
157
|
def correct_forward_sdiff
|
79
158
|
[
|
80
|
-
[
|
81
|
-
[
|
82
|
-
[
|
83
|
-
[
|
84
|
-
[
|
85
|
-
[
|
86
|
-
[
|
87
|
-
[
|
88
|
-
[
|
89
|
-
[
|
90
|
-
[
|
91
|
-
[
|
92
|
-
[
|
159
|
+
['-', [0, 'a'], [0, nil]],
|
160
|
+
['=', [1, 'b'], [0, 'b']],
|
161
|
+
['=', [2, 'c'], [1, 'c']],
|
162
|
+
['+', [3, nil], [2, 'd']],
|
163
|
+
['=', [3, 'e'], [3, 'e']],
|
164
|
+
['!', [4, 'h'], [4, 'f']],
|
165
|
+
['=', [5, 'j'], [5, 'j']],
|
166
|
+
['+', [6, nil], [6, 'k']],
|
167
|
+
['=', [6, 'l'], [7, 'l']],
|
168
|
+
['=', [7, 'm'], [8, 'm']],
|
169
|
+
['!', [8, 'n'], [9, 'r']],
|
170
|
+
['!', [9, 'p'], [10, 's']],
|
171
|
+
['+', [10, nil], [11, 't']]
|
93
172
|
]
|
94
173
|
end
|
95
174
|
|
@@ -113,13 +192,13 @@ module Diff::LCS::SpecHelper
|
|
113
192
|
end
|
114
193
|
|
115
194
|
def format_diffs(diffs)
|
116
|
-
diffs.map
|
195
|
+
diffs.map { |e|
|
117
196
|
if e.kind_of?(Array)
|
118
|
-
e.map { |f| f.to_a.join }.join(
|
197
|
+
e.map { |f| f.to_a.join }.join(', ')
|
119
198
|
else
|
120
199
|
e.to_a.join
|
121
200
|
end
|
122
|
-
|
201
|
+
}.join("\n")
|
123
202
|
end
|
124
203
|
|
125
204
|
def map_diffs(diffs, klass = Diff::LCS::ContextChange)
|
@@ -140,8 +219,8 @@ module Diff::LCS::SpecHelper
|
|
140
219
|
|
141
220
|
def balanced_reverse(change_result)
|
142
221
|
new_result = []
|
143
|
-
change_result.each
|
144
|
-
line = [
|
222
|
+
change_result.each do |line|
|
223
|
+
line = [line[0], line[2], line[1]]
|
145
224
|
case line[0]
|
146
225
|
when '<'
|
147
226
|
line[0] = '>'
|
@@ -149,21 +228,21 @@ module Diff::LCS::SpecHelper
|
|
149
228
|
line[0] = '<'
|
150
229
|
end
|
151
230
|
new_result << line
|
152
|
-
|
153
|
-
new_result.sort_by { |line| [
|
231
|
+
end
|
232
|
+
new_result.sort_by { |line| [line[1], line[2]] }
|
154
233
|
end
|
155
234
|
|
156
235
|
def map_to_no_change(change_result)
|
157
236
|
new_result = []
|
158
|
-
change_result.each
|
237
|
+
change_result.each do |line|
|
159
238
|
case line[0]
|
160
239
|
when '!'
|
161
|
-
new_result << [
|
162
|
-
new_result << [
|
240
|
+
new_result << ['<', line[1], line[2]]
|
241
|
+
new_result << ['>', line[1] + 1, line[2]]
|
163
242
|
else
|
164
243
|
new_result << line
|
165
244
|
end
|
166
|
-
|
245
|
+
end
|
167
246
|
new_result
|
168
247
|
end
|
169
248
|
|
@@ -200,14 +279,18 @@ module Diff::LCS::SpecHelper
|
|
200
279
|
end
|
201
280
|
|
202
281
|
def finished_a(event)
|
203
|
-
@done_a << [
|
204
|
-
event.
|
282
|
+
@done_a << [
|
283
|
+
event.old_element, event.old_position,
|
284
|
+
event.new_element, event.new_position
|
285
|
+
]
|
205
286
|
end
|
206
287
|
|
207
288
|
def finished_b(event)
|
208
|
-
p
|
209
|
-
@done_b << [
|
210
|
-
event.
|
289
|
+
p 'called #finished_b'
|
290
|
+
@done_b << [
|
291
|
+
event.old_element, event.old_position,
|
292
|
+
event.new_element, event.new_position
|
293
|
+
]
|
211
294
|
end
|
212
295
|
end
|
213
296
|
callbacks.reset
|
@@ -233,19 +316,19 @@ module Diff::LCS::SpecHelper
|
|
233
316
|
end
|
234
317
|
|
235
318
|
def match(event)
|
236
|
-
@result << [
|
319
|
+
@result << ['=', event.old_position, event.new_position]
|
237
320
|
end
|
238
321
|
|
239
322
|
def discard_a(event)
|
240
|
-
@result << [
|
323
|
+
@result << ['<', event.old_position, event.new_position]
|
241
324
|
end
|
242
325
|
|
243
326
|
def discard_b(event)
|
244
|
-
@result << [
|
327
|
+
@result << ['>', event.old_position, event.new_position]
|
245
328
|
end
|
246
329
|
|
247
330
|
def change(event)
|
248
|
-
@result << [
|
331
|
+
@result << ['!', event.old_position, event.new_position]
|
249
332
|
end
|
250
333
|
end
|
251
334
|
cb.reset
|
@@ -265,14 +348,14 @@ module Diff::LCS::SpecHelper
|
|
265
348
|
|
266
349
|
matcher :be_nil_or_match_values do |ii, s1, s2|
|
267
350
|
match do |ee|
|
268
|
-
ee.
|
351
|
+
expect(ee).to(satisfy { |vee| vee.nil? || s1[ii] == s2[ee] })
|
269
352
|
end
|
270
353
|
end
|
271
354
|
|
272
355
|
matcher :correctly_map_sequence do |s1|
|
273
356
|
match do |actual|
|
274
357
|
actual.each_with_index { |ee, ii|
|
275
|
-
ee.
|
358
|
+
expect(ee).to be_nil_or_match_values(ii, s1, @s2)
|
276
359
|
}
|
277
360
|
end
|
278
361
|
|