diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-15 14:37:18 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-15 14:37:18 +0000 |
commit | abc1fbf6b22454366d957f427ef1e2ea32eda7e8 (patch) | |
tree | 7d2d9d454ecb67d5acd5b36f7a344891af96777b /test/ruby/test_symbol.rb | |
parent | 73c51efe974f7c0b9490680824f1f948ac797388 (diff) | |
download | ruby-abc1fbf6b22454366d957f427ef1e2ea32eda7e8.tar.gz ruby-abc1fbf6b22454366d957f427ef1e2ea32eda7e8.tar.xz ruby-abc1fbf6b22454366d957f427ef1e2ea32eda7e8.zip |
* test/ruby/test_string.rb: add tests to achieve over 90% test
coverage of string.c.
* test/ruby/test_m17n.rb: ditto.
* test/ruby/test_symbol.rb: ditto.
* test/ruby/test_pack.rb: ditto.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_symbol.rb')
-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 42350ba6e..a19a78e60 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 |