mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 14:05:02 +02:00
range.c: fix fixnum loop condition
* range.c (range_step): FIXABLE + FIXABLE never overflow, but may not be FIXABLE. [Feature #12912] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5a5c9a706c
commit
ad5a6aa790
2 changed files with 9 additions and 4 deletions
|
@ -3,6 +3,7 @@ require 'test/unit'
|
|||
require 'delegate'
|
||||
require 'timeout'
|
||||
require 'bigdecimal'
|
||||
require 'rbconfig/sizeof'
|
||||
|
||||
class TestRange < Test::Unit::TestCase
|
||||
def test_new
|
||||
|
@ -244,6 +245,11 @@ class TestRange < Test::Unit::TestCase
|
|||
(2**32-1 .. ).step(2) {|x| a << x; break if a.size == 2 }
|
||||
assert_equal([4294967295, 4294967297], a)
|
||||
|
||||
a = []
|
||||
max = RbConfig::LIMITS["FIXNUM_MAX"]
|
||||
(max..).step {|x| a << x; break if a.size == 2 }
|
||||
assert_equal([max, max+1], a)
|
||||
|
||||
o1 = Object.new
|
||||
o2 = Object.new
|
||||
def o1.<=>(x); -1; end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue