diff options
| author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-12-31 15:40:46 +0000 |
|---|---|---|
| committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-12-31 15:40:46 +0000 |
| commit | 25e036d5aab50395e91a9051bba023253b6792ad (patch) | |
| tree | ebed826326bd80a617160e2b414ccb04a2ac8e3c /test/ruby | |
| parent | 3f1da781c56e779e303b23d0bf0053780f342e5b (diff) | |
* string.c: Add instance methods to Symbol: succ, next, <=>,
casecmp, =~, [], slice, length, size, empty?, match, upcase,
downcase, capitalize and swapcase. [backport from 1.9]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@26222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_symbol.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb index 42350ba6e7..a19a78e605 100644 --- a/test/ruby/test_symbol.rb +++ b/test/ruby/test_symbol.rb @@ -89,4 +89,47 @@ class TestSymbol < Test::Unit::TestCase assert_equal ary_ids, ary.collect(&:object_id) end end + + def test_call + o = Object.new + def o.foo(x, y); x + y; end + + assert_equal(3, :foo.to_proc.call(o, 1, 2)) + assert_raise(ArgumentError) { :foo.to_proc.call } + end + + def test_succ + assert_equal(:fop, :foo.succ) + end + + def test_cmp + assert_equal(0, :FoO <=> :FoO) + assert_equal(-1, :FoO <=> :fOO) + assert_equal(1, :fOO <=> :FoO) + assert_nil(:foo <=> "foo") + end + + def test_casecmp + assert_equal(0, :FoO.casecmp(:fOO)) + assert_equal(1, :FoO.casecmp(:BaR)) + assert_equal(-1, :baR.casecmp(:FoO)) + assert_nil(:foo.casecmp("foo")) + end + + def test_length + assert_equal(3, :FoO.length) + assert_equal(3, :FoO.size) + end + + def test_empty + assert_equal(false, :FoO.empty?) + assert_equal(true, :"".empty?) + end + + def test_case + assert_equal(:FOO, :FoO.upcase) + assert_equal(:foo, :FoO.downcase) + assert_equal(:Foo, :foo.capitalize) + assert_equal(:fOo, :FoO.swapcase) + end end |
