diff-lcs 1.2.5 → 1.4.3

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