Sha256: 6b182e0e5a77956ca516e3d065d02b72daa9dfb54b67fb301f2e325d70bfe1e0

Contents?: true

Size: 1.3 KB

Versions: 5012

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

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 do |hunk|
      hunk.each do |change| change[0] = '+' end
    end
    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 be_empty
  end

  it 'returns an empty diff with (hello_ary, hello_ary)' do
    expect(Diff::LCS.diff(hello_ary, hello_ary)).to be_empty
  end
end

Version data entries

5,012 entries across 4,963 versions & 53 rubygems

Version Path
mux_ruby-3.20.0 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/spec/diff_spec.rb
mux_ruby-3.19.0 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/spec/diff_spec.rb
moneykit-0.1.15 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/spec/diff_spec.rb
moneykit-0.1.14 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/spec/diff_spec.rb
mux_ruby-3.18.0 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/spec/diff_spec.rb
moneykit-0.1.13 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/spec/diff_spec.rb
moneykit-0.1.12 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/spec/diff_spec.rb
moneykit-0.1.11 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/spec/diff_spec.rb
mux_ruby-3.17.0 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/spec/diff_spec.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.4.4/spec/diff_spec.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.4.4/spec/diff_spec.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.4.4/spec/diff_spec.rb
moneykit-0.1.10 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/spec/diff_spec.rb
moneykit-0.1.9 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/spec/diff_spec.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/spec/diff_spec.rb
mux_ruby-3.15.0 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/spec/diff_spec.rb
avalara_sdk-24.2.29 vendor/bundle/ruby/2.7.0/gems/diff-lcs-1.5.0/spec/diff_spec.rb
mux_ruby-3.14.0 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/spec/diff_spec.rb
moneykit-0.1.6 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/spec/diff_spec.rb
moneykit-0.1.5 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/spec/diff_spec.rb