diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-22 13:33:34 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-22 13:33:34 +0000 |
commit | bd3eb8afec7f814f25827d4c5359a0b3d20a28bf (patch) | |
tree | 57e49ec5a1164e87d615a1eaa1657cdedd0a210c /test/ruby/test_numeric.rb | |
parent | 4154b96068eab8fc5e9359ad26747e9dabdceea1 (diff) |
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.rb | 27 |
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 |