1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Remove lcs - dead code

This commit is contained in:
Norman Clarke 2012-05-22 16:38:13 -03:00
parent 795efb7873
commit e747898474
2 changed files with 0 additions and 35 deletions

View file

@ -106,24 +106,6 @@ module Haml
end
end
# Computes a single longest common subsequence for `x` and `y`.
# If there are more than one longest common subsequences,
# the one returned is that which starts first in `x`.
#
# @param x [Array]
# @param y [Array]
# @yield [a, b] An optional block to use in place of a check for equality
# between elements of `x` and `y`.
# @yieldreturn [Object, nil] If the two values register as equal,
# this will return the value to use in the LCS array.
# @return [Array] The LCS
def lcs(x, y, &block)
x = [nil, *x]
y = [nil, *y]
block ||= proc {|a, b| a == b && a}
lcs_backtrace(lcs_table(x, y, &block), x, y, x.size-1, y.size-1, &block)
end
# Returns information about the caller of the previous method.
#
# @param entry [String] An entry in the `#caller` list, or a similarly formatted string

View file

@ -65,23 +65,6 @@ class UtilTest < MiniTest::Unit::TestCase
powerset([1, 2, 3]))
end
def test_lcs
assert_equal([1, 2, 3], lcs([1, 2, 3], [1, 2, 3]))
assert_equal([], lcs([], [1, 2, 3]))
assert_equal([], lcs([1, 2, 3], []))
assert_equal([1, 2, 3], lcs([5, 1, 4, 2, 3, 17], [0, 0, 1, 2, 6, 3]))
assert_equal([1], lcs([1, 2, 3, 4], [4, 3, 2, 1]))
assert_equal([1, 2], lcs([1, 2, 3, 4], [3, 4, 1, 2]))
end
def test_lcs_with_block
assert_equal(["1", "2", "3"],
lcs([1, 4, 2, 5, 3], [1, 2, 3]) {|a, b| a == b && a.to_s})
assert_equal([-4, 2, 8],
lcs([-5, 3, 2, 8], [-4, 1, 8]) {|a, b| (a - b).abs <= 1 && [a, b].max})
end
def test_silence_warnings
old_stderr, $stderr = $stderr, StringIO.new
warn "Out"