Skip to content
Browse files

Fix pruning of common sequences at start.

  • Loading branch information...
1 parent 12df45e commit 986cf913b7798d4cb244847eb0508a3fcafc9aa1 @pck committed Apr 20, 2013
Showing with 7 additions and 0 deletions.
  1. +1 −0 lib/diff/lcs/internals.rb
  2. +6 −0 spec/diff_spec.rb
View
1 lib/diff/lcs/internals.rb
@@ -49,6 +49,7 @@ def lcs(a, b)
(a[a_start] == b[b_start]))
vector[a_start] = b_start
a_start += 1
+ b_start += 1
end
b_start = a_start
View
6 spec/diff_spec.rb
@@ -31,6 +31,12 @@
change_diff(correct_diff).should == diff
end
+ it "should correctly diff 'xx' and 'xaxb'" do
+ left = 'xx'
+ right = 'xaxb'
+ Diff::LCS.patch(left, Diff::LCS.diff(left, right)).should == right
+ end
+
it "should return an empty diff with (hello, hello)" do
Diff::LCS.diff(hello, hello).should == []
end

0 comments on commit 986cf91

Please sign in to comment.
Something went wrong with that request. Please try again.