summaryrefslogtreecommitdiff
path: root/test/test_abbrev.rb
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-30 03:35:01 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-30 03:35:01 +0000
commit06c3b413f07bfcc93621fb644a4865e8f48cf851 (patch)
treedf06730d5e9150fb051cfd511d17363dde6b80a4 /test/test_abbrev.rb
parentaee295fc747c7e117f4b550ab806057b4c4738a4 (diff)
Add tests for lib/abbrev.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_abbrev.rb')
-rw-r--r--test/test_abbrev.rb49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/test_abbrev.rb b/test/test_abbrev.rb
new file mode 100644
index 0000000..3cf1acf
--- /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