diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-30 08:43:52 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-30 08:43:52 +0000 |
commit | 020cc0ad5c5b4b2b2aac9e0a7fc9d35cfc76dfdc (patch) | |
tree | 345e65a2780135223edf8720e4ed07ed605faef7 /test | |
parent | c08785a36278ad10aa977168813e1cfcb531cc7b (diff) | |
download | ruby-020cc0ad5c5b4b2b2aac9e0a7fc9d35cfc76dfdc.tar.gz |
string.c: compare with to_str
* string.c (rb_str_cmp_m): try to compare with to_str result if
possible before calling <=> method. [ruby-core:49279] [Bug #7342]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_string.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 6c73a7ccc7..e988f99629 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -170,8 +170,9 @@ class TestString < Test::Unit::TestCase o = Object.new def o.to_str; "bar"; end - assert_nil("foo" <=> o) + assert_equal(1, "foo" <=> o) + class << o;remove_method :to_str;end def o.<=>(x); nil; end assert_nil("foo" <=> o) |