aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_numeric.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-22 13:33:34 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-22 13:33:34 +0000
commitda503a9e2345b3772774297d9ac9106146f2c65a (patch)
tree57e49ec5a1164e87d615a1eaa1657cdedd0a210c /test/ruby/test_numeric.rb
parent0e2ab7ea3c308078e71263b0ba83259e1a238fa7 (diff)
downloadruby-da503a9e2345b3772774297d9ac9106146f2c65a.tar.gz
numeric.c: fix up r55891
* numeric.c (num_funcall1): check recursion by inverse pair, to fix fake infinite recursion. [ruby-core:77713] [Bug #12864] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_numeric.rb')
-rw-r--r--test/ruby/test_numeric.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb
index c5817c5efe..eb056f61c3 100644
--- a/test/ruby/test_numeric.rb
+++ b/test/ruby/test_numeric.rb
@@ -353,4 +353,31 @@ class TestNumeric < Test::Unit::TestCase
assert_raise(ArgumentError) {1.remainder(x)}
end;
end
+
+ def test_comparison_comparable
+ bug12864 = '[ruby-core:77713] [Bug #12864]'
+
+ myinteger = Class.new do
+ include Comparable
+
+ def initialize(i)
+ @i = i.to_i
+ end
+ attr_reader :i
+
+ def <=>(other)
+ @i <=> (other.is_a?(self.class) ? other.i : other)
+ end
+ end
+
+ all_assertions(bug12864) do |a|
+ [5, 2**62, 2**61].each do |i|
+ a.for("%#x"%i) do
+ m = myinteger.new(i)
+ assert_equal(i, m)
+ assert_equal(m, i)
+ end
+ end
+ end
+ end
end