diff options
author | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-19 09:28:12 +0000 |
---|---|---|
committer | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-19 09:28:12 +0000 |
commit | b091ffcd5661b0d6c847135ccbf2b516602d06c1 (patch) | |
tree | 6b6ce7ab2c9ab3be6004b00ddd8e78c6f7c192b2 /test/-ext-/integer/test_my_integer.rb | |
parent | aedece589291dc8be6350935f432376a9b4a212b (diff) | |
download | ruby-b091ffcd5661b0d6c847135ccbf2b516602d06c1.tar.gz |
* bignum.c (Bignum#<=>): remove it because they are unified with
Integer#<=>.
* numeric.c (Integer#<=>, Fixnum#<=>): move <=> method from Fixnum to
Integer.
* numeric.c (int_cmp): add this method for Integer#<=>.
* test/-ext-/integer/test_my_integer.rb (test_my_integer_cmp): add a
test to examine Integer#<=> for unknown subclasses.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/-ext-/integer/test_my_integer.rb')
-rw-r--r-- | test/-ext-/integer/test_my_integer.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/-ext-/integer/test_my_integer.rb b/test/-ext-/integer/test_my_integer.rb index bc4757f463..e6d8dd1a07 100644 --- a/test/-ext-/integer/test_my_integer.rb +++ b/test/-ext-/integer/test_my_integer.rb @@ -23,4 +23,26 @@ class TestIntegerExt < Test::Unit::TestCase end end end + + def test_my_integer_cmp + assert_raise(NotImplementedError) do + Bug::Integer::MyInteger.new <=> 0 + end + + begin + Bug::Integer::MyInteger.class_eval do + def <=>(other) + 0 + end + end + + assert_nothing_raised do + Bug::Integer::MyInteger.new <=> 0 + end + ensure + Bug::Integer::MyInteger.class_eval do + remove_method :<=> + end + end + end end |