summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Ziegler <austin@zieglers.ca>2013-04-20 19:56:19 -0400
committerAustin Ziegler <austin@zieglers.ca>2013-04-20 19:56:19 -0400
commitd11d10143e9b98d9a1ba1cd053f750efc299b5e4 (patch)
treefcdb4a777230c8d45c6c473b17ada9eff2b23517
parentf3d75164d36c93b0ab78fc79a5a3beb358a0f4be (diff)
parent28fc343b704c4d7cfa6cc58ab799a0249c0da084 (diff)
downloaddiff-lcs-d11d10143e9b98d9a1ba1cd053f750efc299b5e4.tar.gz
Merge branch 'master' of github-halostatue:halostatue/diff-lcs
* 'master' of github-halostatue:halostatue/diff-lcs: Fix pruning of common sequences at start.
-rw-r--r--lib/diff/lcs/internals.rb1
-rw-r--r--spec/diff_spec.rb6
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/diff/lcs/internals.rb b/lib/diff/lcs/internals.rb
index fe4ed9b..9d9e3f3 100644
--- a/lib/diff/lcs/internals.rb
+++ b/lib/diff/lcs/internals.rb
@@ -49,6 +49,7 @@ class << Diff::LCS::Internals
(a[a_start] == b[b_start]))
vector[a_start] = b_start
a_start += 1
+ b_start += 1
end
b_start = a_start
diff --git a/spec/diff_spec.rb b/spec/diff_spec.rb
index e82ab3d..95d7b40 100644
--- a/spec/diff_spec.rb
+++ b/spec/diff_spec.rb
@@ -31,6 +31,12 @@ describe "Diff::LCS.diff" do
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