1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Add tests for lib/abbrev.rb.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2012-11-30 03:35:01 +00:00
parent aee295fc74
commit 06c3b413f0
2 changed files with 53 additions and 0 deletions

View file

@ -1,3 +1,7 @@
Fri Nov 30 12:30:55 2012 Akinori MUSHA <knu@iDaemons.org>
* test/test_abbrev.rb: Add tests for lib/abbrev.rb.
Fri Nov 30 12:27:51 2012 Eric Hodel <drbrain@segment7.net>
* lib/rubygems/spec_fetcher.rb: Allow prerelease spec fetching to fail

49
test/test_abbrev.rb Normal file
View file

@ -0,0 +1,49 @@
require 'test/unit'
require 'abbrev'
class TestAbbrev < Test::Unit::TestCase
def test_abbrev
words = %w[summer winter ruby rules]
assert_equal({
"rub" => "ruby",
"ruby" => "ruby",
"rul" => "rules",
"rule" => "rules",
"rules" => "rules",
"s" => "summer",
"su" => "summer",
"sum" => "summer",
"summ" => "summer",
"summe" => "summer",
"summer" => "summer",
"w" => "winter",
"wi" => "winter",
"win" => "winter",
"wint" => "winter",
"winte" => "winter",
"winter" => "winter",
}, words.abbrev)
assert_equal({
"rub" => "ruby",
"ruby" => "ruby",
"rul" => "rules",
"rule" => "rules",
"rules" => "rules",
}, words.abbrev('ru'))
assert_equal words.abbrev, Abbrev.abbrev(words)
assert_equal words.abbrev('ru'), Abbrev.abbrev(words, 'ru')
end
def test_abbrev_lf
assert_equal({
"abc" => "abc",
"abc\n" => "abc\nd",
"abc\nd" => "abc\nd",
"d" => "de",
"de" => "de",
}, Abbrev.abbrev(["abc", "abc\nd", "de"]))
end
end