Sha256: a84460f686d68debb4fd222a4db71a4483cdb2ee760d27c26bd53c4759985110

Contents?: true

Size: 1.31 KB

Versions: 212

Compression:

Stored size: 1.31 KB

Contents

# -*- ruby encoding: utf-8 -*-

require 'spec_helper'

describe "Diff::LCS.diff" do
  include Diff::LCS::SpecHelper::Matchers

  it 'correctly diffs seq1 to seq2' do
    diff_s1_s2 = Diff::LCS.diff(seq1, seq2)
    expect(change_diff(correct_forward_diff)).to eq(diff_s1_s2)
  end

  it 'correctly diffs seq2 to seq1' do
    diff_s2_s1 = Diff::LCS.diff(seq2, seq1)
    expect(change_diff(correct_backward_diff)).to eq(diff_s2_s1)
  end

  it 'correctly diffs against an empty sequence' do
    diff = Diff::LCS.diff(word_sequence, [])
    correct_diff = [
      [ [ '-', 0, 'abcd'           ],
        [ '-', 1, 'efgh'           ],
        [ '-', 2, 'ijkl'           ],
        [ '-', 3, 'mnopqrstuvwxyz' ] ]
    ]

    expect(change_diff(correct_diff)).to eq(diff)

    diff = Diff::LCS.diff([], word_sequence)
    correct_diff.each { |hunk| hunk.each { |change| change[0] = '+' } }
    expect(change_diff(correct_diff)).to eq(diff)
  end

  it "correctly diffs 'xx' and 'xaxb'" do
    left = 'xx'
    right = 'xaxb'
    expect(Diff::LCS.patch(left, Diff::LCS.diff(left, right))).to eq(right)
  end

  it "returns an empty diff with (hello, hello)" do
    expect(Diff::LCS.diff(hello, hello)).to eq([])
  end

  it "returns an empty diff with (hello_ary, hello_ary)" do
    expect(Diff::LCS.diff(hello_ary, hello_ary)).to eq([])
  end
end

Version data entries

212 entries across 193 versions & 54 rubygems

Version Path
pomodorokun-0.1.0 bundle/ruby/2.4.0/gems/diff-lcs-1.3/spec/ldiff_spec.rb
xaiml-0.1.3 vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.3/spec/ldiff_spec.rb
alimentos-alu0100945645-0.1.0 vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.3/spec/ldiff_spec.rb
alimentos-alu0100945645-1.0.0 vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.3/spec/ldiff_spec.rb
xaiml-0.1.2 vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.3/spec/ldiff_spec.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.3/spec/ldiff_spec.rb
tdiary-5.0.11 vendor/bundle/gems/diff-lcs-1.3/spec/ldiff_spec.rb
embulk-input-druginfo_interview_form-0.1.0 vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.3/spec/ldiff_spec.rb
embulk-input-druginfo_interview_form-0.1.0 vendor/bundle/ruby/2.4.0/gems/diff-lcs-1.3/spec/ldiff_spec.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.3/spec/ldiff_spec.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.3/spec/ldiff_spec.rb
xaiml-0.1.1 vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.3/spec/ldiff_spec.rb
xaiml-0.1.0 vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.3/spec/ldiff_spec.rb
bsielski_control_flow-1.0.0 vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.3/spec/ldiff_spec.rb
vagrant-unbundled-2.1.4.0 vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.3/spec/ldiff_spec.rb
vagrant-unbundled-2.1.2.0 vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.3/spec/ldiff_spec.rb
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.3/spec/ldiff_spec.rb
dirwatch-0.0.8 vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.3/spec/ldiff_spec.rb
cloudsmith-api-0.30.7 vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.3/spec/ldiff_spec.rb
logstash-filter-device_detection-1.0.7-java vendor/bundle/jruby/1.9/gems/diff-lcs-1.3/spec/ldiff_spec.rb