diff-lcs 2.0.0.beta.1 → 2.0.0.beta.2
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/CHANGELOG.md +30 -5
- data/CONTRIBUTING.md +8 -3
- data/CONTRIBUTORS.md +19 -9
- data/Manifest.txt +88 -70
- data/README.md +13 -9
- data/Rakefile +90 -22
- data/SECURITY.md +1 -10
- data/integration/compare/array_diff_spec.rb +10 -0
- data/integration/compare/hash_diff_spec.rb +25 -0
- data/integration/compare/string_diff_spec.rb +10 -0
- data/integration/rspec_differ_spec.rb +26 -0
- data/integration/rspec_expectations_spec.rb +32 -0
- data/integration/runner +20 -0
- data/lib/diff/lcs/change.rb +21 -16
- data/lib/diff/lcs/ldiff.rb +9 -4
- data/lib/diff/lcs/version.rb +1 -1
- data/spec/hunk_spec.rb +32 -34
- data/spec/ldiff_spec.rb +7 -7
- data/spec/spec_helper.rb +4 -12
- data/test/fixtures/ldiff/output.diff-c +7 -0
- data/test/fixtures/ldiff/output.diff-u +5 -0
- data/test/fixtures/ldiff/output.diff.bin2 +1 -0
- data/test/fixtures/ldiff/output.diff.bin2-c +1 -0
- data/test/fixtures/ldiff/output.diff.bin2-e +1 -0
- data/test/fixtures/ldiff/output.diff.bin2-f +1 -0
- data/test/fixtures/ldiff/output.diff.bin2-u +1 -0
- data/{spec → test}/fixtures/ldiff/output.diff.chef-c +2 -2
- data/test/fixtures/ldiff/output.diff.chef-u +9 -0
- data/{spec → test}/fixtures/ldiff/output.diff.chef2-c +2 -2
- data/{spec → test}/fixtures/ldiff/output.diff.chef2-u +2 -2
- data/test/fixtures/ldiff/output.diff.empty.vs.four_lines-c +9 -0
- data/test/fixtures/ldiff/output.diff.empty.vs.four_lines-u +7 -0
- data/test/fixtures/ldiff/output.diff.four_lines.vs.empty-c +9 -0
- data/test/fixtures/ldiff/output.diff.four_lines.vs.empty-u +7 -0
- data/test/fixtures/ldiff/output.diff.issue95_trailing_context-c +9 -0
- data/test/fixtures/ldiff/output.diff.issue95_trailing_context-u +6 -0
- data/{spec → test}/fixtures/ldiff/output.diff.missing_new_line1-c +2 -2
- data/test/fixtures/ldiff/output.diff.missing_new_line1-u +9 -0
- data/{spec → test}/fixtures/ldiff/output.diff.missing_new_line2-c +2 -2
- data/test/fixtures/ldiff/output.diff.missing_new_line2-u +9 -0
- data/test/test_block.rb +34 -0
- data/test/test_change.rb +234 -0
- data/test/test_diff.rb +53 -0
- data/test/test_helper.rb +225 -0
- data/test/test_hunk.rb +72 -0
- data/test/test_issues.rb +168 -0
- data/test/test_lcs.rb +47 -0
- data/test/test_ldiff.rb +89 -0
- data/test/test_patch.rb +362 -0
- data/test/test_sdiff.rb +167 -0
- data/test/test_traverse_balanced.rb +322 -0
- data/test/test_traverse_sequences.rb +187 -0
- metadata +130 -96
- data/spec/fixtures/ldiff/output.diff-c +0 -7
- data/spec/fixtures/ldiff/output.diff-u +0 -5
- data/spec/fixtures/ldiff/output.diff.bin2 +0 -1
- data/spec/fixtures/ldiff/output.diff.bin2-c +0 -1
- data/spec/fixtures/ldiff/output.diff.bin2-e +0 -1
- data/spec/fixtures/ldiff/output.diff.bin2-f +0 -1
- data/spec/fixtures/ldiff/output.diff.bin2-u +0 -1
- data/spec/fixtures/ldiff/output.diff.chef-u +0 -9
- data/spec/fixtures/ldiff/output.diff.empty.vs.four_lines-c +0 -9
- data/spec/fixtures/ldiff/output.diff.empty.vs.four_lines-u +0 -7
- data/spec/fixtures/ldiff/output.diff.four_lines.vs.empty-c +0 -9
- data/spec/fixtures/ldiff/output.diff.four_lines.vs.empty-u +0 -7
- data/spec/fixtures/ldiff/output.diff.issue95_trailing_context-c +0 -9
- data/spec/fixtures/ldiff/output.diff.issue95_trailing_context-u +0 -6
- data/spec/fixtures/ldiff/output.diff.missing_new_line1-u +0 -9
- data/spec/fixtures/ldiff/output.diff.missing_new_line2-u +0 -9
- /data/{spec → test}/fixtures/123_x +0 -0
- /data/{spec → test}/fixtures/456_x +0 -0
- /data/{spec → test}/fixtures/aX +0 -0
- /data/{spec → test}/fixtures/bXaX +0 -0
- /data/{spec → test}/fixtures/ds1.csv +0 -0
- /data/{spec → test}/fixtures/ds2.csv +0 -0
- /data/{spec → test}/fixtures/empty +0 -0
- /data/{spec → test}/fixtures/file1.bin +0 -0
- /data/{spec → test}/fixtures/file2.bin +0 -0
- /data/{spec → test}/fixtures/four_lines +0 -0
- /data/{spec → test}/fixtures/four_lines_with_missing_new_line +0 -0
- /data/{spec → test}/fixtures/ldiff/diff.missing_new_line1-e +0 -0
- /data/{spec → test}/fixtures/ldiff/diff.missing_new_line1-f +0 -0
- /data/{spec → test}/fixtures/ldiff/diff.missing_new_line2-e +0 -0
- /data/{spec → test}/fixtures/ldiff/diff.missing_new_line2-f +0 -0
- /data/{spec → test}/fixtures/ldiff/error.diff.chef-e +0 -0
- /data/{spec → test}/fixtures/ldiff/error.diff.chef-f +0 -0
- /data/{spec → test}/fixtures/ldiff/error.diff.missing_new_line1-e +0 -0
- /data/{spec → test}/fixtures/ldiff/error.diff.missing_new_line1-f +0 -0
- /data/{spec → test}/fixtures/ldiff/error.diff.missing_new_line2-e +0 -0
- /data/{spec → test}/fixtures/ldiff/error.diff.missing_new_line2-f +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.bin1 +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.bin1-c +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.bin1-e +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.bin1-f +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.bin1-u +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.chef +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.chef2 +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.chef2-d +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.empty.vs.four_lines +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.empty.vs.four_lines-e +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.empty.vs.four_lines-f +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.four_lines.vs.empty +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.four_lines.vs.empty-e +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.four_lines.vs.empty-f +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.issue95_trailing_context +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.issue95_trailing_context-e +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.issue95_trailing_context-f +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.missing_new_line1 +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.missing_new_line1-e +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.missing_new_line1-f +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.missing_new_line2 +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.missing_new_line2-e +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.missing_new_line2-f +0 -0
- /data/{spec → test}/fixtures/new-chef +0 -0
- /data/{spec → test}/fixtures/new-chef2 +0 -0
- /data/{spec → test}/fixtures/old-chef +0 -0
- /data/{spec → test}/fixtures/old-chef2 +0 -0
data/lib/diff/lcs/change.rb
CHANGED
|
@@ -10,7 +10,7 @@ class Diff::LCS::Change
|
|
|
10
10
|
# (changed), '<' (tail changes from first sequence), or '>' (tail changes from second
|
|
11
11
|
# sequence). The last two ('<>') are only found with Diff::LCS::diff and
|
|
12
12
|
# Diff::LCS::sdiff.
|
|
13
|
-
VALID_ACTIONS = %w[
|
|
13
|
+
VALID_ACTIONS = %w[= - + ! > <].freeze
|
|
14
14
|
|
|
15
15
|
def self.valid_action?(action) = VALID_ACTIONS.include?(action)
|
|
16
16
|
|
|
@@ -37,6 +37,9 @@ class Diff::LCS::Change
|
|
|
37
37
|
|
|
38
38
|
def to_a = [action, position, element]
|
|
39
39
|
alias_method :to_ary, :to_a
|
|
40
|
+
alias_method :deconstruct, :to_a
|
|
41
|
+
|
|
42
|
+
def deconstruct_keys(_) = {action:, position:, element:}
|
|
40
43
|
|
|
41
44
|
def self.from_a(arr)
|
|
42
45
|
case arr
|
|
@@ -59,8 +62,8 @@ class Diff::LCS::Change
|
|
|
59
62
|
end
|
|
60
63
|
|
|
61
64
|
def <=>(other)
|
|
62
|
-
r =
|
|
63
|
-
r =
|
|
65
|
+
r = position <=> other.position
|
|
66
|
+
r = VALID_ACTIONS.index(action) <=> VALID_ACTIONS.index(other.action) if r.zero?
|
|
64
67
|
r = element <=> other.element if r.zero?
|
|
65
68
|
r
|
|
66
69
|
end
|
|
@@ -111,28 +114,27 @@ class Diff::LCS::ContextChange
|
|
|
111
114
|
|
|
112
115
|
def to_a = [action, [old_position, old_element], [new_position, new_element]]
|
|
113
116
|
alias_method :to_ary, :to_a
|
|
117
|
+
alias_method :deconstruct, :to_a
|
|
118
|
+
|
|
119
|
+
def deconstruct_keys(_) = {action:, old_position:, old_element:, new_position:, new_element:}
|
|
114
120
|
|
|
115
121
|
def self.from_a(arr) = Diff::LCS::Change.from_a(arr)
|
|
116
122
|
|
|
117
123
|
# Simplifies a context change for use in some diff callbacks. '<' actions are converted
|
|
118
124
|
# to '-' and '>' actions are converted to '+'.
|
|
119
125
|
def self.simplify(event)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
case ea[0]
|
|
126
|
+
case event.action
|
|
123
127
|
when "-"
|
|
124
|
-
|
|
128
|
+
event.with(new_element: nil)
|
|
125
129
|
when "<"
|
|
126
|
-
|
|
127
|
-
ea[2][1] = nil
|
|
130
|
+
event.with(action: "-", new_element: nil)
|
|
128
131
|
when "+"
|
|
129
|
-
|
|
132
|
+
event.with(old_element: nil)
|
|
130
133
|
when ">"
|
|
131
|
-
|
|
132
|
-
|
|
134
|
+
event.with(action: "+", old_element: nil)
|
|
135
|
+
else
|
|
136
|
+
event
|
|
133
137
|
end
|
|
134
|
-
|
|
135
|
-
from_a(ea)
|
|
136
138
|
end
|
|
137
139
|
|
|
138
140
|
def ==(other)
|
|
@@ -145,9 +147,12 @@ class Diff::LCS::ContextChange
|
|
|
145
147
|
end
|
|
146
148
|
|
|
147
149
|
def <=>(other)
|
|
148
|
-
r =
|
|
149
|
-
r = old_position <=> other.old_position if r.zero?
|
|
150
|
+
r = old_position <=> other.old_position
|
|
150
151
|
r = new_position <=> other.new_position if r.zero?
|
|
152
|
+
if r.zero?
|
|
153
|
+
r = Diff::LCS::Change::VALID_ACTIONS.index(action) <=>
|
|
154
|
+
Diff::LCS::Change::VALID_ACTIONS.index(other.action)
|
|
155
|
+
end
|
|
151
156
|
r = old_element <=> other.old_element if r.zero?
|
|
152
157
|
r = new_element <=> other.new_element if r.zero?
|
|
153
158
|
r
|
data/lib/diff/lcs/ldiff.rb
CHANGED
|
@@ -16,9 +16,14 @@ class Diff::LCS::Ldiff # :nodoc:
|
|
|
16
16
|
MIT licence.
|
|
17
17
|
COPYRIGHT
|
|
18
18
|
|
|
19
|
-
InputInfo = Struct.new(:filename, :data, :
|
|
19
|
+
InputInfo = Struct.new(:filename, :data, :mtime) do
|
|
20
20
|
def initialize(filename)
|
|
21
|
-
|
|
21
|
+
if filename == "-"
|
|
22
|
+
super("<stdin>", $stdin.read, Time.now)
|
|
23
|
+
return
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
super(filename, ::File.read(filename), ::File.stat(filename).mtime)
|
|
22
27
|
end
|
|
23
28
|
end
|
|
24
29
|
|
|
@@ -142,9 +147,9 @@ class Diff::LCS::Ldiff # :nodoc:
|
|
|
142
147
|
output << "Files #{info_old.filename} and #{info_new.filename} differ\n"
|
|
143
148
|
return true
|
|
144
149
|
when :unified, :context
|
|
145
|
-
ft = info_old.
|
|
150
|
+
ft = info_old.mtime.localtime.strftime("%Y-%m-%d %H:%M:%S.000000000 %z")
|
|
146
151
|
output << "#{char_old} #{info_old.filename}\t#{ft}\n"
|
|
147
|
-
ft = info_new.
|
|
152
|
+
ft = info_new.mtime.localtime.strftime("%Y-%m-%d %H:%M:%S.000000000 %z")
|
|
148
153
|
output << "#{char_new} #{info_new.filename}\t#{ft}\n"
|
|
149
154
|
when :ed
|
|
150
155
|
output = []
|
data/lib/diff/lcs/version.rb
CHANGED
data/spec/hunk_spec.rb
CHANGED
|
@@ -2,71 +2,69 @@
|
|
|
2
2
|
|
|
3
3
|
require "spec_helper"
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
require "diff/lcs/hunk"
|
|
5
|
+
require "diff/lcs/hunk"
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
describe Diff::LCS::Hunk do
|
|
8
|
+
let(:old_data) { ["Tu a un carté avec {count} itéms".encode("UTF-16LE")] }
|
|
9
|
+
let(:new_data) { ["Tu a un carte avec {count} items".encode("UTF-16LE")] }
|
|
10
|
+
let(:pieces) { Diff::LCS.diff old_data, new_data }
|
|
11
|
+
let(:hunk) { Diff::LCS::Hunk.new(old_data, new_data, pieces[0], 3, 0) }
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
it "produces a unified diff from the two pieces" do
|
|
14
|
+
expected = <<-EXPECTED.gsub(/^\s+/, "").encode("UTF-16LE").chomp
|
|
16
15
|
@@ -1 +1 @@
|
|
17
16
|
-Tu a un carté avec {count} itéms
|
|
18
17
|
+Tu a un carte avec {count} items
|
|
19
|
-
|
|
18
|
+
EXPECTED
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
expect(hunk.diff(:unified)).to eq(expected)
|
|
21
|
+
end
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
it "produces a unified diff from the two pieces (last entry)" do
|
|
24
|
+
expected = <<-EXPECTED.gsub(/^\s+/, "").encode("UTF-16LE").chomp
|
|
26
25
|
@@ -1 +1 @@
|
|
27
26
|
-Tu a un carté avec {count} itéms
|
|
28
27
|
+Tu a un carte avec {count} items
|
|
29
28
|
\
|
|
30
|
-
|
|
29
|
+
EXPECTED
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
expect(hunk.diff(:unified, true)).to eq(expected)
|
|
32
|
+
end
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
it "produces a context diff from the two pieces" do
|
|
35
|
+
expected = <<-EXPECTED.gsub(/^\s+/, "").encode("UTF-16LE").chomp
|
|
37
36
|
***************
|
|
38
37
|
*** 1 ****
|
|
39
38
|
! Tu a un carté avec {count} itéms
|
|
40
39
|
--- 1 ----
|
|
41
40
|
! Tu a un carte avec {count} items
|
|
42
|
-
|
|
41
|
+
EXPECTED
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
expect(hunk.diff(:context)).to eq(expected)
|
|
44
|
+
end
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
it "produces an old diff from the two pieces" do
|
|
47
|
+
expected = <<-EXPECTED.gsub(/^ +/, "").encode("UTF-16LE").chomp
|
|
49
48
|
1c1
|
|
50
49
|
< Tu a un carté avec {count} itéms
|
|
51
50
|
---
|
|
52
51
|
> Tu a un carte avec {count} items
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
EXPECTED
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
expect(hunk.diff(:old)).to eq(expected)
|
|
56
|
+
end
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
context "with empty first data set" do
|
|
59
|
+
let(:old_data) { [] }
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
it "produces a unified diff" do
|
|
62
|
+
expected = <<-EXPECTED.gsub(/^\s+/, "").encode("UTF-16LE").chomp
|
|
64
63
|
@@ -0,0 +1 @@
|
|
65
64
|
+Tu a un carte avec {count} items
|
|
66
|
-
|
|
65
|
+
EXPECTED
|
|
67
66
|
|
|
68
|
-
|
|
69
|
-
end
|
|
67
|
+
expect(hunk.diff(:unified)).to eq(expected)
|
|
70
68
|
end
|
|
71
69
|
end
|
|
72
70
|
end
|
data/spec/ldiff_spec.rb
CHANGED
|
@@ -27,11 +27,11 @@ RSpec.describe "bin/ldiff" do
|
|
|
27
27
|
def self.test_ldiff(fixture)
|
|
28
28
|
desc = [
|
|
29
29
|
fixture[:flag],
|
|
30
|
-
"
|
|
31
|
-
"
|
|
30
|
+
"test/fixtures/#{fixture[:left]}",
|
|
31
|
+
"test/fixtures/#{fixture[:right]}",
|
|
32
32
|
"#",
|
|
33
33
|
"=>",
|
|
34
|
-
"
|
|
34
|
+
"test/fixtures/ldiff/output.#{fixture[:name]}#{fixture[:flag]}"
|
|
35
35
|
].join(" ")
|
|
36
36
|
|
|
37
37
|
it desc do
|
|
@@ -49,7 +49,7 @@ RSpec.describe "bin/ldiff" do
|
|
|
49
49
|
def read_fixture(options, mode: "output", allow_missing: false)
|
|
50
50
|
fixture = options.fetch(:name)
|
|
51
51
|
flag = options.fetch(:flag)
|
|
52
|
-
name = "
|
|
52
|
+
name = "test/fixtures/ldiff/#{mode}.#{fixture}#{flag}"
|
|
53
53
|
|
|
54
54
|
return "" if !::File.exist?(name) && allow_missing
|
|
55
55
|
|
|
@@ -74,7 +74,7 @@ RSpec.describe "bin/ldiff" do
|
|
|
74
74
|
^
|
|
75
75
|
[-+*]{3}
|
|
76
76
|
\s*
|
|
77
|
-
|
|
77
|
+
test/fixtures/(\S+)
|
|
78
78
|
\s*
|
|
79
79
|
\d{4}-\d\d-\d\d
|
|
80
80
|
\s*
|
|
@@ -82,7 +82,7 @@ RSpec.describe "bin/ldiff" do
|
|
|
82
82
|
\s*
|
|
83
83
|
(?:[-+]\d{4}|Z)
|
|
84
84
|
}x,
|
|
85
|
-
'***
|
|
85
|
+
'*** test/fixtures/\1 0000-00-00 :00 =>:00 =>00.000000000 -0000'
|
|
86
86
|
)
|
|
87
87
|
end
|
|
88
88
|
|
|
@@ -92,7 +92,7 @@ RSpec.describe "bin/ldiff" do
|
|
|
92
92
|
right = options.fetch(:right)
|
|
93
93
|
|
|
94
94
|
stdout, stderr = capture_subprocess_io do
|
|
95
|
-
system("ruby -Ilib bin/ldiff #{flag}
|
|
95
|
+
system("ruby -Ilib bin/ldiff #{flag} test/fixtures/#{left} test/fixtures/#{right}")
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
[clean_data(stdout, flag), stderr, $?.exitstatus]
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
require "pathname"
|
|
5
|
-
|
|
6
|
-
require "psych" if RUBY_VERSION >= "1.9"
|
|
3
|
+
$LOAD_PATH.unshift File.expand_path(__dir__, "../lib")
|
|
7
4
|
|
|
5
|
+
require "rubygems"
|
|
8
6
|
require "simplecov"
|
|
9
7
|
require "simplecov-lcov"
|
|
10
8
|
|
|
9
|
+
require "diff/lcs"
|
|
10
|
+
|
|
11
11
|
SimpleCov::Formatter::LcovFormatter.config do |config|
|
|
12
12
|
config.report_with_single_file = true
|
|
13
13
|
config.lcov_file_name = "lcov.info"
|
|
@@ -23,12 +23,6 @@ SimpleCov.start "test_frameworks" do
|
|
|
23
23
|
])
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
file = Pathname.new(__FILE__).expand_path
|
|
27
|
-
path = file.parent
|
|
28
|
-
parent = path.parent
|
|
29
|
-
|
|
30
|
-
$:.unshift parent.join("lib")
|
|
31
|
-
|
|
32
26
|
module CaptureSubprocessIO
|
|
33
27
|
def _synchronize
|
|
34
28
|
yield
|
|
@@ -62,8 +56,6 @@ module CaptureSubprocessIO
|
|
|
62
56
|
private :_capture_subprocess_io
|
|
63
57
|
end
|
|
64
58
|
|
|
65
|
-
require "diff-lcs"
|
|
66
|
-
|
|
67
59
|
module Diff::LCS::SpecHelper
|
|
68
60
|
def hello
|
|
69
61
|
"hello"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Binary files test/fixtures/file1.bin and test/fixtures/file2.bin differ
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Binary files test/fixtures/file1.bin and test/fixtures/file2.bin differ
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Binary files test/fixtures/file1.bin and test/fixtures/file2.bin differ
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Binary files test/fixtures/file1.bin and test/fixtures/file2.bin differ
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Binary files test/fixtures/file1.bin and test/fixtures/file2.bin differ
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
***
|
|
2
|
-
---
|
|
1
|
+
*** test/fixtures/old-chef 2020-06-23 23:18:20.000000000 -0400
|
|
2
|
+
--- test/fixtures/new-chef 2020-06-23 23:18:20.000000000 -0400
|
|
3
3
|
***************
|
|
4
4
|
*** 1,4 ****
|
|
5
5
|
{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
***
|
|
2
|
-
---
|
|
1
|
+
*** test/fixtures/old-chef2 2020-06-30 09:43:35.000000000 -0400
|
|
2
|
+
--- test/fixtures/new-chef2 2020-06-30 09:44:32.000000000 -0400
|
|
3
3
|
***************
|
|
4
4
|
*** 1,5 ****
|
|
5
5
|
recipe[a::default]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
---
|
|
2
|
-
+++
|
|
1
|
+
--- test/fixtures/old-chef2 2020-06-30 09:43:35.000000000 -0400
|
|
2
|
+
+++ test/fixtures/new-chef2 2020-06-30 09:44:32.000000000 -0400
|
|
3
3
|
@@ -1,5 +1,4 @@
|
|
4
4
|
recipe[a::default]
|
|
5
5
|
-recipe[b::default]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
***
|
|
2
|
-
---
|
|
1
|
+
*** test/fixtures/four_lines 2025-01-31 12:17:43.926013315 +0100
|
|
2
|
+
--- test/fixtures/four_lines_with_missing_new_line 2025-01-31 12:17:43.926013315 +0100
|
|
3
3
|
***************
|
|
4
4
|
*** 1,4 ****
|
|
5
5
|
one
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
***
|
|
2
|
-
---
|
|
1
|
+
*** test/fixtures/four_lines_with_missing_new_line 2025-01-31 12:17:43.926013315 +0100
|
|
2
|
+
--- test/fixtures/four_lines 2025-01-31 12:17:43.926013315 +0100
|
|
3
3
|
***************
|
|
4
4
|
*** 1,4 ****
|
|
5
5
|
one
|
data/test/test_block.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "test_helper"
|
|
4
|
+
require "diff/lcs/block"
|
|
5
|
+
|
|
6
|
+
class TestBlock < Minitest::Test
|
|
7
|
+
include Diff::LCS::TestHelper
|
|
8
|
+
|
|
9
|
+
def test_op_unchanged
|
|
10
|
+
block = Diff::LCS::Block.from_chunk([])
|
|
11
|
+
assert_equal "^", block.op
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_op_delete
|
|
15
|
+
changes = [Diff::LCS::Change.new("-", 0, "a")]
|
|
16
|
+
block = Diff::LCS::Block.from_chunk(changes)
|
|
17
|
+
assert_equal "-", block.op
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_op_insert
|
|
21
|
+
changes = [Diff::LCS::Change.new("+", 0, "a")]
|
|
22
|
+
block = Diff::LCS::Block.from_chunk(changes)
|
|
23
|
+
assert_equal "+", block.op
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_op_conflict
|
|
27
|
+
changes = [
|
|
28
|
+
Diff::LCS::Change.new("-", 0, "a"),
|
|
29
|
+
Diff::LCS::Change.new("+", 0, "b")
|
|
30
|
+
]
|
|
31
|
+
block = Diff::LCS::Block.from_chunk(changes)
|
|
32
|
+
assert_equal "!", block.op
|
|
33
|
+
end
|
|
34
|
+
end
|