diff-lcs 1.5.0 → 1.5.1
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/Contributing.md +2 -0
- data/History.md +86 -55
- data/License.md +6 -4
- data/Rakefile +36 -27
- data/bin/htmldiff +4 -4
- data/lib/diff/lcs/array.rb +1 -1
- data/lib/diff/lcs/backports.rb +2 -2
- data/lib/diff/lcs/block.rb +4 -4
- data/lib/diff/lcs/callbacks.rb +9 -7
- data/lib/diff/lcs/change.rb +19 -19
- data/lib/diff/lcs/htmldiff.rb +24 -16
- data/lib/diff/lcs/hunk.rb +35 -30
- data/lib/diff/lcs/internals.rb +17 -17
- data/lib/diff/lcs/ldiff.rb +37 -35
- data/lib/diff/lcs.rb +57 -55
- data/lib/diff-lcs.rb +1 -1
- data/spec/change_spec.rb +50 -50
- data/spec/diff_spec.rb +14 -14
- data/spec/hunk_spec.rb +19 -19
- data/spec/issues_spec.rb +48 -42
- data/spec/lcs_spec.rb +11 -11
- data/spec/ldiff_spec.rb +13 -11
- data/spec/patch_spec.rb +84 -84
- data/spec/sdiff_spec.rb +111 -109
- data/spec/spec_helper.rb +76 -74
- data/spec/traverse_balanced_spec.rb +191 -189
- data/spec/traverse_sequences_spec.rb +31 -31
- metadata +28 -21
data/spec/patch_spec.rb
CHANGED
@@ -1,54 +1,54 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe "Diff::LCS.patch" do
|
6
6
|
include Diff::LCS::SpecHelper::Matchers
|
7
7
|
|
8
|
-
shared_examples
|
9
|
-
it
|
8
|
+
shared_examples "patch sequences correctly" do
|
9
|
+
it "correctly patches left-to-right (patch autodiscovery)" do
|
10
10
|
expect(Diff::LCS.patch(s1, patch_set)).to eq(s2)
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
13
|
+
it "correctly patches left-to-right (explicit patch)" do
|
14
14
|
expect(Diff::LCS.patch(s1, patch_set, :patch)).to eq(s2)
|
15
15
|
expect(Diff::LCS.patch!(s1, patch_set)).to eq(s2)
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
18
|
+
it "correctly patches right-to-left (unpatch autodiscovery)" do
|
19
19
|
expect(Diff::LCS.patch(s2, patch_set)).to eq(s1)
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
22
|
+
it "correctly patches right-to-left (explicit unpatch)" do
|
23
23
|
expect(Diff::LCS.patch(s2, patch_set, :unpatch)).to eq(s1)
|
24
24
|
expect(Diff::LCS.unpatch!(s2, patch_set)).to eq(s1)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
describe
|
29
|
-
describe
|
30
|
-
it
|
28
|
+
describe "using a Diff::LCS.diff patchset" do
|
29
|
+
describe "an empty patchset returns the source" do
|
30
|
+
it "works on a string (hello)" do
|
31
31
|
diff = Diff::LCS.diff(hello, hello)
|
32
32
|
expect(Diff::LCS.patch(hello, diff)).to eq(hello)
|
33
33
|
end
|
34
34
|
|
35
|
-
it
|
35
|
+
it "works on an array %W(h e l l o)" do
|
36
36
|
diff = Diff::LCS.diff(hello_ary, hello_ary)
|
37
37
|
expect(Diff::LCS.patch(hello_ary, diff)).to eq(hello_ary)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
describe
|
42
|
-
describe
|
43
|
-
it_has_behavior
|
41
|
+
describe "with default diff callbacks (DiffCallbacks)" do
|
42
|
+
describe "forward (s1 -> s2)" do
|
43
|
+
it_has_behavior "patch sequences correctly" do
|
44
44
|
let(:s1) { seq1 }
|
45
45
|
let(:s2) { seq2 }
|
46
46
|
let(:patch_set) { Diff::LCS.diff(seq1, seq2) }
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
describe
|
51
|
-
it_has_behavior
|
50
|
+
describe "reverse (s2 -> s1)" do
|
51
|
+
it_has_behavior "patch sequences correctly" do
|
52
52
|
let(:s1) { seq2 }
|
53
53
|
let(:s2) { seq1 }
|
54
54
|
let(:patch_set) { Diff::LCS.diff(seq2, seq1) }
|
@@ -56,9 +56,9 @@ describe 'Diff::LCS.patch' do
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
describe
|
60
|
-
describe
|
61
|
-
it_has_behavior
|
59
|
+
describe "with context diff callbacks (ContextDiffCallbacks)" do
|
60
|
+
describe "forward (s1 -> s2)" do
|
61
|
+
it_has_behavior "patch sequences correctly" do
|
62
62
|
let(:s1) { seq1 }
|
63
63
|
let(:s2) { seq2 }
|
64
64
|
let(:patch_set) {
|
@@ -67,8 +67,8 @@ describe 'Diff::LCS.patch' do
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
describe
|
71
|
-
it_has_behavior
|
70
|
+
describe "reverse (s2 -> s1)" do
|
71
|
+
it_has_behavior "patch sequences correctly" do
|
72
72
|
let(:s1) { seq2 }
|
73
73
|
let(:s2) { seq1 }
|
74
74
|
let(:patch_set) {
|
@@ -78,9 +78,9 @@ describe 'Diff::LCS.patch' do
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
describe
|
82
|
-
describe
|
83
|
-
it_has_behavior
|
81
|
+
describe "with sdiff callbacks (SDiffCallbacks)" do
|
82
|
+
describe "forward (s1 -> s2)" do
|
83
|
+
it_has_behavior "patch sequences correctly" do
|
84
84
|
let(:s1) { seq1 }
|
85
85
|
let(:s2) { seq2 }
|
86
86
|
let(:patch_set) {
|
@@ -89,8 +89,8 @@ describe 'Diff::LCS.patch' do
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
describe
|
93
|
-
it_has_behavior
|
92
|
+
describe "reverse (s2 -> s1)" do
|
93
|
+
it_has_behavior "patch sequences correctly" do
|
94
94
|
let(:s1) { seq2 }
|
95
95
|
let(:s2) { seq1 }
|
96
96
|
let(:patch_set) {
|
@@ -101,20 +101,20 @@ describe 'Diff::LCS.patch' do
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
describe
|
105
|
-
describe
|
106
|
-
it
|
104
|
+
describe "using a Diff::LCS.sdiff patchset" do
|
105
|
+
describe "an empty patchset returns the source" do
|
106
|
+
it "works on a string (hello)" do
|
107
107
|
expect(Diff::LCS.patch(hello, Diff::LCS.sdiff(hello, hello))).to eq(hello)
|
108
108
|
end
|
109
109
|
|
110
|
-
it
|
110
|
+
it "works on an array %W(h e l l o)" do
|
111
111
|
expect(Diff::LCS.patch(hello_ary, Diff::LCS.sdiff(hello_ary, hello_ary))).to eq(hello_ary)
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
-
describe
|
116
|
-
describe
|
117
|
-
it_has_behavior
|
115
|
+
describe "with default diff callbacks (DiffCallbacks)" do
|
116
|
+
describe "forward (s1 -> s2)" do
|
117
|
+
it_has_behavior "patch sequences correctly" do
|
118
118
|
let(:s1) { seq1 }
|
119
119
|
let(:s2) { seq2 }
|
120
120
|
let(:patch_set) {
|
@@ -123,8 +123,8 @@ describe 'Diff::LCS.patch' do
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
-
describe
|
127
|
-
it_has_behavior
|
126
|
+
describe "reverse (s2 -> s1)" do
|
127
|
+
it_has_behavior "patch sequences correctly" do
|
128
128
|
let(:s1) { seq2 }
|
129
129
|
let(:s2) { seq1 }
|
130
130
|
let(:patch_set) {
|
@@ -134,9 +134,9 @@ describe 'Diff::LCS.patch' do
|
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
-
describe
|
138
|
-
describe
|
139
|
-
it_has_behavior
|
137
|
+
describe "with context diff callbacks (DiffCallbacks)" do
|
138
|
+
describe "forward (s1 -> s2)" do
|
139
|
+
it_has_behavior "patch sequences correctly" do
|
140
140
|
let(:s1) { seq1 }
|
141
141
|
let(:s2) { seq2 }
|
142
142
|
let(:patch_set) {
|
@@ -145,8 +145,8 @@ describe 'Diff::LCS.patch' do
|
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
|
-
describe
|
149
|
-
it_has_behavior
|
148
|
+
describe "reverse (s2 -> s1)" do
|
149
|
+
it_has_behavior "patch sequences correctly" do
|
150
150
|
let(:s1) { seq2 }
|
151
151
|
let(:s2) { seq1 }
|
152
152
|
let(:patch_set) {
|
@@ -156,17 +156,17 @@ describe 'Diff::LCS.patch' do
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
|
-
describe
|
160
|
-
describe
|
161
|
-
it_has_behavior
|
159
|
+
describe "with sdiff callbacks (SDiffCallbacks)" do
|
160
|
+
describe "forward (s1 -> s2)" do
|
161
|
+
it_has_behavior "patch sequences correctly" do
|
162
162
|
let(:s1) { seq1 }
|
163
163
|
let(:s2) { seq2 }
|
164
164
|
let(:patch_set) { Diff::LCS.sdiff(seq1, seq2) }
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
168
|
-
describe
|
169
|
-
it_has_behavior
|
168
|
+
describe "reverse (s2 -> s1)" do
|
169
|
+
it_has_behavior "patch sequences correctly" do
|
170
170
|
let(:s1) { seq2 }
|
171
171
|
let(:s2) { seq1 }
|
172
172
|
let(:patch_set) { Diff::LCS.sdiff(seq2, seq1) }
|
@@ -179,43 +179,43 @@ describe 'Diff::LCS.patch' do
|
|
179
179
|
# to s2 patches"), this cannot use the "patch sequences correctly" shared
|
180
180
|
# set. Once the bug in autodiscovery is fixed, this can be converted as
|
181
181
|
# above.
|
182
|
-
describe
|
182
|
+
describe "fix bug 891: patchsets do not contain the last equal part" do
|
183
183
|
before :each do
|
184
|
-
@s1 = %w
|
185
|
-
@s2 = %w
|
184
|
+
@s1 = %w[a b c d e f g h i j k] # rubocop:disable Layout/SpaceInsideArrayPercentLiteral
|
185
|
+
@s2 = %w[a b c d D e f g h i j k]
|
186
186
|
end
|
187
187
|
|
188
|
-
describe
|
188
|
+
describe "using Diff::LCS.diff with default diff callbacks" do
|
189
189
|
before :each do
|
190
190
|
@patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2)
|
191
191
|
@patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1)
|
192
192
|
end
|
193
193
|
|
194
|
-
it
|
194
|
+
it "autodiscovers s1 to s2 patches" do
|
195
195
|
expect do
|
196
196
|
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
|
197
197
|
end.to_not raise_error
|
198
198
|
end
|
199
199
|
|
200
|
-
it
|
200
|
+
it "autodiscovers s2 to s1 patches" do
|
201
201
|
expect do
|
202
202
|
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
|
203
203
|
end.to_not raise_error
|
204
204
|
end
|
205
205
|
|
206
|
-
it
|
206
|
+
it "autodiscovers s2 to s1 the left-to-right patches" do
|
207
207
|
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
|
208
208
|
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
|
209
209
|
end
|
210
210
|
|
211
|
-
it
|
211
|
+
it "correctly patches left-to-right (explicit patch)" do
|
212
212
|
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
|
213
213
|
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
|
214
214
|
expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
|
215
215
|
expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
|
216
216
|
end
|
217
217
|
|
218
|
-
it
|
218
|
+
it "correctly patches right-to-left (explicit unpatch)" do
|
219
219
|
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
|
220
220
|
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
|
221
221
|
expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
|
@@ -223,37 +223,37 @@ describe 'Diff::LCS.patch' do
|
|
223
223
|
end
|
224
224
|
end
|
225
225
|
|
226
|
-
describe
|
226
|
+
describe "using Diff::LCS.diff with context diff callbacks" do
|
227
227
|
before :each do
|
228
228
|
@patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2, Diff::LCS::ContextDiffCallbacks)
|
229
229
|
@patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1, Diff::LCS::ContextDiffCallbacks)
|
230
230
|
end
|
231
231
|
|
232
|
-
it
|
232
|
+
it "autodiscovers s1 to s2 patches" do
|
233
233
|
expect do
|
234
234
|
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
|
235
235
|
end.to_not raise_error
|
236
236
|
end
|
237
237
|
|
238
|
-
it
|
238
|
+
it "autodiscovers s2 to s1 patches" do
|
239
239
|
expect do
|
240
240
|
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
|
241
241
|
end.to_not raise_error
|
242
242
|
end
|
243
243
|
|
244
|
-
it
|
244
|
+
it "autodiscovers s2 to s1 the left-to-right patches" do
|
245
245
|
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
|
246
246
|
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
|
247
247
|
end
|
248
248
|
|
249
|
-
it
|
249
|
+
it "correctly patches left-to-right (explicit patch)" do
|
250
250
|
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
|
251
251
|
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
|
252
252
|
expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
|
253
253
|
expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
|
254
254
|
end
|
255
255
|
|
256
|
-
it
|
256
|
+
it "correctly patches right-to-left (explicit unpatch)" do
|
257
257
|
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
|
258
258
|
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
|
259
259
|
expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
|
@@ -261,37 +261,37 @@ describe 'Diff::LCS.patch' do
|
|
261
261
|
end
|
262
262
|
end
|
263
263
|
|
264
|
-
describe
|
264
|
+
describe "using Diff::LCS.diff with sdiff callbacks" do
|
265
265
|
before(:each) do
|
266
266
|
@patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2, Diff::LCS::SDiffCallbacks)
|
267
267
|
@patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1, Diff::LCS::SDiffCallbacks)
|
268
268
|
end
|
269
269
|
|
270
|
-
it
|
270
|
+
it "autodiscovers s1 to s2 patches" do
|
271
271
|
expect do
|
272
272
|
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
|
273
273
|
end.to_not raise_error
|
274
274
|
end
|
275
275
|
|
276
|
-
it
|
276
|
+
it "autodiscovers s2 to s1 patches" do
|
277
277
|
expect do
|
278
278
|
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
|
279
279
|
end.to_not raise_error
|
280
280
|
end
|
281
281
|
|
282
|
-
it
|
282
|
+
it "autodiscovers s2 to s1 the left-to-right patches" do
|
283
283
|
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
|
284
284
|
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
|
285
285
|
end
|
286
286
|
|
287
|
-
it
|
287
|
+
it "correctly patches left-to-right (explicit patch)" do
|
288
288
|
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
|
289
289
|
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
|
290
290
|
expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
|
291
291
|
expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
|
292
292
|
end
|
293
293
|
|
294
|
-
it
|
294
|
+
it "correctly patches right-to-left (explicit unpatch)" do
|
295
295
|
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
|
296
296
|
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
|
297
297
|
expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
|
@@ -299,37 +299,37 @@ describe 'Diff::LCS.patch' do
|
|
299
299
|
end
|
300
300
|
end
|
301
301
|
|
302
|
-
describe
|
302
|
+
describe "using Diff::LCS.sdiff with default sdiff callbacks" do
|
303
303
|
before(:each) do
|
304
304
|
@patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2)
|
305
305
|
@patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1)
|
306
306
|
end
|
307
307
|
|
308
|
-
it
|
308
|
+
it "autodiscovers s1 to s2 patches" do
|
309
309
|
expect do
|
310
310
|
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
|
311
311
|
end.to_not raise_error
|
312
312
|
end
|
313
313
|
|
314
|
-
it
|
314
|
+
it "autodiscovers s2 to s1 patches" do
|
315
315
|
expect do
|
316
316
|
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
|
317
317
|
end.to_not raise_error
|
318
318
|
end
|
319
319
|
|
320
|
-
it
|
320
|
+
it "autodiscovers s2 to s1 the left-to-right patches" do
|
321
321
|
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
|
322
322
|
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
|
323
323
|
end
|
324
324
|
|
325
|
-
it
|
325
|
+
it "correctly patches left-to-right (explicit patch)" do
|
326
326
|
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
|
327
327
|
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
|
328
328
|
expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
|
329
329
|
expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
|
330
330
|
end
|
331
331
|
|
332
|
-
it
|
332
|
+
it "correctly patches right-to-left (explicit unpatch)" do
|
333
333
|
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
|
334
334
|
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
|
335
335
|
expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
|
@@ -337,37 +337,37 @@ describe 'Diff::LCS.patch' do
|
|
337
337
|
end
|
338
338
|
end
|
339
339
|
|
340
|
-
describe
|
340
|
+
describe "using Diff::LCS.sdiff with context diff callbacks" do
|
341
341
|
before(:each) do
|
342
342
|
@patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2, Diff::LCS::ContextDiffCallbacks)
|
343
343
|
@patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1, Diff::LCS::ContextDiffCallbacks)
|
344
344
|
end
|
345
345
|
|
346
|
-
it
|
346
|
+
it "autodiscovers s1 to s2 patches" do
|
347
347
|
expect do
|
348
348
|
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
|
349
349
|
end.to_not raise_error
|
350
350
|
end
|
351
351
|
|
352
|
-
it
|
352
|
+
it "autodiscovers s2 to s1 patches" do
|
353
353
|
expect do
|
354
354
|
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
|
355
355
|
end.to_not raise_error
|
356
356
|
end
|
357
357
|
|
358
|
-
it
|
358
|
+
it "autodiscovers s2 to s1 the left-to-right patches" do
|
359
359
|
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
|
360
360
|
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
|
361
361
|
end
|
362
362
|
|
363
|
-
it
|
363
|
+
it "correctly patches left-to-right (explicit patch)" do
|
364
364
|
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
|
365
365
|
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
|
366
366
|
expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
|
367
367
|
expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
|
368
368
|
end
|
369
369
|
|
370
|
-
it
|
370
|
+
it "correctly patches right-to-left (explicit unpatch)" do
|
371
371
|
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
|
372
372
|
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
|
373
373
|
expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
|
@@ -375,37 +375,37 @@ describe 'Diff::LCS.patch' do
|
|
375
375
|
end
|
376
376
|
end
|
377
377
|
|
378
|
-
describe
|
378
|
+
describe "using Diff::LCS.sdiff with default diff callbacks" do
|
379
379
|
before(:each) do
|
380
380
|
@patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2, Diff::LCS::DiffCallbacks)
|
381
381
|
@patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1, Diff::LCS::DiffCallbacks)
|
382
382
|
end
|
383
383
|
|
384
|
-
it
|
384
|
+
it "autodiscovers s1 to s2 patches" do
|
385
385
|
expect do
|
386
386
|
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
|
387
387
|
end.to_not raise_error
|
388
388
|
end
|
389
389
|
|
390
|
-
it
|
390
|
+
it "autodiscovers s2 to s1 patches" do
|
391
391
|
expect do
|
392
392
|
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
|
393
393
|
end.to_not raise_error
|
394
394
|
end
|
395
395
|
|
396
|
-
it
|
396
|
+
it "autodiscovers s2 to s1 the left-to-right patches" do
|
397
397
|
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
|
398
398
|
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
|
399
399
|
end
|
400
400
|
|
401
|
-
it
|
401
|
+
it "correctly patches left-to-right (explicit patch)" do
|
402
402
|
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
|
403
403
|
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
|
404
404
|
expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
|
405
405
|
expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
|
406
406
|
end
|
407
407
|
|
408
|
-
it
|
408
|
+
it "correctly patches right-to-left (explicit unpatch)" do
|
409
409
|
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
|
410
410
|
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
|
411
411
|
expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
|