1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/test_abbrev.rb
kazu b15f8b6de9 lib/abbrev.rb: Specify frozen_string_literal: true.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-09 16:12:00 +00:00

55 lines
1.3 KiB
Ruby

# frozen_string_literal: true
require 'test/unit'
require 'abbrev'
class TestAbbrev < Test::Unit::TestCase
def test_abbrev
words = %w[summer winter win 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",
"win" => "win",
"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
words = ["abc", "abc\nd", "de"]
assert_equal({
"abc" => "abc",
"abc\n" => "abc\nd",
"abc\nd" => "abc\nd",
"d" => "de",
"de" => "de",
}, words.abbrev)
assert_equal({
"d" => "de",
"de" => "de",
}, words.abbrev('d'))
end
end