зеркало из https://github.com/github/ruby.git
Fix a line matching problem in Abbrev.abbrev(words, "prefix").
* lib/abbrev.rb (Abbrev#abbrev): A fixed string prefix pattern should only match the beginning of each word, not the beginning of every line in it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
aac52e2b87
Коммит
4078d42b72
|
@ -1,3 +1,9 @@
|
|||
Fri Nov 30 12:47:59 2012 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* lib/abbrev.rb (Abbrev#abbrev): A fixed string prefix pattern
|
||||
should only match the beginning of each word, not the beginning
|
||||
of every line in it.
|
||||
|
||||
Fri Nov 30 12:30:55 2012 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* test/test_abbrev.rb: Add tests for lib/abbrev.rb.
|
||||
|
|
|
@ -69,7 +69,7 @@ module Abbrev
|
|||
seen = Hash.new(0)
|
||||
|
||||
if pattern.is_a?(String)
|
||||
pattern = /^#{Regexp.quote(pattern)}/ # regard as a prefix
|
||||
pattern = /\A#{Regexp.quote(pattern)}/ # regard as a prefix
|
||||
end
|
||||
|
||||
words.each do |word|
|
||||
|
|
|
@ -36,12 +36,19 @@ class TestAbbrev < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_abbrev_lf
|
||||
words = ["abc", "abc\nd", "de"]
|
||||
|
||||
assert_equal({
|
||||
"abc" => "abc",
|
||||
"abc\n" => "abc\nd",
|
||||
"abc\nd" => "abc\nd",
|
||||
"d" => "de",
|
||||
"de" => "de",
|
||||
}, Abbrev.abbrev(["abc", "abc\nd", "de"]))
|
||||
}, words.abbrev)
|
||||
|
||||
assert_equal({
|
||||
"d" => "de",
|
||||
"de" => "de",
|
||||
}, words.abbrev('d'))
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче