diff --git a/ChangeLog b/ChangeLog index 20cdcdf7b1..bfaa054a9c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Nov 30 12:30:55 2012 Akinori MUSHA + + * test/test_abbrev.rb: Add tests for lib/abbrev.rb. + Fri Nov 30 12:27:51 2012 Eric Hodel * lib/rubygems/spec_fetcher.rb: Allow prerelease spec fetching to fail diff --git a/test/test_abbrev.rb b/test/test_abbrev.rb new file mode 100644 index 0000000000..3cf1acfb05 --- /dev/null +++ b/test/test_abbrev.rb @@ -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