Support svalue

This commit is contained in:
ksss
2016-12-01 15:32:29 +09:00
parent 0f774ff4df
commit 2718fed124
2 changed files with 5 additions and 2 deletions
@@ -162,9 +162,9 @@ class Enumerator
end
n = offset - 1
enumerator_block_call do |i|
enumerator_block_call do |*i|
n += 1
yield [i,n]
yield i.__svalue, n
end
end
@@ -50,6 +50,9 @@ end
assert 'Enumerator#with_index' do
assert_equal([[1,0],[2,1],[3,2]], @obj.to_enum(:foo, 1, 2, 3).with_index.to_a)
assert_equal([[1,5],[2,6],[3,7]], @obj.to_enum(:foo, 1, 2, 3).with_index(5).to_a)
a = []
@obj.to_enum(:foo, 1, 2, 3).with_index(10).with_index(20) { |*i| a << i }
assert_equal [[[1, 10], 20], [[2, 11], 21], [[3, 12], 22]], a
end
assert 'Enumerator#with_index nonnum offset' do