diff options
author | Austin Ziegler <austin@halostatue.ca> | 2011-07-31 15:35:30 -0400 |
---|---|---|
committer | Austin Ziegler <austin@halostatue.ca> | 2011-07-31 15:35:30 -0400 |
commit | 095afd9c321d4de8457dee91eb030c08981ee39b (patch) | |
tree | 919202e2ddbbed2519685e9fc934bab520864c6d /spec/traverse_sequences_spec.rb | |
parent | 340073b761d16d7ec3a0a559e0c8d706b1d2dff9 (diff) | |
download | diff-lcs-095afd9c321d4de8457dee91eb030c08981ee39b.tar.gz |
Cleaning up the specs.
Diffstat (limited to 'spec/traverse_sequences_spec.rb')
-rw-r--r-- | spec/traverse_sequences_spec.rb | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/spec/traverse_sequences_spec.rb b/spec/traverse_sequences_spec.rb new file mode 100644 index 0000000..c7a5558 --- /dev/null +++ b/spec/traverse_sequences_spec.rb @@ -0,0 +1,83 @@ +# -*- ruby encoding: utf-8 -*- + +require 'spec_helper' + +describe "Diff::LCS.traverse_sequences" do + describe "callback with no finishers" do + before(:each) do + @callback_s1_s2 = simple_callback_no_finishers + Diff::LCS.traverse_sequences(seq1, seq2, @callback_s1_s2) + + @callback_s2_s1 = simple_callback_no_finishers + Diff::LCS.traverse_sequences(seq2, seq1, @callback_s2_s1) + end + + it "should have the correct LCS result on left-matches" do + @callback_s1_s2.matched_a.should == correct_lcs + @callback_s2_s1.matched_a.should == correct_lcs + end + + it "should have the correct LCS result on right-matches" do + @callback_s1_s2.matched_b.should == correct_lcs + @callback_s2_s1.matched_b.should == correct_lcs + end + + it "should have the correct skipped sequences for the left sequence" do + @callback_s1_s2.discards_a.should == skipped_seq1 + @callback_s2_s1.discards_a.should == skipped_seq2 + end + + it "should have the correct skipped sequences for the right sequence" do + @callback_s1_s2.discards_b.should == skipped_seq2 + @callback_s2_s1.discards_b.should == skipped_seq1 + end + + it "should not have anything done markers from the left or right sequences" do + @callback_s1_s2.done_a.should be_empty + @callback_s1_s2.done_b.should be_empty + @callback_s2_s1.done_a.should be_empty + @callback_s2_s1.done_b.should be_empty + end + end + + describe "callback with finisher" do + before(:each) do + @callback_s1_s2 = simple_callback + Diff::LCS.traverse_sequences(seq1, seq2, @callback_s1_s2) + @callback_s2_s1 = simple_callback + Diff::LCS.traverse_sequences(seq2, seq1, @callback_s2_s1) + end + + it "should have the correct LCS result on left-matches" do + @callback_s1_s2.matched_a.should == correct_lcs + @callback_s2_s1.matched_a.should == correct_lcs + end + + it "should have the correct LCS result on right-matches" do + @callback_s1_s2.matched_b.should == correct_lcs + @callback_s2_s1.matched_b.should == correct_lcs + end + + it "should have the correct skipped sequences for the left sequence" do + @callback_s1_s2.discards_a.should == skipped_seq1 + @callback_s2_s1.discards_a.should == skipped_seq2 + end + + it "should have the correct skipped sequences for the right sequence" do + @callback_s1_s2.discards_b.should == skipped_seq2 + @callback_s2_s1.discards_b.should == skipped_seq1 + end + + it "should have done markers differently-sized sequences" do + @callback_s1_s2.done_a.should == [[ "p", 9, "s", 10 ]] + @callback_s1_s2.done_b.should be_empty + + # 20110731 I don't yet understand why this particular behaviour + # isn't transitive. + @callback_s2_s1.done_a.should be_empty + @callback_s2_s1.done_b.should be_empty + end + end +end + +# vim: ft=ruby |