mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 22:14:37 +02:00
enumerator.c: allow Bignum for with_index
* enumerator.c (enumerator_with_index_i): allow Bignum as offset, to get rid of conversion exception and integer overflow. [ruby-dev:47131] [Bug #8010] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ce357ef152
commit
4a429c11e1
5 changed files with 25 additions and 10 deletions
|
@ -104,6 +104,14 @@ class TestEnumerator < Test::Unit::TestCase
|
|||
assert_equal([[1,5],[2,6],[3,7]], @obj.to_enum(:foo, 1, 2, 3).with_index(5).to_a)
|
||||
end
|
||||
|
||||
def test_with_index_large_offset
|
||||
bug8010 = '[ruby-dev:47131] [Bug #8010]'
|
||||
s = 1 << (8*1.size-2)
|
||||
assert_equal([[1,s],[2,s+1],[3,s+2]], @obj.to_enum(:foo, 1, 2, 3).with_index(s).to_a, bug8010)
|
||||
s <<= 1
|
||||
assert_equal([[1,s],[2,s+1],[3,s+2]], @obj.to_enum(:foo, 1, 2, 3).with_index(s).to_a, bug8010)
|
||||
end
|
||||
|
||||
def test_with_object
|
||||
obj = [0, 1]
|
||||
ret = (1..10).each.with_object(obj) {|i, memo|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue